View Full Version : Look at this color change after AVC lossless encode. Not chroma subsampling or ranges


Ajvar
3rd April 2015, 15:36
My PC and encoders live with their own life.
After lossless encodes (2, one by one) color changed twice and even if I set 4:4:4 and it's not PC<>TV range.
Later that day it finally encoded fine by x264 (after success encode by x265) but WTH that was?
Pictures: Original (http://i60.fastpic.ru/big/2015/0403/5f/90ed97789ab3a3e20f8c1647144b2d5f.png) and 2 further (http://screenshotcomparison.com/comparison/119919).
Video samples (if it's decoder problem) later:

Ajvar
3rd April 2015, 17:02
Link with video samples HERE. (https://mega.co.nz/#!kARDSYpK!ucxJZSBvvh_RzqeqAdIt0aEb7HKmwoarbffuYPn91ws)

poisondeathray
3rd April 2015, 18:25
Describe what 1,2,3 are

Post your steps, avs script if used, commandlines

"3" becomes similar to "2" if you do a TV to PC range conversion and colormatrix 601=>709 . So likely you goofed up somewhere

If you are upscaling or downscaling, then typically you would change the colormatrix . e.g. if "1" was the source and it was SD, and the colors were "correct" in the first place, then you would use colormatrix to convert 601=>709 if upscaling to HD

Ajvar
3rd April 2015, 21:58
1 = original 500p file.
2 = lossless resize of this file so I would do other steps next. it was just lanczos resize: FFVideoSource("E:\DOCUME~1\Desktop\(5)~1\source.MP4")|SetMTMode(2)|LanczosResize(1920,1080)
It was simple preset medium for x264, nothing else. And I even didn't notice color change at the first.
3 = I took lossless and used SVP interpolation script (fulfill fps drops by interpolated frames) and output another lossless x264 file: DirectShowSource2("source.mkv"...)|ConvertToYV12()/SVP script
preset medium x264. And now it was easy to find a difference in colors. First time was used Hybrid GUI, 2nd encode used Xvid4PSP.
Then I tried 4:4:4 lossless resize from 500p to 1080p, picked some color matrixs and other stuff.

Funny thing that after creating the same lossless resize but by x265 encoder, it gave 100% same colors.
Then I rebooted and next dozen encodes of the same file in x264 was fine no matter what scripts I used.

mandarinka
4th April 2015, 01:50
What probably happened:

500p file was probably guessed by your video renderer to have bt601 color primaries. OTOH, if you take the same thing upscaled to 1080p, your drivers/video renderer will guess it is bt709 color primaries. If you force the renderer to use bt601 for the upscale, the difference should go away. The color primaries affect conversion of YV12 to RGB.

Lyris
5th April 2015, 02:39
Yeah, that's a classic 601/709 mismatch.

You should avoid doing any conversion between YCbCr and RGB. Once the video is YCbCr, it should stay that way.

Ajvar
6th April 2015, 03:34
OK, thank you guys. As I see this opinion is agreed by all here so now I know what happened there. Thank you. Don't know why renderer decided I have different colors.
But how can I keep YCbCr after RGB>RCbCr? Should I add extra lines to encoder?

BTW! Maybe you also can tell me how to encode (what primaries, transfers and matrix need to use) if source (and target res.) is 1080p and Color primaries: BT.601 NTSC|Transfer characteristics: BT.470 System M|Matrix coefficients: BT.601|Color range: Limited?
Because I see that red color is way different after encoding. Planned to use 8bit x265.

Asmodian
6th April 2015, 18:11
add this to the H.264 command line.

--colorprim "smpte170m" --transfer "smpte170m" --colormatrix "smpte170m"

I believe only LAV Video with madVR respect these flags though, you might be better off doing a BT.601 to BT.709 conversion if using resolutions of 720p or higher.

Ajvar
7th April 2015, 17:28
add this to the H.264 command line.

--colorprim "smpte170m" --transfer "smpte170m" --colormatrix "smpte170m"

I believe only LAV Video with madVR respect these flags though, you might be better off doing a BT.601 to BT.709 conversion if using resolutions of 720p or higher.

:thanks: Will do it then.