CC: | andy [...] slimdevices.com |
Subject: | MP3::Cut::Gapless does not respect bitrate |
Date: | Mon, 08 Jul 2013 16:08:51 -0700 |
To: | bug-MP3-Cut-Gapless [...] rt.cpan.org |
From: | Ray Lutz <raylutz [...] cognisys.com> |
Hi!
Thanks for your work on this.
BUG NAME:
MP3::Cut::Gapless does not correctly respect bitrate
PLATFORM
* Perl: v5.8.8 built for i386-linux-thread-multi
* OS: CentOS (like Fedora)
* Linux 192.168.123.130 2.6.18-348.4.1.el5 #1 SMP Tue Apr 16
16:02:56 EDT 2013 i686 athlon i386 GNU/Linux
* MP3::Cut::Gapless is up to date (0.03).
PROBLEM:
* When I cut an mp3 file, it does not respect the bitrate.
* I think maybe the first frame is the only one that is screwed up
as the streaming server complains about it and then assumes it is VBR
encoding.
* Trouble is that MP3Info reports the incorrect duration which is
calculated based on the bitrate.
* Maybe 64k is assumed??
EXAMPLE:
Cut 32kpbs file (mono) that is nominally 3600 seconds long (an hour)
into two 1800 sec segments.
Info about the source file:
-------------------------------------
print_mp3info($src_mp3_file, $sourcepath)
dn2013-0705-1.mp3
MPEG VERSION 2
MPEG LAYER 3
STEREO
VBR
BITRATE 32 kbps
FREQUENCY 22.05 KHz
SIZE 14168294 bytes
OFFSET 269 bytes
SECS 3542.0735
MM minutes 59
SS seconds left 2
MS ms left 73.4999999999673
TIME in MM:SS 59:02
COPYRIGHT
PADDING
MODE 3 (single channel)
FRAMES 135595
FRAME_LENGTH 104
VBR_SCALE
============================
AND here is the info about the output file after cutting off the first
1800 seconds:
Notice that it is set to 64kpbs and it thinks the file is 900 seconds
long. (when played it will play for 1800 seconds)
Player thinks first frame is different from the rest.
DB<6> print_mp3info($outname, $outdir.'/'.$outname)
cut_dn2013-0705-1_1800_000.mp3
MPEG VERSION 2
MPEG LAYER 3
STEREO
VBR
BITRATE 64 kbps
FREQUENCY 22.05 KHz
SIZE 7200493 bytes
OFFSET bytes
SECS 900.061625
MM minutes 15
SS seconds left
MS ms left 61.6250000000491
TIME in MM:SS 15:00
COPYRIGHT
PADDING
MODE 3 (single channel)
FRAMES 34455
FRAME_LENGTH 208
VBR_SCALE
============================
Cutting algorithm
my $cut = MP3::Cut::Gapless->new(
file => $sourcepath,
cache_dir => $Config{TempDir},
start_ms => 0,
end_ms => 1800,
);
open my $out, '>', $outdir.'/'.$outname;
while ( $cut->read( my $buf, 4096 ) ) {
syswrite $out, $buf;
}
close $out;
You can check the input and output files I used to test this here:
http://www.cognisys.com/downloads/MP3-Cut-Gapless-errorfiles
Contact me at raylutz@cognisys.com
--
-----------------------
Ray Lutz
Cognisys, Inc.
Cognisys.com
619-820-5321