Opened 9 months ago
Last modified 9 months ago
#10942 new defect
Transcoding to mp2 within an mp4 container will be recognized as mp3
Reported by: | Olaf Ahrens | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | ffmpeg |
Version: | git-master | Keywords: | mp4 mp2 |
Cc: | Olaf Ahrens | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
When transcoding to an mp4 container with mp2 audio codec, the audio codec is marked non-conclusively. This results in ffmpeg itself incorrectly recognizing the audio codec in the transcoded video as mp3, while other programs recognize it as the intended mp2:
ffmpeg -i TargetAsMp4.mp4
[...]Stream #0:1[...]Audio: mp3 (mp3float) (mp4a / 0x6134706D)[...]
Mediainfo
Format - MPEG audio Format version - Version 1 Format profile - Layer 2 Codec ID - mp4a-6b
VLC Media Player
Codec - MPEG Audio layer 1/2 (mpga)
However, if another container format is used, for example mkv, the audio codec will be recognized correctly by all programs:
ffmpeg -i TargetAsMkv.mkv
[...]Stream #0:1[...]Audio: mp2[...]
Mediainfo
Format - MPEG audio Format version - Version 1 Format profile - layer 2 Codec ID - A_MPEG/L2 Codec ID/hint - MP2
VLC Media Player
Codec - MPEG Audio layer 1/2 (mpga)
What is noticeable is the audio codec ID 0x6134706D shown within the mp4 container, which as far as I know is associated with the aac codec, but neither with mp2 nor with mp3.
How to reproduce:
% ffmpeg -i Source.mp4 -c:v h264 -c:a mp2 TargetAsMp4.mp4 ffmpeg version 2024-03-28-git-5d71f97e0e-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 10.100 / 59. 10.100 libavcodec 61. 4.100 / 61. 4.100 libavformat 61. 2.100 / 61. 2.100 libavdevice 61. 2.100 / 61. 2.100 libavfilter 10. 2.100 / 10. 2.100 libswscale 8. 2.100 / 8. 2.100 libswresample 5. 2.100 / 5. 2.100 libpostproc 58. 2.100 / 58. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Source.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 2024-03-30T09:24:24.000000Z encoder : Lavf60.23.100 Duration: 00:00:05.75, start: 0.000000, bitrate: 1531 kb/s Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 720x406 [SAR 406:405 DAR 16:9], 1373 kb/s, 30 fps, 30 tbr, 15360 tbn (default) Metadata: creation_time : 2024-03-30T09:24:24.000000Z handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc60.41.100 libx264 Stream #0:1[0x2](eng): Audio: mp3 (mp3float) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 160 kb/s (default) Metadata: creation_time : 2024-03-30T09:24:24.000000Z handler_name : SoundHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (mp3 (mp3float) -> mp2 (native)) Press [q] to stop, [?] for help [libx264 @ 000002ae3902bc00] using SAR=406/405 [libx264 @ 000002ae3902bc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 000002ae3902bc00] profile High, level 3.0, 4:2:0, 8-bit [libx264 @ 000002ae3902bc00] 264 - core 164 r3190 7ed753b - H.264/MPEG-4 AVC codec - Copyleft 2003-2024 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=13 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'TargetAsMp4.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf61.2.100 Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 720x406 [SAR 406:405 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default) Metadata: creation_time : 2024-03-30T09:24:24.000000Z handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc61.4.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A Stream #0:1(eng): Audio: mp2 (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 384 kb/s (default) Metadata: creation_time : 2024-03-30T09:24:24.000000Z handler_name : SoundHandler vendor_id : [0][0][0][0] encoder : Lavc61.4.100 mp2 [out#0/mp4 @ 000002ae39007cc0] video:819KiB audio:271KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.608235% frame= 171 fps= 81 q=-1.0 Lsize= 1097KiB time=00:00:05.63 bitrate=1594.7kbits/s speed=2.66x [libx264 @ 000002ae3902bc00] frame I:1 Avg QP:24.65 size: 83042 [libx264 @ 000002ae3902bc00] frame P:43 Avg QP:25.31 size: 14442 [libx264 @ 000002ae3902bc00] frame B:127 Avg QP:30.79 size: 1058 [libx264 @ 000002ae3902bc00] consecutive B-frames: 0.6% 0.0% 3.5% 95.9% [libx264 @ 000002ae3902bc00] mb I I16..4: 0.7% 5.3% 94.0% [libx264 @ 000002ae3902bc00] mb P I16..4: 0.1% 0.4% 0.6% P16..4: 56.6% 17.3% 18.2% 0.0% 0.0% skip: 6.9% [libx264 @ 000002ae3902bc00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 49.2% 4.7% 1.0% direct: 0.7% skip:44.4% L0:44.2% L1:46.1% BI: 9.7% [libx264 @ 000002ae3902bc00] 8x8 transform intra:14.8% inter:28.0% [libx264 @ 000002ae3902bc00] coded y,uvDC,uvAC intra: 88.1% 96.4% 80.8% inter: 16.1% 12.5% 2.9% [libx264 @ 000002ae3902bc00] i16 v,h,dc,p: 43% 10% 38% 9% [libx264 @ 000002ae3902bc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 15% 18% 3% 4% 4% 4% 4% 10% [libx264 @ 000002ae3902bc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 19% 11% 7% 7% 7% 8% 7% 13% [libx264 @ 000002ae3902bc00] i8c dc,h,v,p: 44% 25% 19% 12% [libx264 @ 000002ae3902bc00] Weighted P-Frames: Y:9.3% UV:0.0% [libx264 @ 000002ae3902bc00] ref P L0: 59.9% 19.3% 7.2% 12.6% 1.1% [libx264 @ 000002ae3902bc00] ref B L0: 78.0% 19.7% 2.3% [libx264 @ 000002ae3902bc00] ref B L1: 84.1% 15.9% [libx264 @ 000002ae3902bc00] kb/s:1176.68 ffmpeg version 2024-03-28-git-5d71f97e0e-full_build-www.gyan.dev built for Windows 7 ff
OS on which the tests were run: Windows 11 Pro Version 10.0.22631 Build 22631
Attachments (3)
Change History (6)
by , 9 months ago
Attachment: | Source.mp4 added |
---|
by , 9 months ago
Attachment: | TargetAsMp4.mp4 added |
---|
target video: container mp4, codecs h264 and mp2
by , 9 months ago
Attachment: | TargetAsMkv.mkv added |
---|
target video: container mkv, codecs h264 and mp2
comment:1 by , 9 months ago
Cc: | added |
---|---|
Component: | undetermined → ffmpeg |
Description: | modified (diff) |
Version: | unspecified → git-master |
comment:2 by , 9 months ago
Description: | modified (diff) |
---|
comment:3 by , 9 months ago
It's a known issue, and caused by the specification since it defined the same config for MP2 and MP3. So with an mp4 container, we don't know whether it's MP2 or MP3 until decoding.
source video