Page MenuHomePhabricator

AV1 with film grain encoding causes ffmpeg crash due to memory leak
Open, Needs TriagePublicBUG REPORT

Description

See the source video: https://en.wikipedia.org/wiki/File:Dreyer_-_Jeanne_d%27Arcs_lidelse_og_d%C3%B8d.webm

I was able to get it to upload properly, and it plays back fine (original file streaming). It works in ffmpeg on my local computer, too (I actually encoded it using ffmpeg and then used mkvtoolnix to adjust).

The largest items refuse to encode because the estimated size is above the soft limit. That's not that unusual.

However, the smaller-sized files also fail to encode, with ffmpeg getting killed for some reason.

For many of the options, the ffmpeg encoder does not seem to get very far (getting somewhere between 600 to 800 frames in and then getting killed without writing over 1kB of video, returning exitcode 1):

ffmpeg-encode.sh

Exitcode: 1
Memory: 4294967296

+ export TMH_FFMPEG_PATH=/usr/bin/ffmpeg
+ TMH_FFMPEG_PATH=/usr/bin/ffmpeg
+ export TMH_FFMPEG_PASSES=2
+ TMH_FFMPEG_PASSES=2
+ export TMH_FFMPEG_THREADS=2
+ TMH_FFMPEG_THREADS=2
+ export TMH_FFMPEG2_OPTS TMH_MOVFLAGS TMH_OPTS_VIDEO TMH_REMUX TMH_OPT_SPEED TMH_OPT_VIDEOCODEC
+ export TMH_OPTS_AUDIO TMH_OPT_NOAUDIO
+ export TMH_OUTPUT_FILE
+ '[' 2 -lt 2 ']'
+ doFfmpegEncode 1
+ current_pass=1
+ '[' '!' -x /usr/bin/ffmpeg ']'
+ '[' ' -threads 8 -row-mt 1 -pix_fmt yuv420p -crf 33 -vcodec libvpx-vp9 -tile-columns 1 -quality good -f mp4 -g 240 -b:v 800000 -s 640x480' = -vn ']'
+ '[' 1 -eq 1 ']'
+ '[' yes = yes ']'
+ TMH_OPTS_AUDIO=-an
+ set --
+ PASS_OPTS=
+ '[' 1 -ne 0 ']'
+ set -- -pass 1 -passlogfile transcoded.mp4.log
+ '[' 1 -eq 1 ']'
+ set -- -pass 1 -passlogfile transcoded.mp4.log /dev/null
+ /usr/bin/ffmpeg -nostdin -y -i original.video -threads 8 -row-mt 1 -pix_fmt yuv420p -crf 33 -vcodec libvpx-vp9 -tile-columns 1 -quality good -f mp4 -g 240 -b:v 800000 -s 640x480 -an -movflags +faststart -movflags +frag_keyframe+empty_moov+default_base_moof -strict experimental -pass 1 -passlogfile transcoded.mp4.log /dev/null
ffmpeg version 4.1.11-0+deb10u1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[libaom-av1 @ 0x5650ad597700] v1.0.0
Input #0, matroska,webm, from 'original.video':
  Metadata:
    encoder         : libebml v1.4.5 + libmatroska v1.7.1
    creation_time   : 2024-02-10T04:54:17.000000Z
  Duration: 01:36:12.50, start: 0.000000, bitrate: 1597 kb/s
    Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1440x1080, SAR 1:1 DAR 4:3, 20 fps, 20 tbr, 1k tbn, 1k tbc (default)
[libaom-av1 @ 0x5650ad59be40] v1.0.0
Stream mapping:
  Stream #0:0 -> #0:0 (av1 (libaom-av1) -> vp9 (libvpx-vp9))
[libvpx-vp9 @ 0x5650ad5a5a80] v1.7.0
Output #0, mp4, to '/dev/null':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: vp9 (libvpx-vp9) (vp09 / 0x39307076), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 800 kb/s, 20 fps, 10240 tbn, 20 tbc (default)
    Metadata:
      encoder         : Lavc58.35.100 libvpx-vp9
    Side data:
      cpb: bitrate max/min/avg: 0/0/800000 buffer size: 0 vbv_delay: -1
frame=    5 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   14 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   22 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   31 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   38 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   46 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   54 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   62 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   69 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   78 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   85 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   93 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   99 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  107 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  115 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  125 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  132 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  141 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  149 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  158 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  164 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  172 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  180 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  187 fps= 15 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  195 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  203 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  211 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  219 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  227 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  235 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  243 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  251 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  259 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  267 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  275 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  283 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  291 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  299 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  307 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  315 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  323 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  331 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  339 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  347 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  355 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  363 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  371 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  379 fps= 14 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  387 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  395 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  403 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  411 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  419 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  427 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  435 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  443 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  451 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  459 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  467 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  474 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  480 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  483 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  491 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  499 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  507 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  515 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  523 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  531 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  539 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  547 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  555 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  563 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  571 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  579 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  587 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  595 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  603 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  611 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  619 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  627 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  635 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  643 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  651 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  659 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  667 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  675 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  683 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  691 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  700 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  707 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  715 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  722 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  726 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  731 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  738 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  743 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  749 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  755 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  761 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  767 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  771 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  777 fps= 13 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  783 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  787 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  793 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  799 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  804 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=  811 fps= 12 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
scripts/ffmpeg-encode.sh: line 16:     6 Killed                  "$TMH_FFMPEG_PATH" -nostdin -y -i original.video $TMH_OPTS_VIDEO $FFMPEG2_OPTS $TMH_OPTS_AUDIO $PASS_OPTS $TMH_MOVFLAGS "$@"
+ echo 'error running first-pass of ffmpeg encoding'
error running first-pass of ffmpeg encoding
+ exit 1

the MJPEG encode is uh, less unsuccessful? Well, it doesn't actually work, either. It also only gets to around 36 seconds (which is, in this case, 735 frames, since the original video is 20fps).But we at least report that we've written 3163kB of data, and we correctly report the time we're at, unlike with the other encodes, which seem to get stuck at time zero for some reason. Then we have exitcode 137 instead of 1.

ffmpeg-encode.sh

Exitcode: 137
Memory: 4294967296

+ export TMH_FFMPEG_PATH=/usr/bin/ffmpeg
+ TMH_FFMPEG_PATH=/usr/bin/ffmpeg
+ export TMH_FFMPEG_PASSES=0
+ TMH_FFMPEG_PASSES=0
+ export TMH_FFMPEG_THREADS=2
+ TMH_FFMPEG_THREADS=2
+ export TMH_FFMPEG2_OPTS TMH_MOVFLAGS TMH_OPTS_VIDEO TMH_REMUX TMH_OPT_SPEED TMH_OPT_VIDEOCODEC
+ export TMH_OPTS_AUDIO TMH_OPT_NOAUDIO
+ export TMH_OUTPUT_FILE
+ '[' 0 -lt 2 ']'
+ doFfmpegEncode
+ current_pass=0
+ '[' '!' -x /usr/bin/ffmpeg ']'
+ '[' ' -vcodec mjpeg -pix_fmt yuv420p -f mp4 -g 240 -b:v 800000 -s 176x144 -aspect 1440:1080' = -vn ']'
+ '[' 0 -eq 1 ']'
+ set --
+ PASS_OPTS=
+ '[' 0 -ne 0 ']'
+ '[' 0 -eq 1 ']'
+ set -- transcoded.mov
+ /usr/bin/ffmpeg -nostdin -y -i original.video -vcodec mjpeg -pix_fmt yuv420p -f mp4 -g 240 -b:v 800000 -s 176x144 -aspect 1440:1080 -acodec libvorbis -movflags +faststart -movflags +empty_moov+default_base_moof -frag_duration 10000000 -strict experimental transcoded.mov
ffmpeg version 4.1.11-0+deb10u1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[libaom-av1 @ 0x556b3e1c7480] v1.0.0
Input #0, matroska,webm, from 'original.video':
  Metadata:
    encoder         : libebml v1.4.5 + libmatroska v1.7.1
    creation_time   : 2024-02-10T04:54:17.000000Z
  Duration: 01:36:12.50, start: 0.000000, bitrate: 1597 kb/s
    Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1440x1080, SAR 1:1 DAR 4:3, 20 fps, 20 tbr, 1k tbn, 1k tbc (default)
[libaom-av1 @ 0x556b3e1cbc80] v1.0.0
Stream mapping:
  Stream #0:0 -> #0:0 (av1 (libaom-av1) -> mjpeg (native))
Output #0, mp4, to 'transcoded.mov':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: mjpeg (mp4v / 0x7634706D), yuv420p, 176x144 [SAR 12:11 DAR 4:3], q=2-31, 800 kb/s, 20 fps, 10240 tbn, 20 tbc (default)
    Metadata:
      encoder         : Lavc58.35.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/800000 buffer size: 0 vbv_delay: -1
frame=    8 fps=0.0 q=1.6 size=       1kB time=00:00:00.35 bitrate=  17.5kbits/s speed=0.696x    
frame=   19 fps= 18 q=1.6 size=       1kB time=00:00:00.90 bitrate=   6.8kbits/s speed=0.842x    
frame=   31 fps= 19 q=1.6 size=       1kB time=00:00:01.50 bitrate=   4.1kbits/s speed=0.902x    
frame=   40 fps= 18 q=1.6 size=       1kB time=00:00:01.95 bitrate=   3.1kbits/s speed=0.888x    
frame=   50 fps= 18 q=1.6 size=       1kB time=00:00:02.45 bitrate=   2.5kbits/s speed=0.904x    
frame=   59 fps= 18 q=1.6 size=       1kB time=00:00:02.90 bitrate=   2.1kbits/s speed=0.898x    
frame=   68 fps= 18 q=1.6 size=       1kB time=00:00:03.35 bitrate=   1.8kbits/s speed=0.898x    
frame=   79 fps= 18 q=1.6 size=       1kB time=00:00:03.90 bitrate=   1.6kbits/s speed=0.909x    
frame=   88 fps= 18 q=1.6 size=       1kB time=00:00:04.35 bitrate=   1.4kbits/s speed=0.906x    
frame=   99 fps= 18 q=1.6 size=       1kB time=00:00:04.90 bitrate=   1.2kbits/s speed=0.907x    
frame=  111 fps= 19 q=1.6 size=       1kB time=00:00:05.50 bitrate=   1.1kbits/s speed=0.919x    
frame=  122 fps= 19 q=1.6 size=       1kB time=00:00:06.05 bitrate=   1.0kbits/s speed=0.927x    
frame=  131 fps= 18 q=1.6 size=       1kB time=00:00:06.50 bitrate=   0.9kbits/s speed=0.909x    
frame=  143 fps= 19 q=1.6 size=       1kB time=00:00:07.10 bitrate=   0.9kbits/s speed=0.924x    
frame=  154 fps= 19 q=1.6 size=       1kB time=00:00:07.65 bitrate=   0.8kbits/s speed=0.933x    
frame=  163 fps= 18 q=1.6 size=       1kB time=00:00:08.10 bitrate=   0.8kbits/s speed=0.916x    
frame=  173 fps= 18 q=1.6 size=       1kB time=00:00:08.60 bitrate=   0.7kbits/s speed=0.919x    
frame=  184 fps= 19 q=1.6 size=       1kB time=00:00:09.15 bitrate=   0.7kbits/s speed=0.927x    
frame=  194 fps= 19 q=1.6 size=       1kB time=00:00:09.65 bitrate=   0.6kbits/s speed=0.93x    
frame=  199 fps= 18 q=1.6 size=       1kB time=00:00:09.90 bitrate=   0.6kbits/s speed=0.907x    
frame=  209 fps= 18 q=1.6 size=     686kB time=00:00:10.40 bitrate= 540.6kbits/s speed=0.906x    
frame=  215 fps= 18 q=1.6 size=     686kB time=00:00:10.70 bitrate= 525.5kbits/s speed=0.889x    
frame=  223 fps= 18 q=1.6 size=     686kB time=00:00:11.10 bitrate= 506.5kbits/s speed=0.884x    
frame=  231 fps= 18 q=1.6 size=     686kB time=00:00:11.50 bitrate= 488.9kbits/s speed=0.875x    
frame=  240 fps= 18 q=1.6 size=     686kB time=00:00:11.95 bitrate= 470.5kbits/s speed=0.876x    
frame=  246 fps= 17 q=1.6 size=     686kB time=00:00:12.25 bitrate= 459.0kbits/s speed=0.864x    
frame=  255 fps= 17 q=1.6 size=     686kB time=00:00:12.70 bitrate= 442.7kbits/s speed=0.863x    
frame=  263 fps= 17 q=1.6 size=     686kB time=00:00:13.10 bitrate= 429.2kbits/s speed=0.856x    
frame=  271 fps= 17 q=1.6 size=     686kB time=00:00:13.50 bitrate= 416.5kbits/s speed=0.853x    
frame=  276 fps= 17 q=1.6 size=     686kB time=00:00:13.75 bitrate= 408.9kbits/s speed=0.842x    
frame=  285 fps= 17 q=1.6 size=     686kB time=00:00:14.20 bitrate= 395.9kbits/s speed=0.841x    
frame=  292 fps= 17 q=1.9 size=     686kB time=00:00:14.55 bitrate= 386.4kbits/s speed=0.836x    
frame=  301 fps= 17 q=2.4 size=     686kB time=00:00:15.00 bitrate= 374.8kbits/s speed=0.837x    
frame=  309 fps= 17 q=2.5 size=     686kB time=00:00:15.40 bitrate= 365.1kbits/s speed=0.835x    
frame=  316 fps= 17 q=2.6 size=     686kB time=00:00:15.75 bitrate= 357.0kbits/s speed=0.831x    
frame=  323 fps= 17 q=2.8 size=     686kB time=00:00:16.10 bitrate= 349.2kbits/s speed=0.825x    
frame=  333 fps= 17 q=3.7 size=     686kB time=00:00:16.60 bitrate= 338.7kbits/s speed=0.828x    
frame=  339 fps= 16 q=4.2 size=     686kB time=00:00:16.90 bitrate= 332.7kbits/s speed=0.821x    
frame=  349 fps= 16 q=4.9 size=     686kB time=00:00:17.40 bitrate= 323.1kbits/s speed=0.822x    
frame=  357 fps= 16 q=5.1 size=     686kB time=00:00:17.80 bitrate= 315.9kbits/s speed=0.82x    
frame=  367 fps= 16 q=5.6 size=     686kB time=00:00:18.30 bitrate= 307.2kbits/s speed=0.822x    
frame=  372 fps= 16 q=6.2 size=     686kB time=00:00:18.55 bitrate= 303.1kbits/s speed=0.814x    
frame=  381 fps= 16 q=7.4 size=     686kB time=00:00:19.00 bitrate= 295.9kbits/s speed=0.816x    
frame=  390 fps= 16 q=7.9 size=     686kB time=00:00:19.45 bitrate= 289.1kbits/s speed=0.817x    
frame=  399 fps= 16 q=8.3 size=     686kB time=00:00:19.90 bitrate= 282.5kbits/s speed=0.818x    
frame=  404 fps= 16 q=8.0 size=    2222kB time=00:00:20.15 bitrate= 903.4kbits/s speed=0.811x    
frame=  413 fps= 16 q=8.4 size=    2222kB time=00:00:20.60 bitrate= 883.6kbits/s speed=0.812x    
frame=  420 fps= 16 q=9.3 size=    2222kB time=00:00:20.95 bitrate= 868.9kbits/s speed=0.81x    
frame=  427 fps= 16 q=9.9 size=    2222kB time=00:00:21.30 bitrate= 854.6kbits/s speed=0.808x    
frame=  435 fps= 16 q=10.5 size=    2222kB time=00:00:21.70 bitrate= 838.8kbits/s speed=0.802x    
frame=  443 fps= 16 q=10.2 size=    2222kB time=00:00:22.10 bitrate= 823.7kbits/s speed=0.802x    
frame=  451 fps= 16 q=9.5 size=    2222kB time=00:00:22.50 bitrate= 809.0kbits/s speed=0.798x    
frame=  459 fps= 16 q=10.4 size=    2222kB time=00:00:22.90 bitrate= 794.9kbits/s speed=0.798x    
frame=  467 fps= 16 q=11.2 size=    2222kB time=00:00:23.30 bitrate= 781.2kbits/s speed=0.797x    
frame=  475 fps= 16 q=11.3 size=    2222kB time=00:00:23.70 bitrate= 768.0kbits/s speed=0.796x    
frame=  483 fps= 16 q=10.3 size=    2222kB time=00:00:24.10 bitrate= 755.3kbits/s speed=0.788x    
frame=  491 fps= 16 q=10.5 size=    2222kB time=00:00:24.50 bitrate= 743.0kbits/s speed=0.788x    
frame=  499 fps= 16 q=11.3 size=    2222kB time=00:00:24.90 bitrate= 731.0kbits/s speed=0.786x    
frame=  507 fps= 16 q=11.4 size=    2222kB time=00:00:25.30 bitrate= 719.5kbits/s speed=0.786x    
frame=  515 fps= 16 q=10.6 size=    2222kB time=00:00:25.70 bitrate= 708.3kbits/s speed=0.78x    
frame=  523 fps= 16 q=9.8 size=    2222kB time=00:00:26.10 bitrate= 697.4kbits/s speed=0.779x    
frame=  531 fps= 16 q=9.6 size=    2222kB time=00:00:26.50 bitrate= 686.9kbits/s speed=0.778x    
frame=  540 fps= 16 q=10.4 size=    2222kB time=00:00:26.95 bitrate= 675.4kbits/s speed=0.779x    
frame=  547 fps= 15 q=10.4 size=    2222kB time=00:00:27.30 bitrate= 666.8kbits/s speed=0.773x    
frame=  555 fps= 15 q=10.1 size=    2222kB time=00:00:27.70 bitrate= 657.1kbits/s speed=0.773x    
frame=  563 fps= 15 q=9.1 size=    2222kB time=00:00:28.10 bitrate= 647.8kbits/s speed=0.772x    
frame=  573 fps= 15 q=8.8 size=    2222kB time=00:00:28.60 bitrate= 636.5kbits/s speed=0.773x    
frame=  579 fps= 15 q=9.3 size=    2222kB time=00:00:28.90 bitrate= 629.9kbits/s speed=0.768x    
frame=  589 fps= 15 q=9.6 size=    2222kB time=00:00:29.40 bitrate= 619.1kbits/s speed=0.771x    
frame=  599 fps= 15 q=9.4 size=    2222kB time=00:00:29.90 bitrate= 608.8kbits/s speed=0.773x    
frame=  607 fps= 15 q=8.3 size=    3163kB time=00:00:30.30 bitrate= 855.3kbits/s speed=0.773x    
frame=  615 fps= 15 q=8.2 size=    3163kB time=00:00:30.70 bitrate= 844.1kbits/s speed=0.772x    
frame=  625 fps= 16 q=8.5 size=    3163kB time=00:00:31.20 bitrate= 830.6kbits/s speed=0.774x    
frame=  634 fps= 16 q=8.7 size=    3163kB time=00:00:31.65 bitrate= 818.8kbits/s speed=0.776x    
frame=  643 fps= 15 q=8.7 size=    3163kB time=00:00:32.10 bitrate= 807.3kbits/s speed=0.772x    
frame=  652 fps= 15 q=8.6 size=    3163kB time=00:00:32.55 bitrate= 796.1kbits/s speed=0.774x    
frame=  662 fps= 16 q=8.7 size=    3163kB time=00:00:33.05 bitrate= 784.1kbits/s speed=0.776x    
frame=  671 fps= 16 q=8.5 size=    3163kB time=00:00:33.50 bitrate= 773.6kbits/s speed=0.777x    
frame=  677 fps= 16 q=8.5 size=    3163kB time=00:00:33.80 bitrate= 766.7kbits/s speed=0.775x    
frame=  687 fps= 16 q=8.5 size=    3163kB time=00:00:34.30 bitrate= 755.5kbits/s speed=0.778x    
frame=  699 fps= 16 q=8.5 size=    3163kB time=00:00:34.90 bitrate= 742.5kbits/s speed=0.781x    
frame=  709 fps= 16 q=8.6 size=    3163kB time=00:00:35.40 bitrate= 732.0kbits/s speed=0.783x    
frame=  719 fps= 16 q=8.5 size=    3163kB time=00:00:35.90 bitrate= 721.8kbits/s speed=0.785x    
frame=  725 fps= 16 q=6.7 size=    3163kB time=00:00:36.20 bitrate= 715.9kbits/s speed=0.782x    
frame=  735 fps= 16 q=3.8 size=    3163kB time=00:00:36.70 bitrate= 706.1kbits/s speed=0.783x    
scripts/ffmpeg-encode.sh: line 16:     6 Killed                  "$TMH_FFMPEG_PATH" -nostdin -y -i original.video $TMH_OPTS_VIDEO $FFMPEG2_OPTS $TMH_OPTS_AUDIO $PASS_OPTS $TMH_MOVFLAGS "$@"

Event Timeline

Hm, this could be an issue with the recent changes to the sandboxing of the ffmpeg process. @Joe can you take a peek? This input file is in av1 which may cause it to use more memory for decoding than other files, perhaps, could be tripping up something.

Don't know if it is AV1 that is causing the issue, but for comparison, https://commons.wikimedia.org/wiki/File:The_Kid_(1921).webm is also an AV1 file (actually, both a larger file overall and with almost 5 times the bitrate) and it transcoded just fine (uploaded on January 12).

So I also tried this locally yesterday, and that ffmpeg transcode wasn't successful either. I think I did spot that it uses a specific option: Film grain synthesis (unable to double check that right now).

Today, googling "AV1 ffmpeg memory leak", I ran into this: https://github.com/mpv-player/mpv/issues/7233
A report on MPV that AV1 video decoding there seemed to shows a severe (ffmpeg/libaom) memory leak on a video with film grain synthesis. Could be something to check.

Yes, the film grain features of AV1 were used in encoding. I had no issue using ffmpeg with this clip on my local machine; could this be an issue in an older version of ffmpeg deployed on WMF servers?

Another thing, though. While it's been deleted now, I uploaded some fragmentary test files from my stash while trying to work out my issues with chunked uploading (T357200). These were short AV1 clips, all with film grain synthesis enabled. The transcode worked properly in those cases. I can try uploading a test clip encoded using AV1 later.

I'll also ask, just in case: is there any difference between the server setups for enwiki and Commons on this issue? My test AV1+FGS uploads that transcoded were uploaded to Commons, while this file is only on English Wikipedia.

I had no issue using ffmpeg with this clip on my local machine; could this be an issue in an older version of ffmpeg deployed on WMF servers?

If I understand correctly, the pre-refactor renderings uses the version of ffmpeg that ships in Debian 12 (is this right?) which should be relatively recent but could easily contain buts in the av1 codec, which is under pretty active work. Whereas the new code runs go via shellbox and I do not know if they have the same host environment or not as the other servers.

is there any difference between the server setups for enwiki and Commons on this issue?

enwiki and commons are in different deployment groups; code that goes out with regular deployment will hit commons in group 1 before it hits enwiki in group 2. So occasionally you will see a difference in behavior between them, though I'm not sure if that applies here.

Uploaded a 1-minute test file (AV1 with FGS). Video transcodes all error out (on both enwiki and commons).

https://en.wikipedia.org/wiki/File:Test-dbm-cyrano-1m.webm
https://commons.wikimedia.org/wiki/File:Test-dbm-cyrano-1m-commons.webm

30-second test file (half of the same clip). Some of the transcodes actually work — up to 720P on enwiki and 480P on commons. (Ed.: Actually, 1080P worked on enwiki!)

https://en.wikipedia.org/wiki/File:Test-dbm-cyrano-30s.webm
https://commons.wikimedia.org/wiki/File:Test-dbm-cyrano-30s-commons.webm

Seems exit code is 137 when it's closer to working, and 1 when it's further.

Seems exit code is 137 when it's closer to working, and 1 when it's further.

137 is the code for out of memory. 1 for general failure of the process

Might the issue be related to which decoder ffmpeg uses for AV1 (libdav1d or libaom-av1)? I've been using libaom-av1 for decode in the build of ffmpeg I'm using locally.

Might the issue be related to which decoder ffmpeg uses for AV1 (libdav1d or libaom-av1)? I've been using libaom-av1 for decode in the build of ffmpeg I'm using locally.

From the logs in the description, we can see that it uses libaom-av1 (version v1.0.0, but apparently there were lots of patch versions/builds of this library released which we cannot distinguish from this log info). We will have to check the kubernetes container definition to figure out what exact version it is using.

Do we know if this errors in the decoding, or in the encoding ? For decoding we could maybe switch to dav1d as a decoder. If it's in the encoding, where it uses grain encoding, simply because the input uses grain encoding, then maybe we can pass a flag to ffmpeg to disable grain encoding ?

ffmpeg version: 4.1.11 (released June 2023)
Debian bookworm should have 5.1.6

Debian does have libdav1d, but doesn't seem to include it in ffmpeg build ? https://packages.debian.org/search?searchon=sourcenames&keywords=dav1d

TheDJ renamed this task from ffmpeg getting killed during transcode to AV1 with film grain encoding causes ffmpeg crash due to memory leak.Thu, Jan 2, 2:44 PM

It can't be using grain synth in the output, because it is encoding VP9 (and some other non-AV1 codecs), which doesn't have a grain synthesis feature like AV1.