[FFmpeg-user] Creating video with xfade takes 27 GB of memory

Paul B Mahol onemda at gmail.com
Thu May 25 01:56:50 EEST 2023


On 5/25/23, Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
> I generate several videos in a similar way. I have only a problem with
> one.
> The command for the one with a problem is:
> time nice -n 10 ionice -c3 ffmpeg -y -ss 48 -t 4 -i langeLijn1c.mkv -ss 0
> -to 176 -i langeLijn1d.mkv -pix_fmt yuv420p -vcodec libx264 -crf 26 -acodec
> libmp3lame -qscale:a 9 -preset veryfast -filter_complex '
>     [0:v][1:v]
>                 xfade=transition=slideup:
>                 duration=4:
>                 offset=0
>                                                             [v01];
>     [0:a][1:a]
>                 acrossfade=d=4
>                                                             [a01];
>     [v01]
>                 drawtext=                   box        = 1:
>        boxborderw = 6:                         boxcolor   = black at 0.2:
>           fontcolor  = white at 0.4:                 fontfile   =
> FreeSerifBold.ttf:         fontsize   = 32:                        text
>  = © 2023 Cecil Westerhof - Cecil at Decebal.nl
> :             x          = ((main_w - text_w) / 2):   y          = main_h -
> (text_h * 2)
>                                                             [v02]' -map
> '[v02]' -map '[a01]' langeLijn1Temp/d.ts
>
>
> The output starts with:
> ffmpeg version 4.3.5-0+deb11u1 Copyright (c) 2000-2022 the FFmpeg developers
>   built with gcc 10 (Debian 10.2.1-6)
>   configuration: --prefix=/usr --extra-version=0+deb11u1
> --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-gnutls --enable-ladspa --enable-libaom --enable-libass
> --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
> --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg
> --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-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2
> --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx
> --enable-openal --enable-opencl --enable-opengl --enable-sdl2
> --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm
> --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264
> --enable-shared
>   WARNING: library configuration mismatch
>   avcodec     configuration: --prefix=/usr --extra-version=0+deb11u1
> --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-gnutls --enable-ladspa --enable-libaom --enable-libass
> --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
> --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg
> --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-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2
> --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx
> --enable-openal --enable-opencl --enable-opengl --enable-sdl2
> --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm
> --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264
> --enable-shared --enable-version3 --disable-doc --disable-programs
> --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb
> --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
>   libavutil      56. 51.100 / 56. 51.100
>   libavcodec     58. 91.100 / 58. 91.100
>   libavformat    58. 45.100 / 58. 45.100
>   libavdevice    58. 10.100 / 58. 10.100
>   libavfilter     7. 85.100 /  7. 85.100
>   libavresample   4.  0.  0 /  4.  0.  0
>   libswscale      5.  7.100 /  5.  7.100
>   libswresample   3.  7.100 /  3.  7.100
>   libpostproc    55.  7.100 / 55.  7.100
> Input #0, matroska,webm, from 'langeLijn1c.mkv':
>   Metadata:
>     ENCODER         : Lavf58.45.100
>   Duration: 00:00:52.05, start: 0.000000, bitrate: 20470 kb/s
>     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
> 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
>     Metadata:
>       DURATION        : 00:00:52.047000000
>     Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 117 kb/s (default)
>     Metadata:
>       DURATION        : 00:00:51.768000000
> Input #1, matroska,webm, from 'langeLijn1d.mkv':
>   Metadata:
>     ENCODER         : Lavf58.45.100
>   Duration: 00:03:00.93, start: 0.000000, bitrate: 22615 kb/s
>     Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
> 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
>     Metadata:
>       DURATION        : 00:03:00.927000000
>     Stream #1:1: Audio: mp3, 48000 Hz, stereo, fltp, 122 kb/s (default)
>     Metadata:
>       DURATION        : 00:03:00.624000000
> [Parsed_drawtext_2 @ 0x5645c1240580] Using
> "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf"
> Stream mapping:
>   Stream #0:0 (h264) -> xfade:main
>   Stream #0:1 (mp3float) -> acrossfade:crossfade0
>   Stream #1:0 (h264) -> xfade:xfade
>   Stream #1:1 (mp3float) -> acrossfade:crossfade1
>   drawtext -> Stream #0:0 (libx264)
>   acrossfade -> Stream #0:1 (libmp3lame)
> Press [q] to stop, [?] for help
> [Parsed_drawtext_2 @ 0x5645c1a96240] Using
> "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf"
> [libx264 @ 0x5645c1301100] using SAR=1/1
> [libx264 @ 0x5645c1301100] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX XOP FMA3 BMI1
> [libx264 @ 0x5645c1301100] profile High, level 4.0, 4:2:0, 8-bit
> Output #0, mpegts, to 'langeLijn1Temp/d.ts':
>   Metadata:
>     encoder         : Lavf58.45.100
>     Stream #0:0: Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1 DAR
> 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc (default)
>     Metadata:
>       encoder         : Lavc58.91.100 libx264
>     Side data:
>       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
>     Stream #0:1: Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp (default)
>     Metadata:
>       encoder         : Lavc58.91.100 libmp3lame
>
> I first thought that the following could be a/the problem:
>   WARNING: library configuration mismatch
>
> But I see this warning back in the logging of all the created videos,
> so that should not be a problem.
> On the other hand: why do I get this error and what can I do about it?
>
> After this I get:
> frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=    1 fps=0.7 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=    1 fps=0.5 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=    1 fps=0.4 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=    1 fps=0.3 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=   16 fps=4.4 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A
> speed=   0x
> frame=   25 fps=5.9 q=31.0 size=       0kB time=00:00:00.08 bitrate=
> 0.0kbits/s speed=0.019x
> frame=   33 fps=7.0 q=31.0 size=       0kB time=00:00:00.40 bitrate=
> 0.0kbits/s speed=0.0845x
> frame=   41 fps=7.8 q=31.0 size=       0kB time=00:00:00.72 bitrate=
> 0.0kbits/s speed=0.137x
> frame=   47 fps=8.2 q=31.0 size=       0kB time=00:00:00.96 bitrate=
> 0.0kbits/s speed=0.167x
> frame=   54 fps=8.5 q=31.0 size=       0kB time=00:00:01.24 bitrate=
> 0.0kbits/s speed=0.196x
> frame=   63 fps=9.2 q=31.0 size=       0kB time=00:00:01.60 bitrate=
> 0.0kbits/s speed=0.233x
> frame=   71 fps=9.6 q=31.0 size=       0kB time=00:00:01.92 bitrate=
> 0.0kbits/s speed=0.258x
> frame=   79 fps=9.8 q=31.0 size=       0kB time=00:00:02.24 bitrate=
> 0.0kbits/s speed=0.279x
> frame=   87 fps= 10 q=31.0 size=       0kB time=00:00:02.56 bitrate=
> 0.0kbits/s speed=0.296x
> frame=   95 fps= 10 q=31.0 size=       0kB time=00:00:02.88 bitrate=
> 0.0kbits/s speed=0.314x
> frame=  100 fps= 10 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.318x
> frame=  100 fps=9.8 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.302x
> frame=  100 fps=9.3 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.288x
> frame=  100 fps=8.9 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.275x
> frame=  100 fps=8.5 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.263x
> .
> .
> .
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.00543x
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.00542x
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.00542x
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.0054x
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.00538x
> frame=  100 fps=0.2 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.00501x
> frame=  102 fps=0.1 q=31.0 size=       0kB time=00:00:03.16 bitrate=
> 0.0kbits/s speed=0.00454x
> frame=  103 fps=0.1 q=31.0 size=       0kB time=00:00:03.20 bitrate=
> 0.0kbits/s speed=0.00458x
> frame=  104 fps=0.1 q=31.0 size=       0kB time=00:00:03.24 bitrate=
> 0.0kbits/s speed=0.00458x
> frame=  105 fps=0.1 q=31.0 size=       0kB time=00:00:03.28 bitrate=
> 0.0kbits/s speed=0.00457x
> frame=  106 fps=0.1 q=31.0 size=       0kB time=00:00:03.32 bitrate=
> 0.0kbits/s speed=0.00456x
> frame=  107 fps=0.1 q=31.0 size=       0kB time=00:00:03.36 bitrate=
> 0.0kbits/s speed=0.00457x
> frame=  108 fps=0.1 q=31.0 size=       0kB time=00:00:03.40 bitrate=
> 0.0kbits/s speed=0.00459x
> frame=  109 fps=0.1 q=31.0 size=       0kB time=00:00:03.44 bitrate=
> 0.0kbits/s speed=0.00463x
> frame=  110 fps=0.1 q=31.0 size=       0kB time=00:00:03.48 bitrate=
> 0.0kbits/s speed=0.00464x
> frame=  111 fps=0.1 q=31.0 size=       0kB time=00:00:03.52 bitrate=
> 0.0kbits/s speed=0.00465x
> frame=  112 fps=0.1 q=31.0 size=       0kB time=00:00:03.56 bitrate=
> 0.0kbits/s speed=0.00465x
> frame=  113 fps=0.1 q=28.0 size=       0kB time=00:00:03.60 bitrate=
> 0.0kbits/s speed=0.0047x
> .
> .
> .
> frame= 4373 fps=1.3 q=31.0 size=  395776kB time=00:02:54.80
> bitrate=18548.0kbits/s dup=0 drop=1 speed=0.0538x
> frame= 4375 fps=1.3 q=31.0 size=  395776kB time=00:02:54.88
> bitrate=18539.6kbits/s dup=0 drop=1 speed=0.0539x
> frame= 4376 fps=1.3 q=31.0 size=  396032kB time=00:02:54.92
> bitrate=18547.3kbits/s dup=0 drop=1 speed=0.0539x
> frame= 4378 fps=1.3 q=28.0 size=  396288kB time=00:02:55.00
> bitrate=18550.8kbits/s dup=0 drop=1 speed=0.0539x
> frame= 4379 fps=1.3 q=31.0 size=  396288kB time=00:02:55.04
> bitrate=18546.6kbits/s dup=0 drop=1 speed=0.0539x
> frame= 4380 fps=1.3 q=31.0 size=  396288kB time=00:02:55.08
> bitrate=18542.3kbits/s dup=0 drop=1 speed=0.0538x
> frame= 4381 fps=1.3 q=31.0 size=  396544kB time=00:02:55.12
> bitrate=18550.1kbits/s dup=0 drop=1 speed=0.0537x
> frame= 4381 fps=1.3 q=31.0 size=  396544kB time=00:02:55.12
> bitrate=18550.1kbits/s dup=0 drop=1 speed=0.0537x
> frame= 4381 fps=1.3 q=-1.0 Lsize=  426550kB time=00:02:55.92
> bitrate=19863.0kbits/s dup=0 drop=1 speed=0.0539x
> video:416366kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 2.446085%
> [libx264 @ 0x5645c1301100] frame I:101   Avg QP:28.88  size:265654
> [libx264 @ 0x5645c1301100] frame P:1360  Avg QP:31.23  size:146185
> [libx264 @ 0x5645c1301100] frame B:2920  Avg QP:33.38  size: 68738
> [libx264 @ 0x5645c1301100] consecutive B-frames:  6.3% 11.6%  8.1% 73.9%
> [libx264 @ 0x5645c1301100] mb I  I16..4:  1.7% 54.3% 44.0%
> [libx264 @ 0x5645c1301100] mb P  I16..4:  1.3% 27.1%  8.2%  P16..4: 28.2%
> 17.6% 15.5%  0.0%  0.0%    skip: 2.0%
> [libx264 @ 0x5645c1301100] mb B  I16..4:  0.4%  7.7%  1.1%  B16..8: 24.7%
> 15.8%  4.4%  direct:20.2%  skip:25.8%  L0:30.3% L1:29.9% BI:39.8%
> [libx264 @ 0x5645c1301100] 8x8 transform intra:74.7% inter:53.5%
> [libx264 @ 0x5645c1301100] coded y,uvDC,uvAC intra: 94.9% 47.5% 4.3% inter:
> 45.3% 6.0% 0.0%
> [libx264 @ 0x5645c1301100] i16 v,h,dc,p: 14% 19% 49% 18%
> [libx264 @ 0x5645c1301100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 11% 23%  4%
> 6% 10%  5%  7%  9%
> [libx264 @ 0x5645c1301100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 34% 15%  5%
> 5%  7%  5%  6%  7%
> [libx264 @ 0x5645c1301100] i8c dc,h,v,p: 56% 12% 24%  8%
> [libx264 @ 0x5645c1301100] Weighted P-Frames: Y:17.9% UV:7.9%
> [libx264 @ 0x5645c1301100] kb/s:19375.53
>
> The needed memory is about 27.5 GB
>
> But when I use:
> time nice -n 10 ionice -c3 ffmpeg -y -ss 48 -t 4 -i langeLijn1c.mkv -ss 0
> -to 16 -i langeLijn1d.mkv -pix_fmt yuv420p -vcodec libx264 -crf 26 -acodec
> libmp3lame -qscale:a 9 -preset veryfast -filter_complex '
>     [0:v][1:v]
>                 xfade=transition=slideup:
>                 duration=4:
>                 offset=0
>                                                             [v01];
>     [0:a][1:a]
>                 acrossfade=d=4
>                                                             [a01];
>     [v01]
>                 drawtext=                   box        = 1:
>        boxborderw = 6:                         boxcolor   = black at 0.2:
>           fontcolor  = white at 0.4:                 fontfile   =
> FreeSerifBold.ttf:         fontsize   = 32:                        text
>  = © 2023 Cecil Westerhof - Cecil at Decebal.nl
> :             x          = ((main_w - text_w) / 2):   y          = main_h -
> (text_h * 2)
>                                                             [v02]' -map
> '[v02]' -map '[a01]' langeLijn1OtherSlideTemp/d.ts
>
>
> I see the following in the log-file:
> frame=   97 fps= 15 q=31.0 size=       0kB time=00:00:02.96 bitrate=
> 0.0kbits/s speed=0.472x
> frame=  100 fps= 15 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.455x
> frame=  100 fps= 14 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.423x
> frame=  100 fps= 13 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.396x
> frame=  100 fps= 12 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.372x
> frame=  100 fps= 11 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.35x
> frame=  100 fps= 11 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.331x
> frame=  100 fps= 10 q=31.0 size=       0kB time=00:00:03.08 bitrate=
> 0.0kbits/s speed=0.314x
> frame=  109 fps= 10 q=31.0 size=       0kB time=00:00:03.44 bitrate=
> 0.0kbits/s speed=0.331x
> frame=  121 fps= 11 q=31.0 size=       0kB time=00:00:03.92 bitrate=
> 0.0kbits/s speed=0.36x
> frame=  131 fps= 11 q=31.0 size=       0kB time=00:00:04.32 bitrate=
> 0.0kbits/s speed=0.379x
>
> And the needed memory is about 2 GB.
> What could be happening here?
> What extra information should I give?
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


Use master FFmpeg version, where memory requirements for this filter
have been drastically reduced.


More information about the ffmpeg-user mailing list