Log in

View Full Version : Tricky case: restore resized interlaced video


Tima
26th February 2009, 23:11
Hi all!

Sorry, if this question has already been answered, but I couldn't find any similar topic.

Input:
There was 29,970 interlaced source, which has been resized from 720x576 to 720x531 (!) with no IVTC (!!) in AssumeFrameBased (!!!) mode. I have only this result.

Question:
What's the best approach to recover 23.976 progressive source from that clip? Custom IVTC may be needed, so how can I at least recover proper fields?

Here's a screenshot of my source:

http://img413.imageshack.us/img413/8002/76156255.png

Blue_MiSfit
27th February 2009, 00:29
Good luck!

I think it's been forever destroyed :(

~MiSfit

Tima
27th February 2009, 01:48
Look at the screenshot. Maybe it's not that hopeless?..

Alex_ander
27th February 2009, 09:57
You can't restore it completely, but (only assuming it was telecined film) you can try to repair it using one of the 2 methods:
1.Kill vertical resolution with VerticalReduceBy2() for blending fields, then resize back and apply a deblending script like FixBlendIVTC or SRestore. You could apply VerticalReduceBy2() to interlaced frames only (using some frame separation tools) but unlikely deblending would work properly with sharp+blurred frames.
2.(not as simple as method 1, but probably better) Replace the 2 interlaced frames in the pattern of 5 with an interpolated frame (from 2 original progressive) to get something close to IVTC (you actually replace 1 lost original frame of 4 in pre-telecine source at that). Here is an illustration. Now you have cycles with 3 progressive frames + 2 spoiled interlaced ones:

-p1p2i3i4p5-p1p2i3i4p5-p1p2i3i4p5-

If those interlaced frames were good, you'd restore the missing original frame in place of those 2 interlaced and get 23.976. But now best you can do is to interpolate that frame from p2 and p5. There is a function MFlowInter of MVTools plugin for replacing a bad frame with one interpolated from the pair of adjacent frames. You can e.g. first remove one of those 2 interlaced frames in telecine cycle (using SelectEvery) and get:

-p1p2i3p5-p1p2i3p5-p1p2i3p5-,

then apply MFlowInter function in each 4-frame cycle for replacing the remaining i3 with interpolation - probably you'll need one of stickboy's plugins (like ApplyEvery) for this. Sorry, I can't give a finished recipe, just the idea.

stickboy's plugins are here:
http://avisynth.org/stickboy/
mvtools2:
http://www.avisynth.org.ru/mvtools/mvtools2.html

Tima
27th February 2009, 12:11
Thanks, it's an interesting approach! I'll try it.

Yes, the source was definitely telecined film (NTSC).

My approach was the following: kill each (5+i*8)-th line (look at the sample picture to get an idea :) ), thus getting 720x512 video where even lines are a part of ofiginal TF, and odd lines are a part of original BF. I did this and wanted to apply ivtc to the result. But I got stuck at this point because of some interlace and small blend left (maybe, due to imperfectness of whis solution and/or compression artifacts). Maybe, it's better to implement deblending technique at this point.

Also there is need for some non-standard field matching, because it appears that input clip has constant field shift :)

2Bdecided
27th February 2009, 13:33
Someone is going to come along and ask you why you don't have the source.

On your example, the trick is to undo the resize operation. It's not impossible - but it's slightly more complicated that what you've tried - it's not a simple "1 line input > 1 line output with some missing" mapping. Some algebra and weightings on adjacent lines should do it, but I don't know how to proceed in AVIsynth.

As you say, it's a bigger problem if it's also been compressed.

Cheers,
David.

Didée
27th February 2009, 14:07
Getting the luma plane (more or less) back to its original state is not that difficult:

source
addborders(0,0,0,9)
lanczosresize(width,480,taps=6)

The chroma planes, however, can not be restored that easily. On the interlaced frames they are most probably fieldblended. Progressive resizing of interlaced YV12, you know.

First thing I'd try is FixBlendIVTC().

Guest
27th February 2009, 14:49
@Tima

Where did you get this mangled up film and why dont you encode from the source itself?

Tima
27th February 2009, 19:17
First thing I'd try is FixBlendIVTC().

Do you mean apply FixBlendIVTC() instead of my trick with lines removal, or after it?

As you can see from the screenshot, the luma information shoud be more or less okay after killing fields, as described above. Or am I completely wrong?

Where did you get this mangled up film and why dont you encode from the source itself?

That's a (short enough) part of an old movie 'Battle beyond the Sun' -- english 'remix' of russian movie 'Nebo Zowiot'. Someone definitely doesn't know how to encode :) and also it's an interesting challenge by itself.

[I suppose, such fair use doesn't violate second part of rule #6 :)]