Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#289 closed defect (fixed)

Regression: mp3 duration estimated from bitrate wrong (bitrate guess wrong)

Reported by: hjr Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: regression mp3 duration bitrate estimate roundup
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Bitrate is analyzed wrong and mp3 duration is way off then.

Recent win32 build

>ffmpeg -v 9 -loglevel 99 -i duration-problem.mp3
ffmpeg version git-N-30698-g39dbe9b, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 10 2011 22:10:00 with gcc 4.5.3
  configuration: --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --disable-outdev=sdl --pkg-config=pkg-config
  libavutil    51.  8. 0 / 51.  8. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  3. 0 / 53.  3. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[NULL @ 01DDA180] Format mp3 probed with size=2048 and score=51
[mp3 @ 01DDA180] max_analyze_duration 5000000 reached at 5015510
[mp3 @ 01DDA180] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'duration-problem.mp3':
  Metadata:
    encoder         : Lavf52.39.2
  Duration: 00:14:44.44, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0, 194, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16, 32 kb/s
At least one output file must be specified

Duration and bitrate is incorrect, the file is actually 192 kb/s, duration 00:02:27.40, as shown below:

Old ffmpeg on FreeBSD box (hence the regression)

(unfortunately I don't have root on our servers, so I cannot test various builds on BSD)

>ffmpeg -v 9 -i duration-problem.mp3
FFmpeg version 0.5.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-swscale --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-memalign-hack --cc=cc --extra-cflags=-I/usr/local/include/vorbis -I/usr/local/include --extra-ldflags=-L/usr/local/lib  --extra-libs=-pthread --disable-debug --disable-mmx --enable-libamr-nb --enable-nonfree --enable-libamr-wb --enable-nonfree --disable-libdirac --disable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --disable-vhook --disable-ipv6 --enable-libmp3lame --disable-libopenjpeg --enable-libschroedinger --disable-ffplay --disable-libspeex --enable-libtheora --enable-libvorbis --disable-x11grab --enable-libx264 --disable-libxvid
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar 11 2010 14:16:57, gcc: 4.2.1 20070719  [FreeBSD]
Input #0, mp3, from 'duration-problem.mp3':
  Duration: 00:02:27.40, start: 0.000000, bitrate: 192 kb/s
    Stream #0.0, 1/90000: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
At least one output file must be specified

My guess is that this is related to https://roundup.libav.org/issue1954 (at least the build that introduces the problem is the same)

You can find the original file at http://usr.bandzone.cz/test/mp3/duration-problem.mp3 (~3.5MB)
I can provide much more files that are affected, if needed.

When I cut and/or recode the file, ie.

ffmpeg -i duration-problem.mp3 -acodec copy -t 5 ffmpeg-copy.mp3

and

ffmpeg -i duration-problem.mp3 -acodec libmp3lame -aq 2 -t 5 ffmpeg-recode.mp3

everything gets guessed alright, for lengths up to the original file.

Interesting thing to note, when I cut and/or recode the file with recent libav build, ffmpeg produces this bug again (and so does libav). I used the same commands as above, but with the libav binary. I'm attaching these files as well as ffmpeg output, the duration reported should be 5 seconds:

>ffmpeg -v 9 -loglevel 99 -i libav-copy.mp3
ffmpeg version git-N-30698-g39dbe9b, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 10 2011 22:10:00 with gcc 4.5.3
  configuration: --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --disable-outdev=sdl --pkg-config=pkg-config
  libavutil    51.  8. 0 / 51.  8. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  3. 0 / 53.  3. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[NULL @ 002FA160] Format mp3 probed with size=2048 and score=51
[mp3 @ 002FA160] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'libav-copy.mp3':
  Metadata:
    encoder         : Lavf53.2.0
  Duration: 00:00:26.28, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0, 192, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16, 32 kb/s
At least one output file must be specified
>ffmpeg -v 9 -loglevel 99 -i libav-recode.mp3
ffmpeg version git-N-30698-g39dbe9b, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 10 2011 22:10:00 with gcc 4.5.3
  configuration: --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --disable-outdev=sdl --pkg-config=pkg-config
  libavutil    51.  8. 0 / 51.  8. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  3. 0 / 53.  3. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 15. 0 /  2. 15. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[NULL @ 002DA160] Format mp3 probed with size=2048 and score=51
[mp3 @ 002DA160] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'libav-recode.mp3':
  Metadata:
    encoder         : Lavf53.2.0
  Duration: 00:00:27.37, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0, 193, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16, 32 kb/s
At least one output file must be specified

Attachments (2)

libav-copy.mp3 (102.7 KB ) - added by hjr 13 years ago.
libav-copy.mp3
libav-recode.mp3 (106.9 KB ) - added by hjr 13 years ago.
libav-recode.mp3

Download all attachments as: .zip

Change History (6)

by hjr, 13 years ago

Attachment: libav-copy.mp3 added

libav-copy.mp3

by hjr, 13 years ago

Attachment: libav-recode.mp3 added

libav-recode.mp3

comment:1 by Carl Eugen Hoyos, 13 years ago

Reproduced by developer: set
Status: newopen
Version: gitgit-master

I cannot reproduce any problems when re-muxing, but the original problem is a regression since r19300

$ ffmpeg -analyzeduration 1000000000 -i duration-problem.mp3
ffmpeg version N-30884-g54dd50d, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 20 2011 23:38:45 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  4. 0 / 53.  4. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    0. 14. 1 /  0. 14. 1
[mp3 @ 0x126b6e0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'duration-problem.mp3':
  Metadata:
    encoder         : Lavf52.39.2
  Duration: 00:14:44.44, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 32 kb/s
At least one output file must be specified
$ ffmpeg -i duration-problem.mp3
FFmpeg version git-2073fc8, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.32. 0 / 52.32. 0
  libavformat   52.36. 0 / 52.36. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1
  built on Jun 20 2011 23:27:14, gcc: 4.5.3
Input #0, mp3, from 'duration-problem.mp3':
  Duration: 00:02:27.40, start: 0.000000, bitrate: 192 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, 2 channels, s16, 192 kb/s
At least one output file must be specified

comment:2 by hjr, 13 years ago

With the recent build, on files remuxed by ffmpeg the duration is probed right, on files remuxed by libav (uploaded ones) the duration is probed wrong - just to clear any confusion here.

Versions between r19300 and recent fail on original file:

hujer@sid ~/> ffmpeg -analyzeduration 1000000000 -i duration-problem.mp3
FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
  built on Apr  8 2011 11:07:57 with gcc 4.2.1 20070719  [FreeBSD]
  configuration: --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-memalign-hack --cc=cc --extra-cflags=-msse -I/usr/local/include/vorbis -I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-pthread --disable-debug --enable-runtime-cpudetect --disable-indev=alsa --disable-outdev=alsa --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libdirac --disable-libfaac --enable-libfaad --enable-libfaadbin --disable-ffserver --enable-libgsm --enable-libmp3lame --disable-libopenjpeg --enable-libschroedinger --disable-ffplay --enable-libspeex --disable-libtheora --disable-vaapi --disable-vdpau --enable-libvorbis --disable-libvpx --disable-libx264 --disable-libxvid
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[mp3 @ 0x80311c010]Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'duration-problem.mp3':
  Metadata:
    TSSE            : Lavf52.39.2
  Duration: 00:14:44.44, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, 2 channels, s16, 32 kb/s
At least one output file must be specified

as well as on remuxed files:

$ ffmpeg -v 9 -loglevel 99 -i duration-problem.mp3 -acodec copy -t 5 ffmpeg-0.6.1-copy.mp3
FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
  built on Apr  8 2011 11:07:57 with gcc 4.2.1 20070719  [FreeBSD]
  configuration: --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-memalign-hack --cc=cc --extra-cflags=-msse -I/usr/local/include/vorbis -I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-pthread --disable-debug --enable-runtime-cpudetect --disable-indev=alsa --disable-outdev=alsa --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libdirac --disable-libfaac --enable-libfaad --enable-libfaadbin --disable-ffserver --enable-libgsm --enable-libmp3lame --disable-libopenjpeg --enable-libschroedinger --disable-ffplay --enable-libspeex --disable-libtheora --disable-vaapi --disable-vdpau --enable-libvorbis --disable-libvpx --disable-libx264 --disable-libxvid
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[NULL @ 0x80311b010]Probed with size=2048 and score=51
[mp3 @ 0x80311b010]max_analyze_duration reached
[mp3 @ 0x80311b010]Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'duration-problem.mp3':
  Metadata:
    TSSE            : Lavf52.39.2
  Duration: 00:14:44.44, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0, 194, 1/14112000: Audio: mp3, 44100 Hz, 2 channels, s16, 32 kb/s
Output #0, mp3, to 'ffmpeg-0.6.1-copy.mp3':
  Metadata:
    TSSE            : Lavf52.64.2
    Stream #0.0, 0, 1/90000: Audio: libmp3lame, 44100 Hz, 2 channels, 32 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
size=     103kB time=5.02 bitrate= 167.7kbits/s
video:0kB audio:103kB global headers:0kB muxing overhead 0.031396%
$ ffmpeg -v 9 -loglevel 99 -i ffmpeg-0.6.1-copy.mp3
FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
  built on Apr  8 2011 11:07:57 with gcc 4.2.1 20070719  [FreeBSD]
  configuration: --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-memalign-hack --cc=cc --extra-cflags=-msse -I/usr/local/include/vorbis -I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-pthread --disable-debug --enable-runtime-cpudetect --disable-indev=alsa --disable-outdev=alsa --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libdirac --disable-libfaac --enable-libfaad --enable-libfaadbin --disable-ffserver --enable-libgsm --enable-libmp3lame --disable-libopenjpeg --enable-libschroedinger --disable-ffplay --enable-libspeex --disable-libtheora --disable-vaapi --disable-vdpau --enable-libvorbis --disable-libvpx --disable-libx264 --disable-libxvid
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[NULL @ 0x80311b010]Probed with size=2048 and score=51
[mp3 @ 0x80311b010]Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'ffmpeg-0.6.1-copy.mp3':
  Metadata:
    TSSE            : Lavf52.64.2
  Duration: 00:00:26.28, start: 0.000000, bitrate: 32 kb/s
    Stream #0.0, 192, 1/14112000: Audio: mp3, 44100 Hz, 2 channels, s16, 32 kb/s
At least one output file must be specified

Maybe there are two separate issues? Because half of the problem seems to be fixed in git-master.

Before r19300, probing is fine, remuxing and probing is fine.
After r19300, probing is wrong, remuxing and probing is wrong.
After r_half_fix (git-master), probing is wrong, remuxing and probing is fine.

where r_half_fix > the_fork, otherwise libav would behave as ffmpeg git-master, which it does not.

Last edited 13 years ago by hjr (previous) (diff)

comment:3 by Michael Niedermayer, 13 years ago

Resolution: fixed
Status: openclosed

more or less fixed locally

comment:4 by Carl Eugen Hoyos, 11 years ago

Keywords: roundup added
Note: See TracTickets for help on using tickets.