This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] AviSynth 32 bit - ColorMatrix filter not working for video?
#21
Okay, to many things to look at.
I can't keep the overview. + don't have much time this week.

So let's first stick to preview only, Vapoursynth and the current version.
(Vapoursynth since, the code is a bit easier there.)

First think I noticed when looking at the image:
- It's not limited luma range! It's 28-255, so full range.
- so using ColorMatrix while clamping the colors on input and output to 16-235 will cause color changes.

So whatever created the video stream didn't properly flag the input and might have messed up the colors during the rgb->yuv444 conversion.
Opening the image with Luma range PC and Color Matric bt709 and then opening the normal preview with FFvHuFF and Color space rgb select uses the following script for preview:
# Imports
import vapoursynth as vs
core = vs.get_core()
# source: 'C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png'
# current color space: RGB24, bit depth: 8, resolution: 1440x1080, fps: 25, color matrix: 709, yuv luminance scale: full, scanorder: progressive
# Loading C:\Users\Selur\Desktop\Image Test\Test-AdobeRGB.png using vsImageReader
clip = core.imwri.Read(["C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png"])
clip = core.std.Loop(clip=clip, times=100)
# Input color space is assumed to be RGB24
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
(color range is still 28/28/30-255/255/255)
enabling ColorMatrix with 'Rec.601/..' to 'Rec.709' and Clipping set to 'no clipping' uses:
# Imports
import vapoursynth as vs
core = vs.get_core()
# source: 'C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png'
# current color space: RGB24, bit depth: 8, resolution: 1440x1080, fps: 25, color matrix: 709, yuv luminance scale: full, scanorder: progressive
# Loading C:\Users\Selur\Desktop\Image Test\Test-AdobeRGB.png using vsImageReader
clip = core.imwri.Read(["C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png"])
clip = core.std.Loop(clip=clip, times=100)
# Input color space is assumed to be RGB24
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
# adjusting color space from RGB24 to YUV444P8 for VsColorMatrix
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="709", range_s="full")
# ColorMatrix: adjusting color matrix from 470bg to 709
clip = core.resize.Bicubic(clip=clip, matrix_in_s="470bg", matrix_s="709", range_in=0, range=0)
# adjusting output color from: YUV444P8 to RGB24 for FFvHuffModel (rgb@8-bit)
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
(color range is still 28/28/30-255/255/255)
now using the FilterPreview:
# Imports
import vapoursynth as vs
core = vs.get_core()
# source: 'C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png'
# current color space: RGB24, bit depth: 8, resolution: 1440x1080, fps: 25, color matrix: 709, yuv luminance scale: full, scanorder: progressive
# Loading C:\Users\Selur\Desktop\Image Test\Test-AdobeRGB.png using vsImageReader
clip = core.imwri.Read(["C:/Users/Selur/Desktop/Image Test/Test-AdobeRGB.png"])
clip = core.std.Loop(clip=clip, times=100)
# Input color space is assumed to be RGB24
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
original = clip
# adjusting color space from RGB24 to YUV444P8 for VsColorMatrix
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="709", range_s="full")
# ColorMatrix: adjusting color matrix from 470bg to 709
clip = core.resize.Bicubic(clip=clip, matrix_in_s="470bg", matrix_s="709", range_in=1, range=1)
# adjusting output color from: YUV444P8 to RGB24 for FFvHuffModel (rgb@8)
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
# adjusting for FilterView
if original.format.id != clip.format.id:
if (original.format.color_family == vs.RGB and clip.format.color_family != vs.RGB):
   original = core.resize.Bicubic(original, format=clip.format.id, matrix_s="709", range_s="full")
elif (original.format.color_family == clip.format.color_family):
   original = core.resize.Bicubic(original, format=clip.format.id, range_s="full")
else:
   original = core.resize.Bicubic(original, format=clip.format.id, matrix_in_s="709", range_s="full")
stacked = core.std.StackHorizontal([original,clip])
# set output frame rate to 25.000fps
stacked = core.std.AssumeFPS(clip=stacked, fpsnum=25, fpsden=1)
# Output
stacked.set_output()

Send you a link to my latest version, which should fix the 'unnkown color format' problem.
(btw. you can check the preview script in your temp folder while the Preview is open)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
RE: AviSynth 32 bit - ColorMatrix filter not working for video? - by Selur - 03.11.2020, 07:23

Forum Jump:


Users browsing this thread: 3 Guest(s)