[FFmpeg-trac] #9536(ffprobe:new): ffprobe is unable to parse certain mp3 files

FFmpeg trac at avcodec.org
Sat Nov 27 21:54:57 EET 2021


#9536: ffprobe is unable to parse certain mp3 files
---------------------------------+---------------------------------------
             Reporter:  vlad312  |                     Type:  defect
               Status:  new      |                 Priority:  normal
            Component:  ffprobe  |                  Version:  unspecified
             Keywords:           |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+---------------------------------------
 * What I was trying to accomplish:
 I'm trying to accurately determine the bitrate and duration of the MP3
 file by using ffprobe
 to output information about each audio packet (namely, pts_time,
 duration_time and size),
 and then using this information to determine file's duration and bitrate.

 Namely, file's duration is determined as pts_time+duration_time from the
 last packet,
 and file's bitrate is determined as 8*(sum of sizes of all packets)/file's
 duration.

 * The problem I encountered:

 ffprobe was unable to parse all packets of the MP3 file, resulting in the
 wrong value of the duration and bitrate.

 * The exact command line I was using
 The command line I'm using looks like this:

 ffprobe -v error -select_streams a:0 -show_entries
 packet=pts_time,duration_time,size -of compact
 ffprobe_packet_parsing_bug.mp3

 It outputs only 53 packets. Total size of the packets is 107760 bytes, the
 last packet looks like:
 packet|pts_time=0.277333|duration_time=0.003291|size=1264

 so the duration is 0.277333 + 0.003291 = 0.280624
 and the bitrate is 8 * 107760 / 0.280624 = 3072011

 When I'm using another approach like this:

 ffprobe -v error -select_streams a:0 -show_entries
 stream=duration,bit_rate -of default=noprint_wrappers=1
 ffprobe_packet_parsing_bug.mp3

 I'm also getting the wrong values:
 duration=0.180625
 bit_rate=3072000

 The reported duration is wrong, as the file can be played e.g. in vlc and
 I'm getting the duration of about 536 seconds (08:56).
 The reported bit_rate is also wrong, because the MP3 cannot have a bitrate
 greater than 320000.

 I've processed a large amount of MP3 files and this approach generally
 works very well. However, I've encountered a few files for which I'm
 clearly getting the wrong result about the duration and bitrate, which
 looks like a bug in ffprobe. It seems that ffmpeg is also unable to
 properly parse this file.

 * The full, uncut console output provided by ffmpeg -v 9 -loglevel 99 -i
 ffprobe_packet_parsing_bug.mp3

 ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
   built with gcc 11 (Debian 11.2.0-12)
   configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg
 --disable-gnutls --disable-liblensfun --disable-libopencv --disable-
 podpages --disable-sndio --disable-stripping --enable-avfilter --enable-
 gcrypt --enable-gpl --enable-ladspa --enable-libaom --enable-libaribb24
 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
 --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2
 --enable-libdc1394 --enable-libfdk-aac --enable-libflite --enable-
 libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme
 --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libkvazaar
 --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb
 --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg
 --enable-libopenmpt --enable-libopus --enable-libpulse --enable-
 librabbitmq --enable-librist --enable-librsvg --enable-librubberband
 --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex
 --enable-libsrt --enable-libtesseract --enable-libtheora --enable-
 libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwebp --enable-libwebp --enable-libx265
 --enable-libxavs2 --enable-libxml2 --enable-libxvid --enable-libzimg
 --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-
 omx --enable-openal --enable-opencl --enable-opengl --enable-openssl
 --enable-postproc --enable-pthreads --enable-shared --enable-version3
 --enable-vulkan --incdir=/usr/include/x86_64-linux-gnu
 --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --toolchain=hardened
 --enable-frei0r --enable-chromaprint --enable-libx264 --enable-vaapi
 --enable-libmfx --enable-libvmaf --enable-libsvtav1 --enable-libilbc
 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.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 url with argument
 '/tmp/ffprobe_packet_parsing_bug.mp3'.
 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 url /tmp/ffprobe_packet_parsing_bug.mp3.
 Successfully parsed a group of options.
 Opening an input file: /tmp/ffprobe_packet_parsing_bug.mp3.
 [NULL @ 0x55e53e7ba800] Opening '/tmp/ffprobe_packet_parsing_bug.mp3' for
 reading
 [file @ 0x55e53e7bb4c0] Setting default whitelist 'file,crypto,data'
 Probing mp3 score:1 size:647
 Probing mp3 score:1 size:2695
 Probing libopenmpt score:76 size:2695
 [libopenmpt @ 0x55e53e7ba800] Format libopenmpt probed with size=4096 and
 score=76
 id3v2 ver:3 flags:00 len:1391
 [libopenmpt @ 0x55e53e7ba800] Discarding ID3 tags because more suitable
 tags were found.
 [libopenmpt @ 0x55e53e7ba800] Before avformat_find_stream_info() pos:
 21425453 bytes read:21425453 seeks:0 nb_streams:1
 [libopenmpt @ 0x55e53e7ba800] All info found
 [libopenmpt @ 0x55e53e7ba800] stream 0: start_time: NOPTS duration:
 0.180625
 [libopenmpt @ 0x55e53e7ba800] format: start_time: NOPTS duration: 0.180625
 (estimate from stream) bitrate=948947 kb/s
 [libopenmpt @ 0x55e53e7ba800] After avformat_find_stream_info() pos:
 21425453 bytes read:21425453 seeks:0 frames:50
 Guessed Channel Layout for Input Stream #0.0 : stereo
 Input #0, libopenmpt, from '/tmp/ffprobe_packet_parsing_bug.mp3':
   Metadata:
     title           : ÿûàd ?ð  i
     encoder         : Generic MOD-compatible Tracker
     comment         :     ¤      4€   LAME3.
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
                     :
   Duration: 00:00:00.18, bitrate: 948947 kb/s
   Stream #0:0, 50, 1/1000000: Audio: pcm_f32le, 48000 Hz, stereo, flt,
 3072 kb/s
 Successfully opened the file.
 At least one output file must be specified
 [AVIOContext @ 0x55e53e7c3840] Statistics: 21425453 bytes read, 0 seeks

 * Sufficient information, including any required input files, to reproduce
 the bug and confirm a potential fix.

 I'm going to upload the file "ffprobe_packet_parsing_bug.mp3" to ​the
 VideoLAN File Uploader (file size is 21425453 bytes, md5 is
 452c0dabf3398fc64fb2588ce3a513d3).
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9536>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list