[FFmpeg-user] tmix and scale, different brightness depending on order

Michael Koch astroelectronic at t-online.de
Sun Jan 6 03:06:49 EET 2019


I found a problem while I was experimenting with the haldclut filter. 
But it's simpler to reproduce without haldclut. The input video contains 
10 seconds of noise (10-bit) and can be downloaded here (2MB): 
http://www.astro-electronic.de/x.mov

My command line compares two cases with hstack.
Left side: first tmix filter, then scale filter
Right side: first scale filter, then tmix filter
In the output video you can see that the right side is darker. I don't 
understand why.
It's not a big difference and only visible with strong contrast enhancement.
But the error was big enough to make my haldclut useless.

Below is the console output.

Michael

C:\Users\mKoch\Desktop>c:\ffmpeg\ffmpeg -i x.mov -i x.mov 
-filter_complex [0]tm
ix=frames=25,scale=100:100[a];[1]scale=100:100,tmix=frames=25[b];[a][b]hstack,eq
=brightness=0.77:contrast=2,eq=contrast=2,eq=contrast=2,eq=contrast=2,eq=contras
t=2 -y out.mp4
ffmpeg version N-92833-gfccba32b4c Copyright (c) 2000-2018 the FFmpeg 
developers

   built with gcc 8.2.1 (GCC) 20181201
   configuration: --enable-gpl --enable-version3 --enable-sdl2 
--enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libbluray 
--enable-lib
freetype --enable-libmp3lame --enable-libopencore-amrnb 
--enable-libopencore-amr
wb --enable-libopenjpeg --enable-libopus --enable-libshine 
--enable-libsnappy --
enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx 
--enable-l
ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 
--enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp 
--enable-libvidstab --en
able-libvorbis --enable-libvo-amrwbenc --enable-libmysofa 
--enable-libspeex --en
able-libxvid --enable-libaom --enable-libmfx --enable-amf 
--enable-ffnvcodec --e
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec 
--enable-dxva2 --enab
le-avisynth --enable-libopenmpt
   libavutil      56. 25.100 / 56. 25.100
   libavcodec     58. 42.104 / 58. 42.104
   libavformat    58. 25.100 / 58. 25.100
   libavdevice    58.  6.101 / 58.  6.101
   libavfilter     7. 46.101 /  7. 46.101
   libswscale      5.  4.100 /  5.  4.100
   libswresample   3.  4.100 /  3.  4.100
   libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'x.mov':
   Metadata:
     major_brand     : qt
     minor_version   : 512
     compatible_brands: qt
     encoder         : Lavf58.25.100
   Duration: 00:00:11.06, start: 0.000000, bitrate: 1533 kb/s
     Stream #0:0(eng): Video: h264 (High 4:2:2) (avc1 / 0x31637661), 
yuv422p10le,
  400x400 [SAR 1:1 DAR 1:1], 1401 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 
tbc (defaul
t)
     Metadata:
       handler_name    : VideoHandler
       encoder         : Lavc58.42.104 libx264
       timecode        : 19:19:19:17
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, flt
p, 128 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
     Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
     Metadata:
       handler_name    : TimeCodeHandler
       timecode        : 19:19:19:17
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'x.mov':
   Metadata:
     major_brand     : qt
     minor_version   : 512
     compatible_brands: qt
     encoder         : Lavf58.25.100
   Duration: 00:00:11.06, start: 0.000000, bitrate: 1533 kb/s
     Stream #1:0(eng): Video: h264 (High 4:2:2) (avc1 / 0x31637661), 
yuv422p10le,
  400x400 [SAR 1:1 DAR 1:1], 1401 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 
tbc (defaul
t)
     Metadata:
       handler_name    : VideoHandler
       encoder         : Lavc58.42.104 libx264
       timecode        : 19:19:19:17
     Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, flt
p, 128 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
     Stream #1:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
     Metadata:
       handler_name    : TimeCodeHandler
       timecode        : 19:19:19:17
Stream mapping:
   Stream #0:0 (h264) -> tmix (graph 0)
   Stream #1:0 (h264) -> scale (graph 0)
   eq (graph 0) -> Stream #0:0 (libx264)
   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000000004fa8c0] using SAR=1/1
[libx264 @ 00000000004fa8c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 
SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 00000000004fa8c0] profile High 4:2:2, level 1.1, 4:2:2, 8-bit
[libx264 @ 00000000004fa8c0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 
AVC cod
ec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: 
cabac=1 r
ef=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_pski
p=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 
nr=0 deci
mate=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=2
5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 
qcomp=0.6
0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
   Metadata:
     major_brand     : qt
     minor_version   : 512
     compatible_brands: qt
     encoder         : Lavf58.25.100
     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv422p, 
200x100 [SA
R 1:1 DAR 2:1], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
     Metadata:
       encoder         : Lavc58.42.104 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, flt
p, 128 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
       encoder         : Lavc58.42.104 aac
frame=   20 fps=0.0 q=0.0 size=       0kB time=00:00:01.85 bitrate=   
0.2kbits/s
frame=   44 fps= 43 q=0.0 size=       0kB time=00:00:02.81 bitrate=   
0.1kbits/s
frame=   68 fps= 44 q=28.0 size=       0kB time=00:00:03.77 bitrate=   
0.1kbits/
frame=   92 fps= 45 q=28.0 size=       0kB time=00:00:04.73 bitrate=   
0.1kbits/
frame=  116 fps= 45 q=28.0 size=       0kB time=00:00:05.69 bitrate=   
0.1kbits/
frame=  140 fps= 45 q=28.0 size=       0kB time=00:00:06.65 bitrate=   
0.1kbits/
frame=  164 fps= 46 q=28.0 size=     256kB time=00:00:07.61 bitrate= 
275.4kbits/
frame=  188 fps= 46 q=28.0 size=     256kB time=00:00:08.57 bitrate= 
244.6kbits/
frame=  212 fps= 46 q=28.0 size=     256kB time=00:00:09.53 bitrate= 
220.0kbits/
frame=  236 fps= 46 q=28.0 size=     256kB time=00:00:10.49 bitrate= 
199.8kbits/
frame=  252 fps= 46 q=-1.0 Lsize=     592kB time=00:00:11.05 bitrate= 
438.9kbits
/s dup=1 drop=0 speed=   2x
video:411kB audio:172kB subtitle:0kB other streams:0kB global 
headers:0kB muxing
  overhead: 1.551304%
[libx264 @ 00000000004fa8c0] frame I:2     Avg QP:26.49 size:  7296
[libx264 @ 00000000004fa8c0] frame P:64    Avg QP:26.91 size:  4687
[libx264 @ 00000000004fa8c0] frame B:186   Avg QP:30.39 size:   568
[libx264 @ 00000000004fa8c0] consecutive B-frames:  1.6% 0.0%  0.0% 98.4%
[libx264 @ 00000000004fa8c0] mb I  I16..4:  0.0%  0.0% 100.0%
[libx264 @ 00000000004fa8c0] mb P  I16..4:  0.0%  0.0% 4.6%  P16..4: 
56.1% 24.1
% 14.9%  0.0%  0.0%    skip: 0.4%
[libx264 @ 00000000004fa8c0] mb B  I16..4:  0.0%  0.0% 0.1%  B16..8: 
13.3%  6.4
%  4.8%  direct:27.3%  skip:48.1%  L0:34.6% L1:48.7% BI:16.7%
[libx264 @ 00000000004fa8c0] 8x8 transform intra:0.0% inter:25.2%
[libx264 @ 00000000004fa8c0] coded y,uvDC,uvAC intra: 66.4% 18.2% 0.0% 
inter: 44
.6% 0.1% 0.0%
[libx264 @ 00000000004fa8c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 50%  6% 18%  
6%  4%
  4%  4%  5%  5%
[libx264 @ 00000000004fa8c0] i8c dc,h,v,p: 93%  2%  6%  0%
[libx264 @ 00000000004fa8c0] Weighted P-Frames: Y:15.6% UV:0.0%
[libx264 @ 00000000004fa8c0] ref P L0: 59.6% 20.0% 17.1% 3.1%  0.2%
[libx264 @ 00000000004fa8c0] ref B L0: 94.0%  5.4%  0.6%
[libx264 @ 00000000004fa8c0] ref B L1: 99.3%  0.7%
[libx264 @ 00000000004fa8c0] kb/s:333.49
[aac @ 00000000004fb680] Qavg: 1570.061


More information about the ffmpeg-user mailing list