Opened 3 years ago

Last modified 3 years ago

#9340 new defect

Insane RAM usage when copying hdmv_pgs subs with -forced_subs_only 1 and burning in subs with a complex filtergraph

Reported by: Michael Harmon Owned by:
Priority: important Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: When burning in hdmv pgs subs using -forced_subs_only 1, and trying to also copy those subtitles, memory usage expands to 5+ GB, sometimes stabilizing, and for certain videos, completely maxing out my 16GB of RAM and my SWAP and freezing my system. This only happens if I'm trying to copy those PGS subs. If i just burn-in/overlay and crop the video without copying the subs, it works fine, and when copying just the subs, without burning them in or using forced_subs_only 1 it works fine as well.

How to reproduce:
Take a video with multiple PGS subs, and video, burn in the forced subs only, and try and copy the cubtitle codec and tracks, notice the abnormally large memory usage. I used a bluray m2ts stream for this.

Here's the command I used that caused an issue:
ffmpeg -forced_subs_only 1 -i AQuietPlace -filter_complex "[0:v][0:s]overlay[overlay],[overlay]crop=1920:800:0:140[vid]" -map [vid] -map 0:a -map 0:s -c:s copy -c:v libx264 -crf 18 -c:a libvorbis -q:a 5 AQuietPlaceEncode.mkv

This also doesn't work:
ffmpeg -i AQuietPlace -filter_complex "[0:v][0:s:0]overlay[overlay],[overlay]crop=1920:800:0:140[vid]" -map [vid] -map 0:a -map 0:s -c:s copy -c:v libx264 -crf 18 -c:a libvorbis -q:a 5 AQuietPlaceEncode.mkv (Burning in just the first sub track, without caring if it's forced)

These ones work fine, but sacrifice either the burn-in or sub tracks:
ffmpeg -i AQuietPlace -forced_subs_only 1 -filter_complex "[0:v][0:s]overlay[overlay],[overlay]crop=1920:800:0:140[vid]" -map [vid] -map 0:a -c:v libx264 -crf 18 -c:a libvorbis -q:a 5 AQuietPlaceEncode.mkv (Burn in, but no sub tracks)

ffmpeg -i AQuietPlace -map 0:v -map 0:a -map 0:s -c:s copy -c:v libx264 -crf 18 -c:a libvorbis -q:a 5 AQuietPlaceEncode.mkv (Sub tracks but no burn in)

I've tried with multiple builds of ffmpeg, all with the same result.

Here's the top bit of the command output:
ffmpeg version n4.4 Copyright (c) 2000-2021 the FFmpeg developers

built with gcc 11.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-shared --enable-version3
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100

[mpegts @ 0x556876da47c0] start time for stream 7 is not set in estimate_timings_from_pts
[mpegts @ 0x556876da47c0] start time for stream 8 is not set in estimate_timings_from_pts
[mpegts @ 0x556876da47c0] start time for stream 9 is not set in estimate_timings_from_pts
[mpegts @ 0x556876da47c0] start time for stream 10 is not set in estimate_timings_from_pts
[mpegts @ 0x556876da47c0] start time for stream 11 is not set in estimate_timings_from_pts
[mpegts @ 0x556876da47c0] stream 0 : no PTS found at end of file, duration not set
[mpegts @ 0x556876da47c0] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x556876da47c0] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x556876da47c0] Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x556876da47c0] Could not find codec parameters for stream 10 (Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x556876da47c0] Could not find codec parameters for stream 11 (Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mpegts, from 'AQuietPlace':

Duration: 01:30:14.91, start: 11.650667, bitrate: 34771 kb/s
Program 1
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0:1[0x1100]: Audio: truehd (AC-3 / 0x332D4341), 48000 Hz, 7.1, s32 (24 bit)
Stream #0:2[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s
Stream #0:3[0x1101]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s
Stream #0:4[0x1102]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s
Stream #0:5[0x1103]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s
Stream #0:6[0x1104]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 640 kb/s
Stream #0:7[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
Stream #0:8[0x1201]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
Stream #0:9[0x1202]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
Stream #0:10[0x1203]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
Stream #0:11[0x1204]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)

File 'AQuietPlaceEncode2.mkv' already exists. Overwrite? [y/N] y
Stream mapping:

Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #0:7 (pgssub) -> overlay:overlay (graph 0)
crop (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (truehd (native) -> vorbis (libvorbis))
Stream #0:2 -> #0:2 (ac3 (native) -> vorbis (libvorbis))
Stream #0:3 -> #0:3 (ac3 (native) -> vorbis (libvorbis))
Stream #0:4 -> #0:4 (ac3 (native) -> vorbis (libvorbis))
Stream #0:5 -> #0:5 (ac3 (native) -> vorbis (libvorbis))
Stream #0:6 -> #0:6 (ac3 (native) -> vorbis (libvorbis))
Stream #0:7 -> #0:7 (copy)
Stream #0:8 -> #0:8 (copy)
Stream #0:9 -> #0:9 (copy)
Stream #0:10 -> #0:10 (copy)
Stream #0:11 -> #0:11 (copy)

Press [q] to stop, ? for help
[mpegts @ 0x556876da47c0] sub2video: using 1920x1080 canvas
[libx264 @ 0x556876e1d6c0] using SAR=1/1
[libx264 @ 0x556876e1d6c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x556876e1d6c0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x556876e1d6c0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'AQuietPlaceEncode2.mkv':

Metadata:

encoder : Lavf58.76.100

Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p(progressive), 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 23.98 fps, 1k tbn (default)

Metadata:

encoder : Lavc58.134.100 libx264

Side data:

cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A

Stream #0:1: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 7.1, fltp (24 bit)

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:2: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 5.1(side), fltp

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:3: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 5.1(side), fltp

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:4: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 5.1(side), fltp

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:5: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 5.1(side), fltp

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:6: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, 5.1(side), fltp

Metadata:

encoder : Lavc58.134.100 libvorbis

Stream #0:7: Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
Stream #0:8: Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
Stream #0:9: Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
Stream #0:10: Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
Stream #0:11: Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)

Change History (1)

comment:1 by Michael Harmon, 3 years ago

Summary: unreasonable RAM usage when copying hdmv_pgs subs with -forced_subs_only 1 and burning in subs with a complex filtergraphInsane RAM usage when copying hdmv_pgs subs with -forced_subs_only 1 and burning in subs with a complex filtergraph
Note: See TracTickets for help on using tickets.