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. |
![]() |
#4761 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
Okay,
Avisynth: Code:
Mt_AddDiff(Blurred, ReconstructedMedian) Vapoursynth: Code:
core.std.MergeDiff(Blurred, ReconstructedMedian)) Code:
MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 " , expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) Vapoursynth: Code:
partial_expr = lambda M, N: f" x x[{M},{N}] - x x[{M},{N}] - x x[{M},{N}] - abs 1 + * x x[{M},{N}] - abs 1 + {THR} 1 >= {thr_s} 0.5 pow {THR} ? + / - 128 + " medianDiff = core.akarin.Expr(diff, [partial_expr(0,0) + partial_expr(1,0) + partial_expr(-1,0) + "sort3 drop swap drop", ""]) => But how to convert, Avisynth Code:
Mt_Convolution(Horizontal=" 1 1 0 0 1 0 0 1 1 ", vertical = " 1 ", u=1, v=1) Cu Selur |
![]() |
![]() |
![]() |
#4762 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
got it,
Code:
clip.std.Convolution(matrix=[ 1, 1, 0, 0, 1, 0, 0, 1, 1 ], mode='v', planes=[0]) Uploaded it to: https://github.com/Selur/Vapoursynth...r/fromDoom9.py Cu Selur Last edited by Selur; 31st October 2022 at 10:51. |
![]() |
![]() |
![]() |
#4763 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,497
|
R61-RC1 is out. Bug fixes only.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
![]() |
![]() |
![]() |
#4765 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,497
|
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
![]() |
![]() |
![]() |
#4768 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
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() 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() 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 Last edited by Selur; 18th December 2022 at 19:36. |
![]() |
![]() |
![]() |
#4769 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,160
|
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)
|
![]() |
![]() |
![]() |
#4771 | Link | ||
Registered User
Join Date: Sep 2007
Posts: 5,160
|
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#4772 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
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 Last edited by Selur; 5th January 2023 at 15:55. |
![]() |
![]() |
![]() |
#4773 | Link |
Registered User
Join Date: May 2011
Posts: 273
|
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? |
![]() |
![]() |
![]() |
#4774 | Link | |
Registered User
Join Date: Dec 2020
Posts: 80
|
Quote:
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 Discord: @Julek#9391 || GitHub |
|
![]() |
![]() |
![]() |
#4775 | Link |
Registered User
Join Date: May 2011
Posts: 273
|
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) 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) Code:
rgb = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s='709', range_in=0) Last edited by _Al_; 11th January 2023 at 03:57. |
![]() |
![]() |
![]() |
#4776 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
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) 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 """) Thanks! Cu Selur |
![]() |
![]() |
![]() |
#4780 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,959
|
Okay. Thanks
![]() Opened a separate thread for the porting. https://forum.doom9.org/showthread.php?p=1981140 Cu Selur |
![]() |
![]() |
![]() |
Tags |
speed, vaporware, vapoursynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|