Opened 5 months ago

Last modified 3 weeks ago

#11061 reopened defect

FFmpeg hangs when using apad filter along with shortest flag

Reported by: Krzysztof Paliga Owned by: elenril
Priority: normal Component: ffmpeg
Version: git-master Keywords: audio filters pad
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Krzysztof Paliga)

Summary of the bug: When using the apad filter along with -shortest flag, the ffmpeg process keeps running without ever finishing.

Test file URL: https://bn-stream-e2e.b-cdn.net/hdr.mov

How to reproduce:

% ffmpeg -loglevel verbose -fflags +genpts -i hdr.mov -shortest -c:v copy -c:a aac -af apad,aresample=async=1:first_pts=0 -y tmpPaddingFix.mp4
ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
  configuration: --prefix=/usr --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --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-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-libdav1d --enable-libzimg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-frei0r --enable-libx264 --enable-shared --enable-nonfree --enable-version3 --enable-gpl --arch=x86_64 --extra-libs='-lpthread -lm' --extra-cflags='-Os -march=sandybridge -mtune=znver2'
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100

Verbose output:

[out#0/mp4 @ 0x5582bb8b2300] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x5582bb8ab680] EOF while reading input
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x5582bb8ab680] Terminating thread with return code 0 (success)
[aist#0:1/aac @ 0x5582bb9258c0] [dec:aac @ 0x5582bb8b1540] Decoder thread received EOF packet
[aist#0:1/aac @ 0x5582bb9258c0] [dec:aac @ 0x5582bb8b1540] Decoder returned EOF, finishing
[aist#0:1/aac @ 0x5582bb9258c0] [dec:aac @ 0x5582bb8b1540] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0x5582bb8b2300] Muxer returned EOF
[out#0/mp4 @ 0x5582bb8b2300] Terminating thread with return code 0 (success)

This workflow works perfectly on version 5.1.4 and 6.0.1. I looked at the changelog, but there are no mentions of apad changes, so I figured I file a bug report.

Change History (4)

comment:1 by Krzysztof Paliga, 5 months ago

Description: modified (diff)

comment:2 by elenril, 4 weeks ago

Owner: set to elenril
Status: newopen

comment:3 by elenril, 3 weeks ago

Resolution: fixed
Status: openclosed

comment:4 by steipal, 3 weeks ago

Resolution: fixed
Status: closedreopened

Using the latest master build from BtbN (https://github.com/BtbN/FFmpeg-Builds/releases/tag/latest Latest Auto-Build (2024-10-16 18:22)) it's still not fixed even with the patch commited 2 days ago. This will still hang:

ffmpeg.exe -t 5 -i "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" -af apad -shortest -f null -
ffmpeg version N-117491-gb989314c12 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
  configuration:  --disable-static --enable-shared --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++' --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-conversion --disable-autodetect --enable-amf --enable-bzlib --enable-cuda --enable-cuvid --enable-d3d12va --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-libaom --disable-debug --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libharfbuzz --enable-libvpl --enable-libmysofa --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid --enable-libopenmpt --enable-librav1e --enable-libsrt --enable-libgsm --enable-libvmaf --enable-libsvtav1 --enable-gnutls --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads --shlibdir=/local64/bin-video
  libavutil      59. 42.100 / 59. 42.100
  libavcodec     61. 22.100 / 61. 22.100
  libavformat    61.  9.100 / 61.  9.100
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  6.100 / 10.  6.100
  libswscale      8.  5.100 /  8.  5.100
  libswresample   5.  4.100 /  5.  4.100
  libpostproc    58.  4.100 / 58.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomavc1mp42
    creation_time   : 2010-05-17T15:28:46.000000Z
  Duration: 00:10:53.80, start: 0.000000, bitrate: 2075 kb/s
  Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2010-05-17T15:28:46.000000Z
      handler_name    : (C) 2007 Google Inc. v08.13.2007.
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1947 kb/s, 24 fps, 24 tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2010-05-17T15:28:46.000000Z
      handler_name    : (C) 2007 Google Inc. v08.13.2007.
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> wrapped_avframe (native))
  Stream #0:0 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomavc1mp42
    encoder         : Lavf61.9.100
  Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 24 tbn (default)
    Metadata:
      encoder         : Lavc61.22.100 wrapped_avframe
      creation_time   : 2010-05-17T15:28:46.000000Z
      handler_name    : (C) 2007 Google Inc. v08.13.2007.
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      encoder         : Lavc61.22.100 pcm_s16le
      creation_time   : 2010-05-17T15:28:46.000000Z
      handler_name    : (C) 2007 Google Inc. v08.13.2007.
      vendor_id       : [0][0][0][0]
[out#0/null @ 0000015b7ae92300] video:52KiB audio:861KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame=  120 fps= 58 q=-0.0 Lsize=N/A time=00:00:05.00 bitrate=N/A speed=2.42x
Exiting normally, received signal 2.

The problem seems to be in conjunction with "-t" input parameter. One will have to CTRL+C to abort.

Note: See TracTickets for help on using tickets.