Log in

View Full Version : Apply a Filter at Regular Intervals


Monkeylord
14th August 2012, 20:03
I have a clip where when I IVTC it the chroma gets messed up every 4th frame. For some reason it includes the chroma from the previous frame.

I added the following line to my script;

mergechroma(selectevery(1,1))

This fixes the frames where the errant chroma is introduced, but obviously screws up all the previously good ones.

What's my best method of applying the above line but tell it to only occur every 4th frame?

I messed around with the "selectevery" portion of the line, but the slightest change would introduce chroma from all manner of frames.


I really need to find an idiots guide to avisynth filter use/syntax, lol.

cretindesalpes
14th August 2012, 20:18
fixed = mergechroma(selectevery(1,1))
Interleave (last, fixed)
SelectEvery (8, 0, 2, 4+1, 6)

Move the "+1" on the frame you want to fix.

Monkeylord
14th August 2012, 20:33
fixed = mergechroma(selectevery(1,1))
Interleave (last, fixed)
SelectEvery (8, 0, 2, 4+1, 6)

Move the "+1" on the frame you want to fix.

Thanks,

Just so I can learn from this, what do the 8, 0, 2, 4+1 and 6 represent.

I take it the 4+1 is the frame multiple the filter is being applied to.


Sorry to be a pain, but I'd like to understand rather than just beg for help :)

Thanks

cretindesalpes
14th August 2012, 20:51
I interleaved the original clip and the fixed clip. Therefore the even frames are the original ones and the odd frames the fixed ones. Each group of 4 frames result in a group of 8 frames. Then we just have to pick 4 frames per group of 8, the original or the fixed frame in each pair. In my example:

Original:
… a b c d …

Fixed:
… A B C D …

-- Interleave ->

… a A b B c C d D …
0 1 2 3 4 5 6 7
^ ^ ^ ^

-- SelectEvery ->

… a b C d …

I hope it is more clear with this diagram.

Monkeylord
14th August 2012, 20:53
Genius!


Much clearer now, thanks again!

Monkeylord
14th August 2012, 22:51
Hmmm... it doesn't seem to be working.

I mean, it is moving chromas around, but I can't get it to apply to the fields I want.

Should I add this before or after the IVTC? and also I forgot that I added a trim function to the end, which is why it looked to me that it started on frame 4 and repeated every 4 frames, but in actual fact (after IVTC) it starts on frame 2.


I'm getting so confused.


Here's the original script that when opened in Virtualdub shows the dodgy chroma every 4 frames.

If I get rid of the Trim function, and I skip past all the opening gumph to the actual movie, it still shows the chroma problem every 4 frames. Calculating backwards leads me to the problem first appearing on frame No 2.

#Audio
A=NicAC3Source("F:\Main Movie\VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")

#Video
V=DGDecode_mpeg2source("F:\Main Movie\VTS_01_1.d2v", info=3)

#Merge
Audiodub(V,A)

AssumeBFF()
TFM()
tdecimate(mode=1)

#Subs
VobSub("F:\Main Movie\VTS_01_0.idx")

#Trim
__film = last
__t0 = __film.trim(498, 115250)
__t0

Here's the one that fixes the dodgy chroma frames but screws up all the previously good frames.

#Audio
A=NicAC3Source("F:\Main Movie\VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")

#Video
V=DGDecode_mpeg2source("F:\Main Movie\VTS_01_1.d2v", info=3)

#Merge
Audiodub(V,A)

AssumeBFF()
TFM()
tdecimate(mode=1)
fixed = mergechroma(selectevery(1,1))

#Subs
VobSub("F:\Main Movie\VTS_01_0.idx")

#Trim
__film = last
__t0 = __film.trim(498, 115250)
__t0

Is it feasible (and ultimately easier) if I dump my original AVS in Virtualdub, including the dodgy frames, save to a lossless AVI (lagarith, I spose) and then use that as the source in a new AVS that includes the above suggested fix?

Obviously I'd rather not do any more passes than necessary, but it's driving me bonkers at this point.

IanB
15th August 2012, 00:49
Temporarily Subtitle the fixed version and comment out the SelectEvery. Examine the double rate clip to determine the pattern you need to achieve your desired result. This is called stepwise debugging of your script.#Audio
A=NicAC3Source("F:\Main Movie\VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")

#Video
V=DGDecode_mpeg2source("F:\Main Movie\VTS_01_1.d2v", info=3)

#Merge
Audiodub(V,A)

AssumeBFF()
TFM()
tdecimate(mode=1)
fixed = mergechroma(selectevery(1,1)).Subtitle("Fixed")
Interleave (last, fixed)
# SelectEvery (8, 0, 2, 4+1, 6)When you have the right pattern reactive the SelectEvery with the right numbers. Test, rinse, repeat as required. Finally remove the Subtitle and add back the tail of your script. Test, rinse, repeat as required.

Monkeylord
15th August 2012, 00:52
Thanks for the advice. I'll give it a shot.



... it's gonna be a loooong night! :D