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 29th November 2022, 20:01   #4761  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Thanks again.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 7th December 2022, 05:08   #4762  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
I'm testing out the VSGAN filter in vsedit2, how do I free the gpu ram usage after running it? vsapi->freeFrame() doesn't free it.
lansing is offline   Reply With Quote
Old 18th December 2022, 19:31   #4763  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
I get totally different decimated output when using:
Code:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# source: 'C:\Users\Selur\Desktop\sample_from_DVD.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: telecine
# Loading C:\Users\Selur\Desktop\sample_from_DVD.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/sample_from_DVD.mkv", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 29.97
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)
# cropping the video to 704x480
clip = core.std.CropRel(clip=clip, left=6, right=10, top=0, bottom=0)
# Deinterlacing using TIVTC
clip = core.tivtc.TFM(clip=clip, mode=4)
clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
# make sure content is preceived as frame based
clip = core.std.SetFieldBased(clip, 0)
# adjusting output color from: YUV420P8 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 23.976fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
compared to:
Code:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# source: 'C:\Users\Selur\Desktop\sample_from_DVD.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: telecine
# Loading C:\Users\Selur\Desktop\sample_from_DVD.mkv using DGSource
clip = core.dgdecodenv.DGSource("G:/Temp/mkv_6971e61a600461af6ca6ccf15732fb4f_853323747.dgi",fieldop=2)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 29.97
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)
# cropping the video to 704x480
clip = core.std.CropRel(clip=clip, left=6, right=10, top=0, bottom=0)
# Deinterlacing using TIVTC
clip = core.tivtc.TFM(clip=clip, mode=4)
clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
# make sure content is preceived as frame based
clip = core.std.SetFieldBased(clip, 0)
# adjusting output color from: YUV420P8 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 23.976fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
And the only difference between it is the source filter.
With dgdecodenv.DGSource I get wrong decimation hits.
In Avisynth I would use "clip = clip.PreRoll(Int(clip.FrameRate())" to handle this, but what to do in Vapoursynth?
I encountered this with the source from https://forum.videohelp.com/threads/...erlace-dilemma

Okay, scratch that, using PreRoll in Avisynth doesn't help either, only switching away from DGDecNV.
The question whether there is an alternative to PreRoll still remains.

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 18th December 2022 at 19:36.
Selur is offline   Reply With Quote
Old 19th December 2022, 04:38   #4764  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by Selur View Post
And the only difference between it is the source filter.
With dgdecodenv.DGSource I get wrong decimation hits.
I get similar results between avs and vpy versions of simple TIVTC script using DGSource (frames match up, but not bit identical, I think libtivtc might be taking a slightly different field on some matches, but still resulting in the same frame visually)
poisondeathray is offline   Reply With Quote
Old 20th December 2022, 21:35   #4765  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Is there another SourceFilter than DGDecNV which has 'soft telecine' (ForceFilm) handling?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 20th December 2022, 21:49   #4766  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by Selur View Post
Is there another SourceFilter than DGDecNV which has 'soft telecine' (ForceFilm) handling?
d2vsource ? RFF = False ? or DGIndex FF ?
Quote:

Unlike DGDecode, it's up to the user to apply RFF flags as they see fit, by passing rff=True to the source function, or by passing rff=False and using core.d2v.ApplyRFF(clip, d2v=r'C:\path\to\my.d2v') after calling the source function. Unless you know your source is 100% FILM, you probably want to apply these. DGDecode's traditional "Force FILM" mode isn't really present in this plugin, but if your source or part of it is 100% FILM, which is the only time you should be Force FILMing anyway, you can simply set Force FILM in DGIndex, which will set the framerate properly in the D2V file, and then not apply RFF flags. It's also feasible to trim away any non-FILM frames and still Force FILM.
Maybe ffms2 ... but rffmode might not be present in the vapoursynth version of ffms2 (or maybe it's always mode=0 ?)
poisondeathray is offline   Reply With Quote
Old 5th January 2023, 15:53   #4767  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Issue was resolved over at: https://www.rationalqm.us/board/view...php?f=8&t=1220
It was my mistake, I misunderstood how fieldop in DGSource source worked.
Instead of fieldop=2, I should have used fieldop=0. :/
(so not a bug in DGDecNV, but in my mind )

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 5th January 2023 at 15:55.
Selur is offline   Reply With Quote
Old 9th January 2023, 23:13   #4768  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
About _ColorRange prop,
I have to specify it this way: RANGE = {0:'limited', 1:'full'}, I checked Zimg and it has it the same way.
But manual has it backwards, http://www.vapoursynth.com/doc/apire...ame-properties
Could it be fixed in that documentation?
_Al_ is offline   Reply With Quote
Old 10th January 2023, 01:18   #4769  |  Link
Julek
Registered User
 
Julek's Avatar
 
Join Date: Dec 2020
Posts: 84
Quote:
Originally Posted by _Al_ View Post
About _ColorRange prop,
I have to specify it this way: RANGE = {0:'limited', 1:'full'}, I checked Zimg and it has it the same way.
But manual has it backwards, http://www.vapoursynth.com/doc/apire...ame-properties
Could it be fixed in that documentation?

Frame prop and zimg arg are different things.
1 is limited in _ColorRange prop and full in zimg arg.
__________________
CPU: AMD 3700X | GPU: RTX 3070Ti | RAM: 32GB 3200MHz
GitHub
Julek is offline   Reply With Quote
Old 10th January 2023, 19:28   #4770  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
I have to define range and matrix using strings, otherwise things are off:
Code:
print(vs.__api_version__)
clip = core.lsmas.LibavSMASHSource('YUV.mp4')
rgb1 = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s='709', range_in_s='full')
rgb2 = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s='709', range_in=0)
>>>VapourSynthAPIVersion(api_major=3, api_minor=6)
and rgb1 and rgb2 are not the same, is it an old bug? I do not have portable tkinter in portable API4 right now to quick check

Oh, I get it now, it is swapped, so if wanting to set 'limited' in props, we have to use:
Code:
API3:
clip = clip.std.SetFrameProp(prop='_ColorRange', intval=1)
API4:
clip = clip.std.SetFrameProps(_ColorRange=1)
but if wanting to specify limited range for YUV before conversion, we have to:
Code:
rgb = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s='709', range_in=0)
Wow, I wonder how many headaches this caused, I certainly was confused for a long while ... :-)

Last edited by _Al_; 11th January 2023 at 03:57.
_Al_ is offline   Reply With Quote
Old 15th January 2023, 08:55   #4771  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Trying to port CQTGMC to Vapoursynth, I started with:
Code:
def CQTGMC(clip: vs.VideoNode, Sharpness: float=0.25, thSAD1: int=192, thSAD2: int=320, thSAD3: int=128, thSAD4: int=320) -> vs.VideoNode:
  
  flip = core.std.FlipHorizontal(clip)
  flip = Padding(clip=clip,top=clip.width%64)
  flip = Padding(clip=clip,right=clip.height%64)
  padded = core.std.StackHorizontal([clip,flip])
  # todo: optional use nnedi3CL
  bobbed = core.znedi3.nnedi3(clip=padded, field=2)
  denoised = core.rgvs.RemoveGrain(clip=bobbed,mode=12)
  denoised = core.fmtc.resample(clip=denoised, kernel="gauss", w=denoised.width, h=denoised.height, scaleh=denoised.width+0.0001, interlaced=False, interlacedd=False)
  denoised = core.resize.Bicubic(clip=denoised, format=bobbed.format, dither_type="error_diffusion") # adjust format after fmtc
  denoised = core.std.Merge(clipa=denoised, clipb=bobbed,weight=0.25)
  
  srchClip = denoised
  csuper = core.mv.Super(clip=denoised);
  bvec = core.mv.Analyse(csuper,isb=True,blksize=64,overlap=32)
  fvec = core.mv.Analyse(csuper,isb=False,blksize=64,overlap=32)
  Comp1 = core.mv.Compensate(denoised,csuper,bvec,thsad=thSAD2)
  Comp2 = core.mv.Compensate(denoised,csuper,fvec,thsad=thSAD2)
  denoised = core.std.Interleave([Comp1,denoised,Comp2])
  csuper = core.vs.Super(clip=denoised)
  bvec = core.mv.Analyse(csuper,isb=True,blksize=64,overlap=32)
  fvec = core.Analyse(csuper,isb=False,blksize=64,overlap=32)
  Inter = core.mv.FlowInter(csuper,bvec,fvec,blend=False)
#   global CQTGMC_A = Inter.SelectEvery(3,0)
#   global CQTGMC_B = Inter.SelectEvery(3,1)
#   srchClip
#   ScriptClip("""
#   P = YDifferenceFromPrevious()
#   N = Trim(1,0).YDifferenceFromPrevious()
#   N < P ? CQTGMC_A : CQTGMC_B 
#   """)
#   super = MSuper()
#   bVec1 = MAnalyse(super,isb=true,overlap=4,delta=1)
#   fVec1 = MAnalyse(super,isb=false,overlap=4,delta=1)
#   bobbed 
#   super = MSuper(levels=1)
#   bComp1 = MCompensate(super,bVec1,thSAD=thSAD3)
#   fComp1 = MCompensate(super,fVec1,thSAD=thSAD3)
#   Interleave(\
#   SeparateFields(bobbed).SelectEvery(4,0),\
#   SeparateFields(fComp1).SelectEvery(4,1),\
#   SeparateFields(bComp1).SelectEvery(4,2),\
#   SeparateFields(bobbed).SelectEvery(4,3))
#   Weave()
#   #   super = MSuper(levels=1)
#   bComp1 = MCompensate(super, bVec1,thSAD=thSAD4)
#   fComp1 = MCompensate(super, fVec1,thSAD=thSAD4)
#   tMax = mt_logic(fComp1,"max",U=3,V=3).mt_logic(bComp1,"max",U=3,V=3)
#   tMin = mt_logic(fComp1,"min",U=3,V=3).mt_logic(bComp1,"min",U=3,V=3)
#   MDegrain1(super,bVec1,fVec1,thSAD=thSAD1)
#   sharpen = mt_adddiff(mt_makediff(Removegrain(20),u=3,v=3),u=3,v=3)
#   mt_clamp(sharpen,tMax,tMin,Sharpness,Sharpness,3,3,3)
#   super = MSuper(levels=1)
#   MDegrain1(super,bVec1,fVec1,thSAD=thSAD1)
#   Crop(0,0,-(input.width()%64),-(input.height()%64))
#   return last
  
# from havsfunc
def Padding(clip: vs.VideoNode, left: int = 0, right: int = 0, top: int = 0, bottom: int = 0) -> vs.VideoNode:
    if not isinstance(clip, vs.VideoNode):
        raise vs.Error('Padding: this is not a clip')

    if left < 0 or right < 0 or top < 0 or bottom < 0:
        raise vs.Error('Padding: border size to pad must not be negative')

    width = clip.width + left + right
    height = clip.height + top + bottom

    return clip.resize.Point(width, height, src_left=-left, src_top=-top, src_width=width, src_height=height)
but now I'm stuck.
Can someone tell me how to convert this part:
Code:
global CQTGMC_A = Inter.SelectEvery(3,0)
    global CQTGMC_B = Inter.SelectEvery(3,1)
    srchClip
    ScriptClip("""
    P = YDifferenceFromPrevious()
    N = Trim(1,0).YDifferenceFromPrevious()
    N < P ? CQTGMC_A : CQTGMC_B 
    """)
to Vapoursynth?

Thanks!

Cu
Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 15th January 2023, 10:12   #4772  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
SelectEvery(3,0) -> std.SelectEvery(clip=clip, cycle=2, offsets=0)
SelectEvery(3,1) -> SelectEvery(clip=clip, cycle=2, offsets=1)
YDifferenceFromPrevious() -> core.std.PlaneStats(clip, clip[0] + clip)
kedautinh12 is offline   Reply With Quote
Old 15th January 2023, 10:33   #4773  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Okay, but why:
Code:
SelectEvery(3,0) -> std.SelectEvery(clip=clip, cycle=2, offsets=0)
shouldn't cycle stay 3 ?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 15th January 2023, 10:45   #4774  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
Quote:
Originally Posted by Selur View Post
Okay, but why:
Code:
SelectEvery(3,0) -> std.SelectEvery(clip=clip, cycle=2, offsets=0)
shouldn't cycle stay 3 ?
Lol, i'm forgot change that, sr
kedautinh12 is offline   Reply With Quote
Old 15th January 2023, 12:03   #4775  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Okay. Thanks
Opened a separate thread for the porting. https://forum.doom9.org/showthread.php?p=1981140

Cu
Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 30th January 2023, 22:47   #4776  |  Link
~ VEGETA ~
The cult of personality
 
~ VEGETA ~'s Avatar
 
Join Date: May 2013
Location: Planet Vegeta
Posts: 155
I've been trying to use fvf insertsign to overlay a lagarith .avi with alpha on top of my video. however, it does not work.

how can i specify it right so that it takes the alpha channel properly?

I used the same files with avs and it worked... i think i am missing something related to telling vs about the alpha channel?

the logo appears but without being overlayed properly

Last edited by ~ VEGETA ~; 30th January 2023 at 23:47.
~ VEGETA ~ is offline   Reply With Quote
Old 31st January 2023, 00:05   #4777  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
havsfunc could be used:
import havsfunc
clip=havsfunc.Overlay(clip1,clip2,mask=alpha)
https://github.com/HomeOfVapourSynth...sfunc.py#L5960
_Al_ is offline   Reply With Quote
Old 31st January 2023, 02:31   #4778  |  Link
Julek
Registered User
 
Julek's Avatar
 
Join Date: Dec 2020
Posts: 84
Quote:
Originally Posted by ~ VEGETA ~ View Post
I've been trying to use fvf insertsign to overlay a lagarith .avi with alpha on top of my video. however, it does not work.

how can i specify it right so that it takes the alpha channel properly?

I used the same files with avs and it worked... i think i am missing something related to telling vs about the alpha channel?

the logo appears but without being overlayed properly
https://github.com/Irrational-Encodi...vsfunc/pull/12
__________________
CPU: AMD 3700X | GPU: RTX 3070Ti | RAM: 32GB 3200MHz
GitHub
Julek is offline   Reply With Quote
Old 31st January 2023, 15:46   #4779  |  Link
~ VEGETA ~
The cult of personality
 
~ VEGETA ~'s Avatar
 
Join Date: May 2013
Location: Planet Vegeta
Posts: 155
Quote:
Originally Posted by _Al_ View Post
havsfunc could be used:
import havsfunc
clip=havsfunc.Overlay(clip1,clip2,mask=alpha)
https://github.com/HomeOfVapourSynth...sfunc.py#L5960
overlay succeeded but the result was bad, the alpha overlay is not good. it didn't get completely transparent as it should be.

also, it does not have options to specify ranges.

also:

video1= lvf.misc.overlay_sign(clip=video1,overlay=fixed_logo,frame_ranges=[8508,8655])

didn't work and put this: https://pastebin.com/GSZRYLqi

first it didn't accept 2 colorspaces as alpha clip in RGBA, so I did:

Code:
video1= lsmash...
fixed_logo  = core.ffms2.Source(source=path..., alpha=True)
fixed_logo = core.resize.Bilinear(fixed_logo, format=vs.YUV420P8, matrix_s="709")
video1= lvf.misc.overlay_sign(clip=video1,overlay=fixed_logo,frame_ranges=[8508,8655])
but it still showed the error above.

On insertsign side, I still cannot use it even after modifying it with the mentioned commit manually in scripts folder.
~ VEGETA ~ is offline   Reply With Quote
Old 31st January 2023, 16:16   #4780  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Quote:
Originally Posted by ~ VEGETA ~ View Post
overlay succeeded but the result was bad, the alpha overlay is not good. it didn't get completely transparent as it should be.
Make mask a grayscale clip with only values 0 or 255 (for 8bits). You can use Levels or Expr to make it from your logo.
_Al_ 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 23:19.


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