Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th September 2020, 03:55   #4001  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Using R52:

Code:
clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="limited")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="I:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/PQ_to_BT709_slope.cube")
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235)
-> green screen
Code:
clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="limited")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="I:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/PQ_to_BT709_slope.cube")
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="470bg", range_s="limited")
clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235)
-> green screen
Code:
# adjusting color space from YUV420P10 to RGB48 for vscube
clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="limited")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="I:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/PQ_to_BT709_slope.cube")
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="470bg", range_s="limited")
clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235)
-> works

Same happens when using RGB30 in the scripts.


Levels documentation says:
Code:
clip

    Clip to process. It must have integer sample type and bit depth between 8 and 16, or float sample type and bit depth of 32. If there are any frames with other formats, an error will be returned.
since there isn't an error I assume this is a bug in Vapoursynth or I'm doing something wrong when converting RGBX to YUV.

So:
a. can others reproduce this?
b. is this a bug in Vapoursynth or am I missing something?


Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 9th September 2020, 04:00   #4002  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,370
@Selur , for the 10bit levels cases, it should not be 16 and 235. It should be 64 and 940. And 4096-60160 for 16bit

Also, you are adjusting all channels, not just Y - is that what you wanted ?

And for CbCr, in 8bit it would be 16-240 , 64-960 for 10bit, 4096-61440 for 16bit

Last edited by poisondeathray; 9th September 2020 at 04:11.
poisondeathray is offline   Reply With Quote
Old 9th September 2020, 15:00   #4003  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
@Poisongdeathray: Ah okay, I assumed Levels would to the scaling automatically.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 13th September 2020, 05:08   #4004  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Small question: is there a way to disable auto-loading of filters inside a script (on Linux and Mac) to be sure that only the filters which are explicitly loaded in the script are tried to load?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 13th September 2020, 10:49   #4005  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,554
Quote:
Originally Posted by Selur View Post
Small question: is there a way to disable auto-loading of filters inside a script (on Linux and Mac) to be sure that only the filters which are explicitly loaded in the script are tried to load?
Implemented in the doodle1 branch but it's only accessible through the environment policy interface so it's very iffy. Unfortunately I can't give you an example either right now.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 13th September 2020, 11:04   #4006  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
no problem, I'll wait till it hits the main branch, but happy there it's in the works.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 17th September 2020, 08:18   #4007  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 134
I am not an expert but this may be a bug in Vapoursynth (my original post here https://forum.selur.net/showthread.p...d=9159#pid9159)
Gamma correction works normally if source transformed to RGB. But in YUV it produce green/purple (depends of gamma adjustment direction) color shift.

Examles:
planes: all Gamma adjusted in YUV. Green/Purle color shift problem (probably bug in Vapoursynth):


planes: luma Gamma adjusted in YUV. No color shift problem, but "desaturation" effect that is essential for this sort of luma only adjustment.

planes: all Gamma adjusted in RGB. This is how any normal gamma adjustment usually look:


As a reference here is screengrab with gamma adjusted PhotoLine graphic editor. Some difference may be due video player screengrabs color management and range transformations, but overall look is near the same. It is dark but not desaturated:
shph is offline   Reply With Quote
Old 17th September 2020, 17:11   #4008  |  Link
VS_Fan
Registered User
 
Join Date: Jan 2016
Posts: 98
Quote:
Originally Posted by shph View Post
I am not an expert but this may be a bug in Vapoursynth (my original post here https://forum.selur.net/showthread.p...d=9159#pid9159)
Gamma correction works normally if source transformed to RGB. But in YUV it produce green/purple (depends of gamma adjustment direction) color shift.
It's not a bug. A brief suggestion: Don’t include the chroma planes if adjusting gamma with core.levels in vapoursynth

Recommended reading: Why gamma-correction is applied to RGB instead of YUV or similar?

Also, here’s some info from Avisynth’s Levels
Quote:
When processing data in YUV mode, Levels only gamma-corrects the luma information, not the chroma. Gamma correction is really an RGB concept, and is only approximated here in YUV. If gamma=1.0 (unity), the filter should have the same effect in both RGB and YUV modes. For adjusting brightness or contrast in YUV mode, it may be better (depending on the effect you are looking for) to use Tweak or ColorYUV, because Levels changes the chroma of the clip

Last edited by VS_Fan; 17th September 2020 at 17:13.
VS_Fan is offline   Reply With Quote
Old 17th September 2020, 20:32   #4009  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Vapoursynth documentation should also include some of this,..
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 19th September 2020, 08:33   #4010  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 134
That makes sense. Y is Luma (tonality data only) and UV is saturation (color data only). Gamma is tonal curve only, so seems it is just useless and incorrect to apply it to UV color data or to YUV all together.

It is ok to apply Gamma only to Y in YUV model.
It is ok to apply Gamma to all RGB channels together or to separate R G B channels in RGB model.

And so we came to YRGB color correction concept used in DaVinci Resolve and some other color grading apps
shph is offline   Reply With Quote
Old 19th September 2020, 17:30   #4011  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Quote:
Originally Posted by shph View Post
It is ok to apply Gamma only to Y in YUV model.
It really is not ok!
Cary Knoop is offline   Reply With Quote
Old 19th September 2020, 23:12   #4012  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 134
Cary Knoop, Can you explain further why?

As i noticed earlier Y gamma is not the same as RGB gamma. Y gamma is more like some special effect when you need adjust gamma without saturation.
shph is offline   Reply With Quote
Old 20th September 2020, 04:34   #4013  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 134
Here is another observation. Tweak is a part of VapourSynth? It was a discussed earlier that color correction results don't match exact to other image editors, but seems it is just due different math concepts of same adjustments in different apps https://forum.doom9.org/showthread.php?t=175093

But also i noticed that Tweak Contrast always shifts a lot to dark side of gradient. It feels like center Pivot point for that tool is way off. Could it be a bug? Maybe Tweak also require some special gamma transformation?
You can download Test Patterns generated in DaVinci Resolve here: https://www.dropbox.com/sh/bak63hnr7...jPuQaaxFa?dl=0


To compare, here is how normal contrast adjustment look s in Davinci Resolve or any other app:

Last edited by shph; 20th September 2020 at 04:36.
shph is offline   Reply With Quote
Old 20th September 2020, 05:12   #4014  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Quote:
Originally Posted by shph View Post
Cary Knoop, Can you explain further why?

As i noticed earlier Y gamma is not the same as RGB gamma. Y gamma is more like some special effect when you need adjust gamma without saturation.
You mess up your colors by modifying Y'.

If you want to do what I suspect you want to do you should use something like L*a*b*.
Unfortunately, Vapoursynth does not support this color model.
Cary Knoop is offline   Reply With Quote
Old 20th September 2020, 05:56   #4015  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,370
Quote:
Originally Posted by shph View Post
Here is another observation. Tweak is a part of VapourSynth? It was a discussed earlier that color correction results don't match exact to other image editors, but seems it is just due different math concepts of same adjustments in different apps https://forum.doom9.org/showthread.php?t=175093

But also i noticed that Tweak Contrast always shifts a lot to dark side of gradient. It feels like center Pivot point for that tool is way off. Could it be a bug? Maybe Tweak also require some special gamma transformation?


tweak is just a port from avisynth tweak

If you want to increase contrast in a fashion similar to how Resolve and other NLE programs work, use havsfunc SigmoidDirect , for an increasing contrast "s-curve". The cont value units do not correlate directly with other programs

clip = haf.SigmoidDirect(clip, cont=blah, planes=[0])

gif demo, cont from 1 to 36


There is also VapourSynth-Curve, which can take photoshop acv files, and can work in YUV or RGB, and you can apply to each/all planes
poisondeathray is offline   Reply With Quote
Old 20th September 2020, 07:15   #4016  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 134
Yes, that sort of symmetrical S-curve variations usually expected when something named as "Contrast". Also center point position of that curve sometimes may be adjusted and that adjustment named "Pivot" in other apps. So it maybe a bug in Tweak, or Tweak may be just designed like this for some purpose.
shph is offline   Reply With Quote
Old 29th September 2020, 09:40   #4017  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
for some unknown reason, this seems to crash vspipe (like it's stuck in an infinite loop or something)
Code:
from vapoursynth import *
import os
clp = core.std.BlankClip(format=GRAYS)
clp.set_output(42)
os.system(f'vspipe -o 42 {__file__} tmp.bin -p')
clp = core.raws.Source('tmp.bin', 640, 480, src_fmt='GRAYS')
clp.set_output()
@Myrsloik what is happening here?
feisty2 is offline   Reply With Quote
Old 29th September 2020, 14:13   #4018  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I found a workaround to solve the problem
Code:
from vapoursynth import *
import os
clp = core.std.BlankClip(format=GRAYS)
clp.set_output(42)
if 'cache_flag' not in globals():
    os.system(f'vspipe -o 42 -a "cache_flag=yes" {__file__} tmp.bin -p')
    clp = core.raws.Source('tmp.bin', 640, 480, src_fmt='GRAYS')
clp.set_output()
it doesn't seem very pretty though...
feisty2 is offline   Reply With Quote
Old 29th September 2020, 17:37   #4019  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I wonder if there's a better (more accurate) way of doing this with vs.core or the vs environment stuff:
Code:
def TraceFilePathOfTheRunningScript():
    Frame = inspect.currentframe()
    Callers = inspect.getouterframes(Frame)
    del Frame
    for x in Callers:
        if x.filename.endswith('.vpy'):
            return x.filename
it should work for most cases but it relies on the script being a .vpy file, which I guess might fail in some rare cases?
feisty2 is offline   Reply With Quote
Old 4th October 2020, 19:01   #4020  |  Link
Jukus
Registered User
 
Join Date: Jul 2019
Location: Russia
Posts: 87
I don't know if need to write about this, where and how correctly, but this file opens correctly with lsmas, but all the frames are mixed up when using ffms2.
https://1fichier.com/?w8vicd396ctnl4ds9e45
Jukus is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:35.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.