ffmpeg icon indicating copy to clipboard operation
ffmpeg copied to clipboard

libfdk_aac profile aac_he_v2 doesn't work on the latest alpine320 images

Open unext-wendong opened this issue 11 months ago • 3 comments

The aac_he_v2 profile of encoder libfdk_aac doesn't seem to work in all alpine320 images, while the same command works on alpine313.

Images that don't work:

6.1-alpine320
7.0.2-alpine320
7.1-alpine320

Images that work:

5.1.6-alpine313
7.0.2-alpine313

Command:

docker run --rm -it \
    -v /path/to/data:/data \
    jrottenberg/ffmpeg:<tag> \
    -y -progress -nostats \
    -i /data/input.mp4 \
    -vn -acodec libfdk_aac -profile:a aac_he_v2 -b:a 64k /data/output_audio_aach.mp4

For the alpine320 images, they all show the following error:

[libfdk_aac @ 0x7fda7689e940] Unable to set the AOT 29: Invalid config
[aost#0:0/libfdk_aac @ 0x7fda768b2940] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.

unext-wendong avatar Mar 12 '25 10:03 unext-wendong

A full output from 7.1-alpine320:

# docker run --rm -it \
>     -v /root/tmp/ffmpeg-docker:/data \
>     jrottenberg/ffmpeg:7.1-alpine320 \
>     -y -progress -nostats \
>     -i /data/input.mp4 \
>     -vn -acodec libfdk_aac -profile:a aac_he_v2 -b:a 64k /data/output_audio_aach.mp4
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.1 (Alpine 13.2.1_git20240309) 20240309
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-fontconfig --enable-gpl --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libdav1d --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzmq --enable-nonfree --enable-openssl --enable-postproc --enable-shared --enable-small --enable-version3 --extra-cflags='-I/opt/ffmpeg/include -I/usr/include/x86_64-linux-gnu' --extra-ldflags='-L/opt/ffmpeg/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib' --extra-ldflags=-L/opt/ffmpeg/lib/x86_64-linux-gnu --extra-libs=-ldl --extra-libs=-lm --extra-libs=-lpthread --ld=g++ --prefix=/opt/ffmpeg
  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.3.100
  Duration: 00:00:32.07, start: 0.000000, bitrate: 4966 kb/s
  Stream #0:0[0x1](eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 4834 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : AVC Coding
  Stream #0:1[0x2](eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:1 -> #0:0 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[libfdk_aac @ 0x7fd86d051900] Unable to set the AOT 29: Invalid config
[aost#0:0/libfdk_aac @ 0x7fd8690ba900] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[af#0:0 @ 0x7fd86ad26f40] Error sending frames to consumers: Invalid argument
[af#0:0 @ 0x7fd86ad26f40] Task finished with error code: -22 (Invalid argument)
[af#0:0 @ 0x7fd86ad26f40] Terminating thread with return code -22 (Invalid argument)
[aost#0:0/libfdk_aac @ 0x7fd8690ba900] Could not open encoder before EOF
[aost#0:0/libfdk_aac @ 0x7fd8690ba900] Task finished with error code: -22 (Invalid argument)
[aost#0:0/libfdk_aac @ 0x7fd8690ba900] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 0x7fd86d16f640] Nothing was written into output file, because at least one of its streams received no packets.
size=       0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!

unext-wendong avatar Mar 12 '25 10:03 unext-wendong

Hi @jsheffie I believe this is related to the changes in https://github.com/jrottenberg/ffmpeg/pull/408. But since that PR was a huge and also a fundamental change, it's very difficult for me to tell exactly how it broke the feature.

Could you please help take a look and give some guidance?

@jrottenberg If you have any insights, any comments would be great. Thanks.

unext-wendong avatar Apr 09 '25 07:04 unext-wendong

(Ah, I sent my above comment too early)

After reading more of the new Dockerfile, I just realize it's actually quiet easy to understand. Other than the refactoring, one major difference with the previous alpine313 builds is that for many plugin libraries, it's switched from building from the source to using the alpine native packages.

With regards to this issue, it seems it's in the native library fdk-aac, since it doesn't reproduce after I switched to building libfdk-aac from the source.

With the new Dockerfile, it's quiet easy to make the switch. Just remove the installation of the alpine package fdk-aac and fdk-aac-dev and add the following:

RUN /tmp/workdir/generate-source-of-truth-ffmpeg-versions.py --library-list libfdk-aac
RUN /tmp/workdir/download_tarballs.sh
RUN /tmp/workdir/build_source.sh

unext-wendong avatar Apr 09 '25 09:04 unext-wendong