View Full Version : Encoding dark source
ZZZERO
8th February 2010, 16:46
I'm usually happy with my encodes, but I'm having trouble with an interlaced source with many low light scenes. The encode has come out much darker than the source. The x264 settings I use are:
--profile high --crf 20 --thread-input --b-adapt 2 --b-pyramid normal --ref 5 --rc-lookahead 50 --trellis 0 --no-fast-pskip --sar 1:1 --aud --output
This is my avs script:
LoadPlugin("C:\Program Files\megui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("E:\CLYN\CLYN.d2v", info=3)
LoadPlugin("C:\Program Files\megui\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, interlaced=true, threads=0)
fft3dfilter(interlaced=true)
Load_Stdcall_Plugin("C:\Program Files\megui\tools\yadif\yadif.dll")
Yadif(order=1)
crop( 4, 4, -12, -8)
LanczosResize(576,432) # Lanczos (Sharp)
#denoise
What can I do to get better results with the low light footage? How much would it help to lower the crf to 17?
poisondeathray
8th February 2010, 16:59
darker than the source? are you sure it's not a playback issue?
mp3dom
8th February 2010, 17:06
Try to disable the ColorMatrix filter. It could be responsible for the color shift
Shevach
10th February 2010, 17:22
I suggest that 'darkening' of low lit scenes is related to quantization process.
Indeed, dark picture produces low magnitude coefficients after DCT. Hence after quantization many of coefficients are eliminated or zeroed. Consequently the total energy of a block is decreased and this leads to 'darkening'.
I assume also that in YUV color-space a low lit scene is gets more dark and more green.
Blue_MiSfit
10th February 2010, 18:17
No... This is not a byproduct of compression. It's a playback issue (specifically one related to 0-255 or 16-235 levels)
~MiSfit
Shevach
11th February 2010, 08:27
Perhaps in the given case 'darkening' is caused by playback.
However, my point is more general:
The quantization might reduce luminance levels (e.g. dead-zone is large). Consequently upon decoding video material might get more dark.
For example, transformed luma 4x4 block from low-lit picture can have the following values:
[ 4 1 1 0 ]
[ 1 1 0 0 ]
[ 1 1 1 0 ]
[ 0 0 0 0 ]
Total luma energy = 4^2 + 6 = 21.
After quantization with scaler=2 we have
[ 2 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
At decoder's side the restored block has total energy 16. Hence the block gets more dark than the original one.
Dark Shikari
11th February 2010, 09:24
Perhaps in the given case 'darkening' is caused by playback.
However, my point is more general:
The quantization might reduce luminance levels (e.g. dead-zone is large). Consequently upon decoding video material might get more dark.
For example, transformed luma 4x4 block from low-lit picture can have the following values:
[ 4 1 1 0 ]
[ 1 1 0 0 ]
[ 1 1 1 0 ]
[ 0 0 0 0 ]
Total luma energy = 4^2 + 6 = 21.
After quantization with scaler=2 we have
[ 2 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
At decoder's side the restored block has total energy 16. Hence the block gets more dark than the original one.It doesn't exactly work that way. The qpel and bipred rounding functions actually bias towards a higher brightness than the original video, which results in one of the benefits of x264's implementation of weightp.
Furthermore, x264's trellis has code specifically to optimize for the case of DC-only DCT blocks and avoid exactly the case that you gave.
Shevach
11th February 2010, 11:59
Furthermore, x264's trellis has code specifically to optimize for the case of DC-only DCT blocks and avoid exactly the case that you gave.
This is nice that x264 has built utility which is tailored to maintain the same energy in both original and reproduced signals.
Could you provide info how 'trellis' work? Does 'trellis' compensate DC component or AC or both?
Dark Shikari
11th February 2010, 12:39
This is nice that x264 has built utility which is tailored to maintain the same energy in both original and reproduced signals.
Could you provide info how 'trellis' work? Does 'trellis' compensate DC component or AC or both?The particular code I was talking about compensates for the specific case of a block which is not DC only before quantization and is DC only after quantization (lines 563-568, encoder/rdo.c). It takes into account the fact that without AC coefficients, the DC coefficient is not dithered and thus may be rounded down slightly more than a frequency-domain-only approach would expect.
You're talking about a separate topic; energy preservation is done via a combination of psy-trellis (lines 515-522, encoder/rdo.c) and psy-RD (lines 111-127, encoder/rdo.c).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.