View Full Version : Apply filter to specific frame ranges?
magnetite
25th March 2020, 18:48
I want to filter a specific range of frames on a X-Files Blu-ray episode I have. The non-filtered frames are fine. The filtered frames are essentially missing film they couldn't find for the remaster. So they used the NTSC master tapes instead.
Here's what I have:
LoadPlugin("C:\MeGUI 64-bit\tools\dgindexnv\DGDecodeNV.dll")
DGSource("G:\Temp\tfarfiov.brm\The Host.dgi")
ConvertBits(8)
part1=Trim(0,29869)
part2=Trim(29870,31002).TemporalDegrain2().FFT3DFilter(sigma=50, plane=3, bt=3)
part3=Trim(31003,62599)
part4=Trim(62600,63135).TemporalDegrain2().FFT3DFilter(sigma=5, plane=3, bt=3)
part5=Trim(63136,63296).TemporalDegrain2().FFT3DFilter(sigma=50, plane=3, bt=3)
part6=Trim(63297,65028)
return part1++part2++part3++part4++part5++part6
return last
Prefetch(8)
I wanted to try using the ApplyRange filter for this, because it looks cleaner than all this cutting with Trim. However, whenever I tried to use it, it kept throwing me errors like invalid arguments to ApplyRange, and something like that.
StainlessS
25th March 2020, 19:09
Something like this (Untested)
/*
part1=Trim(0,29869)
part2=Trim(29870,31002).TemporalDegrain2().FFT3DFilter(sigma=50, plane=3, bt=3)
part3=Trim(31003,62599)
part4=Trim(62600,63135).TemporalDegrain2().FFT3DFilter(sigma=5, plane=3, bt=3)
part5=Trim(63136,63296).TemporalDegrain2().FFT3DFilter(sigma=50, plane=3, bt=3)
part6=Trim(63297,65028)
*/
Function MyFunc(clip c,Float Sigma,Int Plane,Int bt) { return c.TemporalDegrain2.FFT3DFilter(sigma=Sigma, plane=Plane,bt=bt) }
Colorbars(pixel_type="YV12")
ApplyRange(29870,31002,"MyFunc",50.0,3,3)
ApplyRange(62600,63135,"MyFunc", 5.0,3,3)
ApplyRange(63136,63296,"MyFunc",50.0,3,3)
Prefetch(8) # Before Return
return last
EDIT: Or maybe (again untested)
Function MyFunc_1(clip c) { return c.TemporalDegrain2.FFT3DFilter(sigma=50.0, plane=3,bt=3) }
Function MyFunc_2(clip c) { return c.TemporalDegrain2.FFT3DFilter(sigma= 5.0, plane=3,bt=3) }
Colorbars(pixel_type="YV12")
ApplyRange(29870,31002,"MyFunc_1")
ApplyRange(62600,63135,"MyFunc_2")
ApplyRange(63136,63296,"MyFunc_1")
Prefetch(8) # Before Return
return last
magnetite
25th March 2020, 21:38
Oh, so that's how it works. I had written something like this, because I was reading off the wiki page (http://avisynth.nl/index.php/ApplyRange#ApplyRange_Examples):
ApplyRange(29870,31002,"FFT3DFilter",sigma=50,plane=3,bt=3)
StainlessS
25th March 2020, 21:55
I only did it as separate functions so as to show use of multiple filters applied via ApplyRange [incl the TemporalDegrain2() thing] [EDIT: also see post #5].
You could also use eg ClipClop() or RemapFramesSimple().
EDIT: Again untested (ClipClop):- https://forum.doom9.org/showthread.php?t=162266
Colorbars(pixel_type="YV12")
# Up to 255 FXn clips supported
FX1 = TemporalDegrain2.FFT3DFilter(sigma=50.0, plane=3,bt=3) # Replacement clip No 1
FX2 = TemporalDegrain2.FFT3DFilter(sigma= 5.0, plane=3,bt=3) # Replacement clip No 2
Nicks = """ # NickNames used in preference to clip index's
Filter_1 = 1 # Pseudonym for clip index 1 ie FX1, can use in SCMD
Filter_2 = 2
"""
# Below, can use NickNames eg "Filter_1 29870,31002" instead of "1 29870,31002"
SCMD = """
Filter_1 29870,31002 # or eg 1 29870,31002 # clip index 1, if not using nicknames, ie FX1
Filter_2 62600,63135 # or eg 2 62600,63135
Filter_1 63136,63296 # or eg 1 63136,63296
"""
SHOW=False
ClipClop(Last,FX1,FX2,scmd=SCMD,show=SHOW,Nickname=Nicks)
EDIT: Or example from ClipClop thread:
Example usage script using NickNames:
###
Avisource("D:\avs\test.avi")
ORG=Last
V1 = FFT3DFilter(Plane=0,Sigma=1.6) # Light Luma
V2 = FFT3DFilter(Plane=0,Sigma=2.0) # Med Luma
V3 = FFT3DFilter(Plane=0,Sigma=4.0) # High Luma
V4 = FFT3DFilter(Plane=3,Sigma=1.6) # Light Chroma
V5 = FFT3DFilter(Plane=3,Sigma=2.0) # Med Chroma
V6 = FFT3DFilter(Plane=3,Sigma=4.0) # High Chroma
V7 = FFT3DFilter(Plane=4,Sigma=1.6) # Light Luma+Chroma
V8 = FFT3DFilter(Plane=4,Sigma=2.0) # Med Luma+Chroma
V9 = FFT3DFilter(Plane=4,Sigma=4.0) # High Luma+Chroma
V10= FlipHorizontal() # Flip-H
V11= FlipVertical() # Flip-V
V12= Invert() # Invert
NickNames =""" # Psuedonyms for clips (clip index number)
L0 = 1 # Light Luma
L1 = 2 # Med Luma
L2 = 3 # High Luma
C0 = 4 # Light Chroma
C1 = 5 # Med Chroma
C2 = 6 # High Chroma
LC0 = 7 # Light Luma + Chroma
LC1 = 8 # Med Luma + Chroma
LC2 = 9 # High Luma + Chroma
FH = 10 # Flip-H
FV = 11 # Flip-V
INV = 12 # Invert
"""
SCMD=""" # Clip editing commands in string, can also use commands in file
C0 0,99 # Light Chroma frames @ 0 -> 99
L0 100,-200 # Light Luma frames @ 100, 200 frames ie frames 100->299
INV 300,399 # Invert 300->399
L0 400,499 # Light Luma frames 400->499
FH 500,599 # Flip-H 500->599
LC2 600,699 # High Luma + Chroma
C1 800 # Med Chroma, Single frame
1 900,999 # Light Luma, We used the clip number instead of a NickName
FV 1000,1099 # Flip-V
LC1 2000,0 # Med Luma + Chroma, 2000 -> lastframe
"""
SHOW=True
ClipClop(ORG,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,scmd=SCMD,nickname=NickNames,show=SHOW)
StainlessS
26th March 2020, 13:21
Oh, so that's how it works. I had written something like this, because I was reading off the wiki page (http://avisynth.nl/index.php/ApplyRange#ApplyRange_Examples):
ApplyRange(29870,31002,"FFT3DFilter",sigma=50,plane=3,bt=3)
Sorry, I should have said, I think that you cannot use named args for ApplyRange() and Animate(), you have to supply all args in Filter argument order, up to the last one that you use and supply defaults for
those you are not using, eg
/*
FFT3DFilter(clip, float "sigma", float "beta"=1.0, int "plane", int "bw"=48, int "bh"=48, int "bt", int "ow", int "oh", float "kratio", float "sharpen", float "scutoff",
\ float "svr", float "smin", float "smax", bool "measure", bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow", float "pcutoff",
\ float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", float "hr", float "ht", int "ncpu")
*/
ApplyRange(29870,31002,"FFT3DFilter",50.0,1.0,3,48,48,3)
EDIT: So above, Blue are the args you want to use, and Red are the defaulted in-between ones, Purple the ones you dont have to provide.
Using script functions makes it easier to use where you can use named args within script functions, and call script function with only the args you are interested in using. [as in post #2]
EDIT: I dont think that I have read above anywhere, was my conclusion after spending some time failing to get named args working with ApplyRange/Animate.
Gavino
26th March 2020, 19:03
Hi Mr S!
You don't have to supply all args, you can stop at the last non-default one you use.
See here.
(Keep safe, everyone...)
StainlessS
26th March 2020, 19:37
you have to supply all args in order, up to the last one that you use[/COLOR]
and supply defaults for those you are not using
Again, up to the last arg that you use.
Above was intended to mean exactly what you said big G.
And you be keeping yourself safe tooooo.
You can come back you know, you cant catch the nasty thingy on-line :)
EDIT: Would probably be a good idea to note above on Wiki.
Something like below, could probably be worded better.
You have to supply all args in filter argument order, up to the last one that you want to use, and supply the filter defaults for those in-between args that you are not using.
You don't have to supply all args, you can stop at the last non-default one you use.
Gavino
26th March 2020, 19:46
Again, up to the last arg that you use.
Above was intended to mean exactly what you said big G.
Ah, sorry SS, I missed that bit as it was scrolled off the right of my screen. :(
Keep up the good work!!!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.