Hello ffmpeg users, I’m having some trouble transcoding audio to mpeg2 aac. I’d like to know if someone could help me get the desired result or understand this issue more clearly.
After reading the ffmpeg document I thought setting the aac profile to mpeg2_aac_low would transcode audio into mpeg2 aac(https://ffmpeg.org/ffmpeg-all.html#Options-6 <https://ffmpeg.org/ffmpeg-all.html#Options-6>). I expected the id field(first bit after 3byte sync word) of the adts headers in the file to have value 1 instead of 0, which indicates whether it’s mpeg 2 or 4(https://wiki.multimedia.cx/index.php/ADTS <https://wiki.multimedia.cx/index.php/ADTS> - The bit represented as the letter B). And this goes the same with when setting the profile to mpeg2_aac_he. According to the source code(adtsenc.c) it seems like the bit is always written as cleared, so I doubt the possibility of getting the desired result but I want to know if 1. My expectation is based on a false assumption 2. My expectation is based on a valid assumption and 2.a It is a ffmpeg bug or should be fixed one day. 2.b Since mpeg2 is the superset of mpeg4 it really doesn’t matter these days because most decoders support mpeg4. 2.c There is a way in achieving the desired result with current version of ffmpeg 3. I am extracting the adts header incorrectly and everything must be carefully evaluated again Suppose the following is the command for the purpose of demonstrating the problem I am having. ffmpeg -y -i BigBuckBunny_320x180.mp4 -to 00:00:10 \ -map a:0 -c:a aac -profile:a mpeg2_aac_low -aac_pns 0 -b:a 128k -ar 48k \ mpeg2_aac_low.aac \ -map a:0 -c:a aac -profile:a mpeg2_aac_he -aac_pns 0 -b:a 128k -ar 48k \ mpeg2_aac_he.aac The attachments are the resulting output files and the following is the output that ffmpeg gives me. ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-gpl --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopus --enable-librsvg --enable-librtmp --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzmq --enable-opencl --enable-videotoolbox --enable-openssl --enable-libsrt --enable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'BigBuckBunny_320x180.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: mp41 creation_time : 1970-01-01T00:00:00.000000Z title : Big Buck Bunny artist : Blender Foundation composer : Blender Foundation date : 2008 encoder : Lavf52.14.0 Duration: 00:09:56.46, start: 0.000000, bitrate: 867 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x180 [SAR 1:1 DAR 16:9], 702 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : SoundHandler Stream mapping: Stream #0:1 -> #0:0 (aac (native) -> aac (native)) Stream #0:1 -> #1:0 (aac (native) -> aac (native)) Press [q] to stop, [?] for help Output #0, adts, to 'mpeg2_aac_low.aac': Metadata: major_brand : isom minor_version : 512 compatible_brands: mp41 date : 2008 title : Big Buck Bunny artist : Blender Foundation composer : Blender Foundation encoder : Lavf58.12.100 Stream #0:0(und): Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : SoundHandler encoder : Lavc58.18.100 aac Output #1, adts, to 'mpeg2_aac_he.aac': Metadata: major_brand : isom minor_version : 512 compatible_brands: mp41 date : 2008 title : Big Buck Bunny artist : Blender Foundation composer : Blender Foundation encoder : Lavf58.12.100 Stream #1:0(und): Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: creation_time : 1970-01-01T00:00:00.000000Z handler_name : SoundHandler encoder : Lavc58.18.100 aac size= 160kB time=00:09:56.24 bitrate= 2.2kbits/s speed= 106x video:0kB audio:9522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown [aac @ 0x7fe88e016000] Qavg: 149.111 [aac @ 0x7fe88e017800] Qavg: 156.998 Any related comments and clarification about the issue is welcomed. Thanks in advance. Yoon-Soo _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".