View Full Version : Apply filters to different segments
Bluedraft
1st April 2024, 22:41
Hello, I need to apply some filters to different parts of a video, these are the segments and the filters to apply
9414-12897 mClean
20799-21008 f3kdb Neo
22727-32001 mClean
36902-37071 mClean
42534-45354 mClean
47349-47894 SMDegrain
47895-51022 mClean
52771-54297 mClean
56833-57076 mClean
60841-61341 SMDegrain
61550-68318 mClean
71004-71762 SMDegrain
73551-76972 SMDegrain
78804-79569 neo_f3kdb
80854-81520 mClean
82504-84289 SMDegrain
84785-85576 Spotless
88640-90931 SMDegrain
93481-97177 SMDegrain
99952-101543 SMDegrain
107042-107469 mClean
110778-110474 SMDegrain
11449-114220 SMDegrain
114637-114868 mClean
114869-115165 SMDegrain
121607-122577 SMDegrain
123517-123716 SMDegrain
123717-124310 mClean
124311-126070 SMDegrain
127144-127360 SMDegrain
128430-131478 SMDegrain
131479-132287 mClean
These are the filters settings
neo_f3kdb(preset="high", output_depth=8)
SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
Total number of frames in the clip; 140.772
Could someone help me to create the script?, I've no idea how to do it. Thanks in advance for any help.
Dogway
1st April 2024, 23:37
You generally use ClipClop.
ClipClop(r1,sCMD="r1(1081,1934); r1(2251,2538); r1(2960,3818); r1(12046,12478); r1(12903,16155)")
This case is for two clips, but you can add more (r2,r3...) and set the ranges as with r1.
Arx1meD
2nd April 2024, 11:42
p1 = last.Trim(9414,12897).mClean(...)
p2 = last.Trim(20799,21008).f3kdb(...)
p3 = last.Trim(22727,32001).mClean(...)
...
p32 = last.Trim(131479,132287).mClean(...)
p1+p2+p3+...+p32
wonkey_monkey
2nd April 2024, 13:01
p1 = last.Trim(9414,12897).mClean(...)
p2 = last.Trim(20799,21008).f3kdb(...)
p3 = last.Trim(22727,32001).mClean(...)
...
p32 = last.Trim(131479,132287).mClean(...)
p1+p2+p3+...+p32
Better to instantiate each filter just once:
cleaned = last.mClean()
debanded = last.f3kdb()
degrained = last.SMDegrain()
untouched = last
cleaned.trim(9414,12897) + untouched.trim(12896,20778) + debanded.trim(20799,21008) + untouched.trim(21009,22736) + cleaned.trim(22727,32001) + ... + cleaned.trim(131479,132287)
ClipClop would be neater though, and a lot easier to make changes to, perhaps with one call per filter for readability.
Bluedraft
3rd April 2024, 02:41
Thanks to all for your help
@Dogway
I should read more about clipclop, I don't really know how to use it. I'm trying to make this script to use with staxrip, I don't know if I can use clipclop with stasxrip.
@Arx1meD
Something like this?
tcFile = "%temp_file%_timestamps.txt" # timestamps file path
Exist(tcFile) ? FFVideoSource("%source_file%", cachefile="%source_temp_file%.ffindex", timecodes=tcFile) : FFVideoSource("%source_file%", cachefile="%source_temp_file%.ffindex")
Import("C:\Users\User4459\Downloads\Portables\StaxRip 2.12\Apps\Plugins\AVS\Spotless.avsi")
p1 = last.Trim(0-9413)
p2 = last.Trim(9414-12897).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p3 = last.Trim(12898-20798)
p4 = last.Trim(20799-21008).neo_f3kdb(preset="high", output_depth=8)
p5 = last.Trim(21009-22726)
p6 = last.Trim(22727-32001).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p7 = last.Trim(32002-36901)
p8 = last.Trim(36902-37071).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p9 = last.Trim(37072-42533)
p10 = last.Trim(42534-45354).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p11 = last.Trim(45355-47348)
p12 = last.Trim(47349-47894).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p13 = last.Trim(47895-51022).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p14 = last.Trim(51023-52770)
p15 = last.Trim(52771-54297).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p16 = last.Trim(54298-56832)
p17 = last.Trim(56833-57076).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p18 = last.Trim(57077-60840)
p19 = last.Trim(60841-61341).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p20 = last.Trim(61342-61549)
p21 = last.Trim(61550-68318).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p22 = last.Trim(68319-71003)
p23 = last.Trim(71004-71762).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p24 = last.Trim(71763-73550)
p25 = last.Trim(73551-76972).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p26 = last.Trim(76973-78803)
p27 = last.Trim(78804-79569)neo_f3kdb(preset="high", output_depth=8)
p28 = last.Trim(79570-80853)
p29 = last.Trim(80854-81520).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p30 = last.Trim(81521-82503)
p31 = last.Trim(82504-84289).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p32 = last.Trim(84290-84784)
p33 = last.Trim(84785-85576).Spotless()
p34 = last.Trim(85577-88639)
p35 = last.Trim(88640-90931).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p36 = last.Trim(90932-93480)
p37 = last.Trim(93481-97177).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p38 = last.Trim(97178-99951)
p39 = last.Trim(99952-101543).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p40 = last.Trim(101544-107041)
p41 = last.Trim(107042-107469).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p42 = last.Trim(107470-110777)
p43 = last.Trim(110778-114220).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p45 = last.Trim(114221-114636)
p47 = last.Trim(114637-114868).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p48 = last.Trim(114869-115165).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p50 = last.Trim(115166-121606)
p51 = last.Trim(121607-122577).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p52 = last.Trim(122578-123516)
p53 = last.Trim(123517-123716).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p54 = last.Trim(123717-124310).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p55 = last.Trim(124311-126070).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p56 = last.Trim(126071-127143)
p57 = last.Trim(127144-127360).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p58 = last.Trim(127361-128429)
p59 = last.Trim(128430-131478).SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
p60 = last.Trim(131479-132287).mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
p61 = last.Trim(132288-140772)
p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 + p11 + p12 + p13 + p14 + p15 + p16 + p17 + p18 + p19 + p20 + p21 + p22 + p23 + p24 + p25 + p26 + p27 + p28 + p29 + p30 + p31 + p32 + p33 + p34 + p35 + p36 + p37 + p38 + p39 + p40 + p41 + p42 + p43 + p44 + p45 + p46 + p47 + p48 + p49 + p50 + p51 + p52 + p53 + p54 + p55 + p56 + p57 + p58 + p59 + p60 + p61
@wonkey_monkey
Or like this
tcFile = "%temp_file%_timestamps.txt" # timestamps file path
Exist(tcFile) ? FFVideoSource("%source_file%", cachefile="%source_temp_file%.ffindex", timecodes=tcFile) : FFVideoSource("%source_file%", cachefile="%source_temp_file%.ffindex")
Import("C:\Users\User4459\Downloads\Portables\StaxRip 2.12\Apps\Plugins\AVS\Spotless.avsi")
cleaned = last.mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
debanded = last.neo_f3kdb(preset="high", output_depth=8)
degrained = last.SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
spotless = last.Spotless()
untouched = last
untouched.Trim(0-9413) + cleaned.Trim(9414-12897) + untouched.Trim(12898-20798) + debanded.Trim(20799-21008) + untouched.Trim(21009-22726) + cleaned.Trim(22727-32001) + untouched.Trim(32002-36901) + cleaned.Trim(36902-37071) + untouched.Trim(37072-42533) + cleaned.Trim(42534-45354) + untouched.Trim(45355-47348) + degrained.Trim(47349-47894) + cleaned.Trim(47895-51022) + untouched.Trim(51023-52770) + cleaned.Trim(52771-54297) + untouched.Trim(54298-56832) + cleaned.Trim(56833-57076) + untouched.Trim(57077-60840) + degrained.Trim(60841-61341) + untouched.Trim(61342-61549) + cleaned.Trim(61550-68318) + untouched.Trim(68319-71003) + degrained.Trim(71004-71762) + untouched.Trim(71763-73550) + degrained.Trim(73551-76972) + untouched.Trim(76973-78803) + debanded.Trim(78804-79569) + untouched.Trim(79570-80853) + cleaned.Trim(80854-81520) + untouched.Trim(81521-82503) + degrained.Trim(82504-84289) + untouched.Trim(84290-84784) + spotless.Trim(84785-85576) + untouched.Trim(85577-88639) + degrained.Trim(88640-90931) + untouched.Trim(90932-93480) + degrained.Trim(93481-97177) + untouched.Trim(97178-99951) + degrained.Trim(99952-101543) + untouched.Trim(101544-107041) + cleaned.Trim(107042-107469) + untouched.Trim(107470-110777) + degrained.Trim(110778-114220) + untouched.Trim(114221-114636) + cleaned.Trim(114637-114868) + degrained.Trim(114869-115165) + untouched.Trim(115166-121606) + degrained.Trim(121607-122577) + untouched.Trim(122578-123516) + degrained.Trim(123517-123716) + cleaned.Trim(123717-124310) + degrained.Trim(124311-126070) + untouched.Trim(126071-127143) + degrained.Trim(127144-127360) + untouched.Trim(127361-128429) + degrained.Trim(128430-131478) + cleaned.Trim(131479-132287) + untouched.Trim(132288-140772)
Arx1meD
3rd April 2024, 07:09
Bluedraft, yes. Both methods are correct.
You missed the point:
p27 = last.Trim(78804-79569)neo_f3kdb(preset="high", output_depth=8)
It must be:
p27 = last.Trim(78804-79569).neo_f3kdb(preset="high", output_depth=8)
Trim(0-9413) It must be Trim(0,9413) for all Trim(...)
Bluedraft
3rd April 2024, 11:42
Great, thank you Arx1meD!
Bluedraft
3rd April 2024, 12:23
Last question, where do I should put
SetFilterMTMode("DEFAULT_MT_MODE", 2)
Prefetch(16)
in order to speed up the encoding, right now some filters are using only one cpu core
Arx1meD
3rd April 2024, 12:43
Bluedraft, about multithreading read this (http://avisynth.nl/index.php/AviSynth%2B#Multithreading_.28MT.29_Notes).
When you use many parts P1+P2+P3+... using Prefetch(...) can cause an error or overflow of RAM.
coolgit
3rd April 2024, 15:52
Last question, where do I should put
SetFilterMTMode("DEFAULT_MT_MODE", 2)
Prefetch(16)
in order to speed up the encoding, right now some filters are using only one cpu core
You can use this https://publishwith.me/ep/pad/view/ro.rDkwcdWn4k9/latest instead of typing out setfiltermtmode blah blah
DL txt file.
Open notepad ++ language avisynth
save as MtModes.avsi
put copy in plugins+ and plugins64+ folder
Prefetch at the bottom of script.
StvG
3rd April 2024, 18:04
I'm surprised that there is no mention of the internal ConditionalFilter (http://avisynth.nl/index.php/ConditionalFilter)+ConditionalReader (http://avisynth.nl/index.php/ConditionalReader).
Bluedraft
3rd April 2024, 20:40
One more question; if I wanted to apply the deband and degrain filter to the same segment how should I write it?
I'm using the format of the 2nd script
cleaned = last.mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
debanded = last.neo_f3kdb(preset="high", output_depth=8)
degrained = last.SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
spotless = last.Spotless()
untouched = last
untouched.Trim(0,9413) + cleaned.Trim(9414,12897)...
I tried "degrained.debanded.Trim(82504,84289)" but it gave me
Script error: There is no function named 'debanded'.
Bluedraft
3rd April 2024, 21:46
I think this may work, I'm not getting error now :)
debanded = last.neo_f3kdb(preset="high", output_depth=8)
degrained = last.SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
degrainedlight = last.SMDegrain(tr=1, thSAD=300, contrasharp=true)
degraindeband = last.SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true).neo_f3kdb(preset="high", output_depth=8)
degrainldeband = last.SMDegrain(tr=1, thSAD=300, contrasharp=true).neo_f3kdb(preset="high", output_depth=8)
spotless = last.Spotless()
untouched = last
untouched.Trim(0,9413) + degrainldeband.Trim(9414,12897)...
wonkey_monkey
3rd April 2024, 21:47
degrained_and_debanded = degrained.neo_f3kdb(preset="high", output_depth=8)
or
degrained_and_debanded = debanded.SMDegrain(tr=6, thSAD=600, contrasharp=true, refinemotion=true)
depending on which order you want the filters to be applied.
Bluedraft
5th April 2024, 00:20
Wonderful, thank you wonkey_monkey!
hello_hello
6th April 2024, 14:33
I find appending segments like this:
p1 + p2 + p3 + p4 + p5 + p6
Tends to make my brain hurt if I need to modify or insert/delete a Trim. I'm easily confused.
A = Last
M = A.mClean(thSAD=400, chroma=true, sharp=10, rn=14, deband=4, depth=0, strength=20)
F = A.neo_f3kdb(preset="high", output_depth=8)
A.Trim(0, 9413) + \
M.Trim(9414, 12897) + \
A.Trim(12898, 20798) + \
F.Trim(20799, 21008) + \
A.Trim(21009, 22726) + \
M.Trim(22727, 32001) + \
A.Trim(32002, 36901) + \
M.Trim(36902, 37071)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.