[FFmpeg-user] ffmpeg architecture question

Mark Filipak markfilipak.windows+ffmpeg at gmail.com
Fri Apr 17 14:08:24 EEST 2020


Argh! I keep making mistakes. I'm working too quickly. You see, I had 2 differing versions: one 
using 'telecine=pattern=5' and one using 'telecine=pattern=46'. They tried to do the same thing, but 
by differing methods (differing filter graphs). It's really easy to get them mixed up.

Here is a sketch of the original graph:

split[A]    select='not(eq(mod(n+1\,5)\,3))'       [C]interleave
      [B]split[E]select='eq(mod(n+1\,5)\,2)'[G]blend[D]
              [F]select='eq(mod(n+1\,5)\,3)'[H]


Here is a sketch of the graph with 'blend' inputs reversed:

split[A]    select='not(eq(mod(n+1\,5)\,3))'       [C]interleave
      [B]split[E]select='eq(mod(n+1\,5)\,2)'[H]blend[D]
              [F]select='eq(mod(n+1\,5)\,3)'[G]

Here are the command lines (as a unified script):

: Run original filter chain
SET FFREPORT=file=FOO-GH.LOG:level=32

ffmpeg -i %1 -filter_complex 
"telecine=pattern=46,split[A][B],[A]select='not(eq(mod(n+1\,5)\,3))'[C],[B]split[E][F],[E]select='eq(mod(n+1\,5)\,2)'[G],[F]select='eq(mod(n+1\,5)\,3)'[H],[G][H]blend[D],[C][D]interleave" 
-map 0 -c:v libx264 -crf 20 -an -sn "C:\AVOut\FOO-GH.MKV"

: Run reversed 'blend' inputs
SET FFREPORT=file=FOO-HG.LOG:level=32

ffmpeg -i %1 -filter_complex 
"telecine=pattern=46,split[A][B],[A]select='not(eq(mod(n+1\,5)\,3))'[C],[B]split[E][F],[E]select='eq(mod(n+1\,5)\,2)'[G],[F]select='eq(mod(n+1\,5)\,3)'[H],[H][G]blend[D],[C][D]interleave" 
-map 0 -c:v libx264 -crf 20 -an -sn "C:\AVOut\FOO-HG.MKV"

Here are the logs in the same order:

ffmpeg started on 2020-04-17 at 06:35:28
Report written to "FOO-GH.LOG"
Log level: 32
Command line:
ffmpeg -i "M:\\Test Videos\\23.976p.mkv" -filter_complex 
"telecine=pattern=46,split[A][B],[A]select='not(eq(mod(n+1\\,5)\\,3))'[C],[B]split[E][F],[E]select='eq(mod(n+1\\,5)\\,2)'[G],[F]select='eq(mod(n+1\\,5)\\,3)'[H],[G][H]blend[D],[C][D]interleave" 
-map 0 -c:v libx264 -crf 20 -an -sn "C:\\AVOut\\FOO-GH.MKV"
ffmpeg version git-2020-04-03-52523b6 Copyright (c) 2000-2020 the FFmpeg developers
   built with gcc 9.3.1 (GCC) 20200328
   configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls 
--enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype 
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg 
--enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt 
--enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp 
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib 
--enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc 
--enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx 
--enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec 
--enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 42.102 / 56. 42.102
   libavcodec     58. 77.101 / 58. 77.101
   libavformat    58. 42.100 / 58. 42.100
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.101 /  7. 77.101
   libswscale      5.  6.101 /  5.  6.101
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'M:\Test Videos\23.976p.mkv':
   Metadata:
     encoder         : libebml v1.3.9 + libmatroska v1.5.2
     creation_time   : 2020-04-04T03:44:24.000000Z
   Duration: 00:00:10.01, start: 0.000000, bitrate: 544 kb/s
     Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 
23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
     Metadata:
       BPS-eng         : 538378
       DURATION-eng    : 00:00:10.010000000
       NUMBER_OF_FRAMES-eng: 240
       NUMBER_OF_BYTES-eng: 673646
       _STATISTICS_WRITING_APP-eng: mkvmerge v41.0.0 ('Smarra') 64-bit
       _STATISTICS_WRITING_DATE_UTC-eng: 2020-04-04 03:44:24
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[Parsed_telecine_0 @ 000001aa1b2384c0] Telecine pattern 46 yields up to 3 frames per frame, pts 
advance factor: 4/10
Stream mapping:
   Stream #0:0 (h264) -> telecine
   interleave -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_telecine_0 @ 000001aa18f0e700] Telecine pattern 46 yields up to 3 frames per frame, pts 
advance factor: 4/10
[libx264 @ 000001aa18ee2d40] using SAR=1/1
[libx264 @ 000001aa18ee2d40] MB rate (8160000000) > level limit (16711680)
[libx264 @ 000001aa18ee2d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001aa18ee2d40] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 000001aa18ee2d40] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 
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=12 lookahead_threads=2 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=25 scenecut=40 intra_refresh=0 
rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'C:\AVOut\FOO-GH.MKV':
   Metadata:
     encoder         : Lavf58.42.100
     Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 
q=-1--1, 1k tbn, 1000k tbc (default)
     Metadata:
       encoder         : Lavc58.77.101 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   46 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A dup=0 drop=11 speed=   0x
frame=  116 fps=111 q=28.0 size=       1kB time=00:00:01.18 bitrate=   4.1kbits/s dup=0 drop=29 
speed=1.14x
frame=  195 fps=126 q=26.0 size=       1kB time=00:00:02.83 bitrate=   1.7kbits/s dup=0 drop=49 
speed=1.83x
frame=  262 fps=128 q=28.0 size=       1kB time=00:00:04.23 bitrate=   1.2kbits/s dup=0 drop=65 
speed=2.07x
frame=  333 fps=131 q=27.0 size=     211kB time=00:00:05.72 bitrate= 302.5kbits/s dup=0 drop=83 
speed=2.25x
frame=  408 fps=133 q=28.0 size=     211kB time=00:00:07.27 bitrate= 238.0kbits/s dup=0 drop=102 
speed=2.38x
frame=  479 fps=135 q=27.0 size=     211kB time=00:00:08.76 bitrate= 197.6kbits/s dup=0 drop=120 
speed=2.46x
frame=  479 fps=118 q=27.0 size=     211kB time=00:00:08.76 bitrate= 197.6kbits/s dup=0 drop=120 
speed=2.15x
video:401kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.988793%
[libx264 @ 000001aa18ee2d40] frame I:2     Avg QP: 8.81  size: 10038
[libx264 @ 000001aa18ee2d40] frame P:178   Avg QP:18.73  size:  1750
[libx264 @ 000001aa18ee2d40] frame B:299   Avg QP:18.46  size:   261
[libx264 @ 000001aa18ee2d40] consecutive B-frames:  0.4% 48.4%  1.9% 49.3%
[libx264 @ 000001aa18ee2d40] mb I  I16..4: 79.3% 18.2%  2.5%
[libx264 @ 000001aa18ee2d40] mb P  I16..4:  0.7%  0.4%  0.2%  P16..4:  2.3%  0.7%  0.2%  0.0%  0.0% 
   skip:95.7%
[libx264 @ 000001aa18ee2d40] mb B  I16..4:  0.1%  0.0%  0.0%  B16..8:  1.6%  0.1%  0.0%  direct: 
0.0%  skip:98.2%  L0:26.8% L1:71.3% BI: 2.0%
[libx264 @ 000001aa18ee2d40] 8x8 transform intra:24.7% inter:40.6%
[libx264 @ 000001aa18ee2d40] coded y,uvDC,uvAC intra: 4.3% 16.3% 13.6% inter: 0.1% 0.4% 0.3%
[libx264 @ 000001aa18ee2d40] i16 v,h,dc,p: 85% 14%  1%  0%
[libx264 @ 000001aa18ee2d40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34%  3% 63%  0%  0%  0%  0%  0%  0%
[libx264 @ 000001aa18ee2d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 25% 24%  1%  1%  1%  0%  1%  0%
[libx264 @ 000001aa18ee2d40] i8c dc,h,v,p: 61% 14% 24%  0%
[libx264 @ 000001aa18ee2d40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001aa18ee2d40] ref P L0: 69.3%  1.7% 16.8% 12.1%
[libx264 @ 000001aa18ee2d40] ref B L0: 69.3% 13.6% 17.1%
[libx264 @ 000001aa18ee2d40] ref B L1: 98.4%  1.6%
[libx264 @ 000001aa18ee2d40] kb/s:328.46


ffmpeg started on 2020-04-17 at 06:36:11
Report written to "FOO-HG.LOG"
Log level: 32
Command line:
ffmpeg -i "M:\\Test Videos\\23.976p.mkv" -filter_complex 
"telecine=pattern=46,split[A][B],[A]select='not(eq(mod(n+1\\,5)\\,3))'[C],[B]split[E][F],[E]select='eq(mod(n+1\\,5)\\,2)'[G],[F]select='eq(mod(n+1\\,5)\\,3)'[H],[H][G]blend[D],[C][D]interleave" 
-map 0 -c:v libx264 -crf 20 -an -sn "C:\\AVOut\\FOO-HG.MKV"
ffmpeg version git-2020-04-03-52523b6 Copyright (c) 2000-2020 the FFmpeg developers
   built with gcc 9.3.1 (GCC) 20200328
   configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls 
--enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype 
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg 
--enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt 
--enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp 
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib 
--enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc 
--enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx 
--enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec 
--enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 42.102 / 56. 42.102
   libavcodec     58. 77.101 / 58. 77.101
   libavformat    58. 42.100 / 58. 42.100
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.101 /  7. 77.101
   libswscale      5.  6.101 /  5.  6.101
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'M:\Test Videos\23.976p.mkv':
   Metadata:
     encoder         : libebml v1.3.9 + libmatroska v1.5.2
     creation_time   : 2020-04-04T03:44:24.000000Z
   Duration: 00:00:10.01, start: 0.000000, bitrate: 544 kb/s
     Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 
23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
     Metadata:
       BPS-eng         : 538378
       DURATION-eng    : 00:00:10.010000000
       NUMBER_OF_FRAMES-eng: 240
       NUMBER_OF_BYTES-eng: 673646
       _STATISTICS_WRITING_APP-eng: mkvmerge v41.0.0 ('Smarra') 64-bit
       _STATISTICS_WRITING_DATE_UTC-eng: 2020-04-04 03:44:24
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[Parsed_telecine_0 @ 000001c0aff784c0] Telecine pattern 46 yields up to 3 frames per frame, pts 
advance factor: 4/10
Stream mapping:
   Stream #0:0 (h264) -> telecine
   interleave -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_telecine_0 @ 000001c0afb7bec0] Telecine pattern 46 yields up to 3 frames per frame, pts 
advance factor: 4/10
[libx264 @ 000001c0af952d40] using SAR=1/1
[libx264 @ 000001c0af952d40] MB rate (8160000000) > level limit (16711680)
[libx264 @ 000001c0af952d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001c0af952d40] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 000001c0af952d40] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 
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=12 lookahead_threads=2 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=25 scenecut=40 intra_refresh=0 
rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'C:\AVOut\FOO-HG.MKV':
   Metadata:
     encoder         : Lavf58.42.100
     Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 
q=-1--1, 1k tbn, 1000k tbc (default)
     Metadata:
       encoder         : Lavc58.77.101 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   36 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x
frame=   94 fps= 93 q=28.0 size=       1kB time=00:00:00.58 bitrate=   8.4kbits/s speed=0.58x
frame=  177 fps=117 q=28.0 size=       1kB time=00:00:01.97 bitrate=   2.5kbits/s speed=1.31x
frame=  260 fps=129 q=28.0 size=       1kB time=00:00:03.35 bitrate=   1.5kbits/s speed=1.66x
frame=  328 fps=130 q=28.0 size=     180kB time=00:00:04.48 bitrate= 327.6kbits/s speed=1.78x
frame=  408 fps=135 q=28.0 size=     180kB time=00:00:05.82 bitrate= 252.6kbits/s speed=1.93x
frame=  485 fps=138 q=28.0 size=     180kB time=00:00:07.10 bitrate= 206.9kbits/s speed=2.02x
frame=  568 fps=141 q=28.0 size=     256kB time=00:00:08.49 bitrate= 246.9kbits/s speed=2.11x
frame=  594 fps=131 q=28.0 size=     256kB time=00:00:08.92 bitrate= 234.9kbits/s speed=1.97x
frame=  594 fps=118 q=28.0 size=     256kB time=00:00:08.92 bitrate= 234.9kbits/s speed=1.77x
video:437kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.073745%
[libx264 @ 000001c0af952d40] frame I:3     Avg QP: 6.19  size: 11408
[libx264 @ 000001c0af952d40] frame P:186   Avg QP:19.13  size:  1739
[libx264 @ 000001c0af952d40] frame B:405   Avg QP:16.99  size:   220
[libx264 @ 000001c0af952d40] consecutive B-frames:  0.7% 16.2% 27.3% 55.9%
[libx264 @ 000001c0af952d40] mb I  I16..4: 96.1%  0.9%  2.9%
[libx264 @ 000001c0af952d40] mb P  I16..4:  0.6%  0.4%  0.2%  P16..4:  2.2%  0.7%  0.2%  0.0%  0.0% 
   skip:95.7%
[libx264 @ 000001c0af952d40] mb B  I16..4:  0.1%  0.0%  0.0%  B16..8:  1.4%  0.1%  0.0%  direct: 
0.0%  skip:98.5%  L0:42.8% L1:55.4% BI: 1.8%
[libx264 @ 000001c0af952d40] 8x8 transform intra:14.6% inter:40.6%
[libx264 @ 000001c0af952d40] coded y,uvDC,uvAC intra: 3.9% 14.9% 12.4% inter: 0.1% 0.4% 0.2%
[libx264 @ 000001c0af952d40] i16 v,h,dc,p: 89% 10%  1%  0%
[libx264 @ 000001c0af952d40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  6%  4% 90%  0%  0%  0%  0%  0%  0%
[libx264 @ 000001c0af952d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 25% 24%  2%  1%  2%  0%  2%  0%
[libx264 @ 000001c0af952d40] i8c dc,h,v,p: 67% 13% 21%  0%
[libx264 @ 000001c0af952d40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001c0af952d40] ref P L0: 75.3%  2.0% 12.2% 10.4%
[libx264 @ 000001c0af952d40] ref B L0: 79.5% 13.9%  6.6%
[libx264 @ 000001c0af952d40] ref B L1: 98.4%  1.6%
[libx264 @ 000001c0af952d40] kb/s:355.76


More information about the ffmpeg-user mailing list