[FFmpeg-trac] #3576(ffmpeg:new): decoding MP3 (LAME) results in wrong length

FFmpeg trac at avcodec.org
Mon Apr 21 03:24:54 CEST 2014


#3576: decoding MP3 (LAME) results in wrong length
-------------------------------------+-------------------------------------
             Reporter:  tobwen       |                     Type:  defect
               Status:  new          |                 Priority:  important
            Component:  ffmpeg       |                  Version:  git-
             Keywords:  MP3, LAME,   |  master
  audio, delay, padding              |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 = What I was trying to accomplish =
 I was trying to transcode from MP3 to 44.1 kHz, 16-bit stereo WAV file.
 Since it uses libmp3lame, the output should be equal to the CLI version.

 = The problem I encountered =
 The output is too long by 1263 samples.

 I've used LAME v3.99.5 aka v3.99r (same es libmp3lame) to transcode a
 testfile with 441000 samples (10 seconds) to MP3 using this command line:
 {{{lame test_tobwen.wav -V 2 test_tobwen.mp3}}}

 When decoding it with the same lame version, it's exactly 441000 samples
 long.
 {{{lame --decode test_tobwen.mp3 output_lame.wav}}}

 LAME recognizes its own tag and skils encoder+decoder delay (1105 samples)
 and padding-decoder delay (263) samples.
 You can read more about this here:
 http://mp3decoders.mp3-tech.org/decoders_lame.html

 = excact command line I was using =
 {{{ffmpeg -i test_tobwen.mp3 -acodec pcm_s16le output_ffmpeg.wav}}}

 = full, uncut console output =
 {{{ffmpeg -v 9 -loglevel 99 -i test_tobwen.mp3  -acodec pcm_s16le
 output_ffmpeg.wav}}}

 {{{
 ffmpeg version N-62569-gf57ac37 Copyright (c) 2000-2014 the FFmpeg
 developers
   built on Apr 19 2014 22:03:22 with gcc 4.8.2 (GCC)
   configuration: --enable-gpl --enable-version3 --disable-w32threads
 --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
 --enable-gnutls --enable-iconv --enable-libass --enable-libbluray
 --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc
 --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
 --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-
 librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex
 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-
 aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs
 --enable-libxvid --enable-decklink --enable-zlib
   libavutil      52. 77.100 / 52. 77.100
   libavcodec     55. 58.105 / 55. 58.105
   libavformat    55. 37.101 / 55. 37.101
   libavdevice    55. 13.100 / 55. 13.100
   libavfilter     4.  4.100 /  4.  4.100
   libswscale      2.  6.100 /  2.  6.100
   libswresample   0. 18.100 /  0. 18.100
   libpostproc    52.  3.100 / 52.  3.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-i' ... matched as input file with argument
 'test_tobwen.mp3'.
 Reading option '-acodec' ... matched as option 'acodec' (force audio codec
 ('copy' to copy stream)) with argument 'pcm_s16le'.
 Reading option 'output_ffmpeg.wav' ... matched as output file.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Successfully parsed a group of options.
 Parsing a group of options: input file test_tobwen.mp3.
 Successfully parsed a group of options.
 Opening an input file: test_tobwen.mp3.
 [mp3 @ 04395000] Format mp3 probed with size=2048 and score=51
 [mp3 @ 04395000] pad 576 792
 [mp3 @ 04395000] Before avformat_find_stream_info() pos: 417 bytes
 read:65664 seeks:2
 [mp3 @ 04395000] demuxer injecting skip 1105
 [mp3 @ 04395820] skip 1105 samples due to side data
 [mp3 @ 04395820] skip 1105/1152 samples
 [mp3 @ 04395000] max_analyze_duration 5000000 reached at 5015510
 microseconds
 [mp3 @ 04395000] After avformat_find_stream_info() pos: 57761 bytes
 read:98432 seeks:2 frames:194
 Input #0, mp3, from 'test_tobwen.mp3':
   Duration: 00:00:10.03, start: 0.025057, bitrate: 104 kb/s
     Stream #0:0, 194, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16p, 104
 kb/s
     Metadata:
       encoder         : LAME3.99r
 Successfully opened the file.
 Parsing a group of options: output file output_ffmpeg.wav.
 Applying option acodec (force audio codec ('copy' to copy stream)) with
 argument pcm_s16le.
 Successfully parsed a group of options.
 Opening an output file: output_ffmpeg.wav.
 Successfully opened the file.
 detected 4 logical cores
 [graph 0 input from stream 0:0 @ 029dd2c0] Setting 'time_base' to value
 '1/44100'
 [graph 0 input from stream 0:0 @ 029dd2c0] Setting 'sample_rate' to value
 '44100'
 [graph 0 input from stream 0:0 @ 029dd2c0] Setting 'sample_fmt' to value
 's16p'
 [graph 0 input from stream 0:0 @ 029dd2c0] Setting 'channel_layout' to
 value '0x3'
 [graph 0 input from stream 0:0 @ 029dd2c0] tb:1/44100 samplefmt:s16p
 samplerate:44100 chlayout:0x3
 [audio format for output stream 0:0 @ 029d7920] Setting 'sample_fmts' to
 value 's16'
 [audio format for output stream 0:0 @ 029d7920] auto-inserting filter
 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the
 filter 'audio format for output stream 0:0'
 [AVFilterGraph @ 043bd100] query_formats: 4 queried, 6 merged, 3 already
 done, 0 delayed
 [auto-inserted resampler 0 @ 029d7f00] ch:2 chl:stereo fmt:s16p r:44100Hz
 -> ch:2 chl:stereo fmt:s16 r:44100Hz
 Output #0, wav, to 'output_ffmpeg.wav':
   Metadata:
     ISFT            : Lavf55.37.101
     Stream #0:0, 0, 1/44100: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
 44100 Hz, stereo, s16, 1411 kb/s
     Metadata:
       encoder         : LAME3.99r
 Stream mapping:
   Stream #0:0 -> #0:0 (mp3 -> pcm_s16le)
 Press [q] to stop, [?] for help
 [mp3 @ 04395820] skip 1105 samples due to side data
 [mp3 @ 04395820] skip 1105/1152 samples
 [output stream 0:0 @ 029d78a0] EOF on sink link output stream 0:0:default.
 No more output streams to write to, finishing.
 size=    1724kB time=00:00:10.00 bitrate=1411.3kbits/s

 video:0kB audio:1724kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.004532%
 Input file #0 (test_tobwen.mp3):
   Input stream #0:0 (audio): 384 packets read (130730 bytes); 384 frames
 decoded (441263 samples);
   Total: 384 packets (130730 bytes) demuxed
 Output file #0 (output_ffmpeg.wav):
   Output stream #0:0 (audio): 384 frames encoded (441263 samples); 384
 packets muxed (1765052 bytes);
   Total: 384 packets (1765052 bytes) muxed
 384 frames successfully decoded, 0 decoding errors
 [AVIOContext @ 043c4a60] Statistics: 4 seeks, 387 writeouts
 [AVIOContext @ 043949e0] Statistics: 164020 bytes read, 2 seeks
 }}}

 == Files attached to this ticket ==
 I've uploaded test_tobwen.wav and test_tobwen.mp3 to the FTP.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3576>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list