Opened 10 months ago

Last modified 10 months ago

#10488 reopened defect

mp3 file with wrong extension erroneusly treated as a video

Reported by: Paolo Benvenuto Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Paolo Benvenuto Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I have an mp3 file (Dichosos.mp3), which is correctly detected by ffmpeg. It has extension mp3. It's correctly detected even if I remove the file extension (Dichosos.).

$ ffmpeg -v 9 -loglevel 99 -i Dichosos
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  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 'Dichosos'.
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 Dichosos.
Successfully parsed a group of options.
Opening an input file: Dichosos.
[NULL @ 0x55afbcd22740] Opening 'Dichosos' for reading
[file @ 0x55afbcd233c0] Setting default whitelist 'file,crypto,data'
Probing mp3 score:25 size:2048
Probing mp3 score:51 size:4096
[mp3 @ 0x55afbcd22740] Format mp3 probed with size=4096 and score=51
[mp3 @ 0x55afbcd22740] Skipping 0 bytes of junk at 0.
[mp3 @ 0x55afbcd22740] Before avformat_find_stream_info() pos: 0 bytes read:65664 seeks:2 nb_streams:1
[mp3 @ 0x55afbcd22740] All info found
[mp3 @ 0x55afbcd22740] Estimating duration from bitrate, this may be inaccurate
[mp3 @ 0x55afbcd22740] stream 0: start_time: 0 duration: 121.32
[mp3 @ 0x55afbcd22740] format: start_time: 0 duration: 121.319 (estimate from bit rate) bitrate=128 kb/s
[mp3 @ 0x55afbcd22740] After avformat_find_stream_info() pos: 21504 bytes read:65664 seeks:2 frames:50
Input #0, mp3, from 'Dichosos':
  Duration: 00:02:01.32, start: 0.000000, bitrate: 128 kb/s
  Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Successfully opened the file.
At least one output file must be specified
[AVIOContext @ 0x55afbcd2b780] Statistics: 65664 bytes read, 2 seeks

However, if I change the extension to jpg, it's detected as a video:

$ ffmpeg -v 9 -loglevel 99 -i Dichosos.jpg 
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  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 'Dichosos.jpg'.
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 Dichosos.jpg.
Successfully parsed a group of options.
Opening an input file: Dichosos.jpg.
[NULL @ 0x564cfe81e740] Opening 'Dichosos.jpg' for reading
[file @ 0x564cfe81f3c0] Setting default whitelist 'file,crypto,data'
Probing image2 score:50 size:2048
Probing mp3 score:25 size:2048
[image2 @ 0x564cfe81e740] Format image2 probed with size=2048 and score=50
[image2 @ 0x564cfe81e740] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[mjpeg @ 0x564cfe8209c0] marker=fb avail_size_in_buf=1941110
[mjpeg @ 0x564cfe8209c0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x564cfe8209c0] marker=f3 avail_size_in_buf=1941017
[mjpeg @ 0x564cfe8209c0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x564cfe8209c0] marker=fc avail_size_in_buf=1940990
[mjpeg @ 0x564cfe8209c0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x564cfe8209c0] marker=d0 avail_size_in_buf=1940895
[mjpeg @ 0x564cfe8209c0] restart marker: 0
[mjpeg @ 0x564cfe8209c0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x564cfe8209c0] marker=fa avail_size_in_buf=1940872
[mjpeg @ 0x564cfe8209c0] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x564cfe8209c0] marker=f7 avail_size_in_buf=1940855
[mjpeg @ 0x564cfe8209c0] bits 223 is invalid
[image2 @ 0x564cfe81e740] decoding for stream 0 failed
[image2 @ 0x564cfe81e740] stream 0: start_time: 0 duration: 0.04
[image2 @ 0x564cfe81e740] format: start_time: 0 duration: 0.04 (estimate from stream) bitrate=388222 kb/s
[image2 @ 0x564cfe81e740] Could not find codec parameters for stream 0 (Video: mjpeg (JPEG LS), 1 reference frame, none(bt470bg/unknown/unknown, center), lossless): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[image2 @ 0x564cfe81e740] After avformat_find_stream_info() pos: 1941112 bytes read:1941112 seeks:0 frames:1
Input #0, image2, from 'Dichosos.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 388222 kb/s
  Stream #0:0, 1, 1/25: Video: mjpeg (JPEG LS), 1 reference frame, none(bt470bg/unknown/unknown, center), lossless, 25 fps, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
At least one output file must be specified
[AVIOContext @ 0x564cfe827780] Statistics: 1941112 bytes read, 0 seeks

Apparently there is something wrong in the scoring of images/mp3...

Change History (5)

comment:1 by Balling, 10 months ago

Resolution: invalid
Status: newclosed

Stop trolling. There is no way to fix that.

comment:2 by Elon Musk, 10 months ago

Resolution: invalid
Status: closedreopened

The mjpeg probe could be very improved.

comment:4 by Paolo Benvenuto, 10 months ago

If I undestand what Balling is saying, it's difficult to avoid considering a jpg as a video.

However, in the bug description, I explained that when no assumption is made on the media type (extensionless file), the mp3 is correctly detected.

This makes me think that if ffmpeg doesn't rely on the extension, it could produce better results.

comment:5 by Cigaes, 10 months ago

The core issue is that MP3 is a shitty format, and there is no way of detecting it reliably without either ① making a boatload of false positives or ② making the probing process much much slower.

So my advice is: name your MP3 files .mp3 rather than .jpg, because that is asking for trouble, and when you ask for trouble you find it.

Note: See TracTickets for help on using tickets.