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 13th September 2020, 11:04   #4081  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
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
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 17th September 2020, 08:18   #4082  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 101
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   #4083  |  Link
VS_Fan
Registered User
 
Join Date: Jan 2016
Posts: 96
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   #4084  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
Vapoursynth documentation should also include some of this,..
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 19th September 2020, 08:33   #4085  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 101
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   #4086  |  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   #4087  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 101
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   #4088  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 101
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   #4089  |  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   #4090  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,551
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   #4091  |  Link
shph
Registered User
 
Join Date: Mar 2020
Posts: 101
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   #4092  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
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?
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 29th September 2020, 14:13   #4093  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
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...
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 29th September 2020, 17:37   #4094  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
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?
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 4th October 2020, 19:01   #4095  |  Link
Jukus
Registered User
 
Join Date: Jul 2019
Location: Russia
Posts: 65
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
Old 4th October 2020, 19:16   #4096  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
@Jukus: looks fine here using ffms2,...
Ah okay, I see it if I don't drop halve of the fields.
Seems like the field order gets mixed up.
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..

Last edited by Selur; 4th October 2020 at 19:46.
Selur is offline   Reply With Quote
Old 5th October 2020, 12:53   #4097  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 802
Link to BlankClip function source code

Can I get link to source code of BlankClip function?
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 5th October 2020, 13:04   #4098  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
Quote:
Originally Posted by vcmohan View Post
Can I get link to source code of BlankClip function?
https://github.com/vapoursynth/vapou...ilters.c#L1184
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 5th October 2020, 13:09   #4099  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,706
On the github website there is a search field in the top left corner, enter BlankClip there or whatever you search.

Or download the code, open the code folder in Visual Studio Code and click on the search button in the side bar.

https://github.com/vapoursynth/vapou...implefilters.c
stax76 is offline   Reply With Quote
Old 7th October 2020, 07:29   #4100  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 802
Quote:
Originally Posted by feisty2 View Post
many thanks. I am trying to code a plugin where there will be no input clip but only outputs frames. I find in blankclip
Code:
VSNodeRef* node = vsapi->propGetNode(in, "clip", 0, &err);
if (!err) {
        d.vi = *vsapi->getVideoInfo(node);
        vsapi->freeNode(node);
        hasvi = 1;
    }
What should I do. I have no node as input, but have I to include a node and bind it to something? Or I should have no ref to node in my code?
in the arInitial part what is the purpose of the following?
Code:
if (d->vi.fpsNum > 0) {
                VSMap* frameProps = vsapi->getFramePropsRW(frame);
                vsapi->propSetInt(frameProps, "_DurationNum", d->vi.fpsDen, paReplace);
                vsapi->propSetInt(frameProps, "_DurationDen", d->vi.fpsNum, paReplace);
            }
Is there an instance where fps == 0?
What is keep?
May be I am testing your patience! Sorry for it.
__________________
mohan
my plugins are now hosted here

Last edited by vcmohan; 7th October 2020 at 07:33.
vcmohan 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 19:12.


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