Log in

View Full Version : IVTC but ignoring part of the video frame from pattern search?


Stereodude
28th November 2011, 18:34
Is there any way to do an automated IVTC using TFM, Telecide, or similar but ignore certain pixel areas of the input video? I'm thinking of things like station logos or in frame popover advertisements / message that are interlaced content superimposed on top of telecined film based content. When the film based content has little motion and the superimposed interlaced video portion is moving around the proper fields to reconstruct the tend to be misdetected leaving interlaced fields in the output.

I'm thinking of something like being able to load an alpha mask from a .png and anything masked out is omitted from the pattern search. This would allow the logos or advertisements to be masked from the pattern search and allow the IVTC to work correctly on the underlying film content.

Is there a way to do this with any existing plugins?

Thanks!

TheRyuu
28th November 2011, 19:49
Requires two passes:
Pass 1:
Crop video (no superimposed stuff) -> feed to tfm -> specify output file.

Pass 2:
Call tfm with the override file set to the output file you made from pass 1 on the whole video.

You can also do some magic with y0/y1 params too although that won't work horizontally (or so people tell me).

cretindesalpes
28th November 2011, 20:34
Another solution (single pass):

# Your source here
h = Height ()
m = ImageSource("mask.png", end=FrameCount()-1).ShowRed ("YV12")
c = mt_merge (last, m, m, luma=true)
StackVertical (c, last)
TFM (y0=h, y1=h*2-1)
Crop (0, h, 0, 0)

You'll have to define a mask file where the masked parts are pure white, and valid parts pure black.

Stereodude
28th November 2011, 20:59
Thanks! I'll give these a try later today when I get home from work.

Stereodude
29th November 2011, 04:19
Another solution (single pass):

# Your source here
h = Height ()
m = ImageSource("mask.png", end=FrameCount()-1).ShowRed ("YV12")
c = mt_merge (last, m, m, luma=true)
StackVertical (c, last)
TFM (y0=h, y1=h*2-1)
Crop (0, h, 0, 0)

You'll have to define a mask file where the masked parts are pure white, and valid parts pure black.This worked well. I am impressed by your guru like knowledge of how to work magic with AVIsynth.

I modified it a little bit to further what I was after.

inputvid=MPEG2Source("videoclip.d2v", idct=5, moderate_h=40, moderate_v=80, cpu2="xxoooo")
h = inputvid.Height()
m = ImageSource("frame_mask.png", end=FrameCount(inputvid)-1).ShowRed("YV12")
c = mt_merge(inputvid, m, m, luma=true)
composite=StackVertical(c1, inputvid).TFM(d2v="videoclip.d2v", y0=h, y1=h*2-1,mode=5, PP=0)

full=composite.crop(0, h, -0, -0)
masked=composite.crop(0, 0, -0, -h)
output=masked.tdecimate(mode=0, clip2=full)
output
Thanks for the help!