Log in

View Full Version : Correcting occasional vertical field shifting


STC-Fan
3rd March 2010, 14:09
Recently I have been re-capturing some old PAL VHS tapes using a Conexant Fusion 878A-based capture card, with better results than from my previous efforts a few years back, capturing through the VIVO port of my then-primary GeForce 4 Ti4200 graphics card.

However, in one of the tape re-captures, one of the fields shifts up, moving out of alignment with the other field, causing jagged edges and generally making for ugly artefacts after deinterlacing.

So far I have been unable to find a filter for AviSynth that is able to correct occasional field shifting, and was wondering if anyone here knows of a solution to this problem. As of this time, I am only aware of one plugin, from the MSU Graphics & Media Lab (http://compression.ru/video/old_film_recover/field_shift_en.html), but this is only capable of correcting fields shifted horizontally - not vertically.

From my investigations, there is a plugin for VirtualDub that will perform a vertical shift on interlaced video fields. However, that plugin shifts all fields in all frames, so it does not address the problem of only correcting those frames which actually suffer from shifted fields.

I have uploaded a sample of the affected video, which can be found here (http://stc.hacking-cult.org/videos/VerticalFieldShift_Sample.avi). The file is compressed with (the latest version of) Lagarith, so bear this in mind if you primarily use VLC Media Player for viewing video files, as it will not play in that application. (This is despite the VLC Wiki stating that Lagarith playback is supported (http://wiki.videolan.org/VLC_Features_Formats), but that's another topic for another thread.)

Boulder
3rd March 2010, 18:39
There's not much you can do..maybe some Depan magic, but I doubt that it can fix the issue so that you wouldn't notice anything.

I'm not that much of an Avisynth expert, but I suppose that a function could be built which could write down the frame numbers where the jitter occurs in a bobbed stream. This list of frames could then be utilized to apply the necessary correction to only those frames.

STC-Fan
3rd March 2010, 22:39
I'm not that much of an Avisynth expert, but I suppose that a function could be built which could write down the frame numbers where the jitter occurs in a bobbed stream. This list of frames could then be utilized to apply the necessary correction to only those frames.
One thing I am aware of is that the Field Shift filter for VirtualDub (http://www.thedeemon.com/VirtualDubFilters/detailed.html#237) can be used in AviSynth with the VDub filter import function. I've tested it and found that only a very small correction is required to realign the interlaced fields correctly, so it's fine for the job.

However, I'm not sure how to apply an AviSynth filter to a pre-defined list of frames. I did have a search around the Web and on some AV forums, but didn't come up with anything of significance. As far as I'm aware, the Select() (http://avisynth.org/mediawiki/SelectEvery) function(s) of AviSynth don't allow selection of individual frames.

Basically, if manually combing through the video to find every affected frame and putting it in a script them is necessary, I'll do it. Thankfully, I'll only have to do it once as none of the other VHS tapes had this issue on capture.

Revgen
4th March 2010, 05:59
^Example. Let's say the video is 3000 frames and you want to filter frames 2100 to 2200 and leave the rest alone.

v1 = yoursource()
v2 = yoursource().filteryouwanttouse()
trim(v1,0,2099)+trim(v2,2100,2200)+trim(v1,2201,0)

Boulder
4th March 2010, 06:44
There's also the Avisynth internal function "ApplyRange" which makes writing the script a bit easier.

Gavino
4th March 2010, 11:07
^ ... also the ReplaceFramesSimple function from stickboy´s RemapFrames (http://avisynth.org/stickboy/RemapFrames.zip) plugin.

STC-Fan
6th March 2010, 15:43
UPDATE: My only complaint about this method I'm using is that it is rather slow (quelle surprise). Yesterday, I managed to locate and fix about 180 or so bad frames, out of the first 5792 - which is nice, except that it took me about 3 hours (roughly) to get through. And there's still around 70000 frames left...!

I can't spare that much time on this every day, which is what I'd need to do to get through this, so I think I'll either wait for an automated (or semi-automated) solution, or plough into it again over the Easter holidays...

--------------------------------------------------------------

Thanks for the suggestions - I hit upon a nice solution in the form of ConditionalReader (http://avisynth.org.ru/docs/english/corefilters/conditionalreader.htm) and ScriptClip (http://avisynth.org.ru/docs/english/corefilters/conditionalfilter.htm) which I arrived at from the ApplyRange Wiki page. As a quick test, I've just tried shifting the fields in 1 frame using the VDub FieldShift plugin, supplying the affected frame from an external text file, and it seems to work very nicely. One down, 9999 or so more to go :)

My current script looks something like this now (various parameters abridged here, just leaving the important bits in):


AVISource("C:\Videos\Source.avi", audio=false).Trim(349, 76274).ShowFrameNumber()

...

LoadVirtualDubPlugin("C:\MeGUI Folder\fieldshift.vdf", "VD_FieldShift", 1)
ConvertToRGB32()
ScriptClip("VD_FieldShift(myvar)")
ConditionalReader("C:\Videos\FramesToAdjust.txt", "myvar", false)
ConvertToYV12()

...