Log in

View Full Version : Vertical stabilization - Resynchronizing unstable video from analog source


VideoOnTapes
27th August 2020, 00:28
I have video recordings from VHS where there are large vertical jumps (loss of sync). I no longer own the tapes.
Here a example :
https://i.imgur.com/mYVAz78.jpg

I'm looking for a solution to realign the faulty images. I mean align them correctly based on the previous frames, even if the image is not perfect in other aspects.

To identify the bad frames, I think I could use the PSNR value of each frame.
The Compare() function has allowed me to see that the frames that have a sync loss are those that return a PSNR value < 20.
Is it possible to retrieve the PSNR value in a variable to use it in conditional tests?

In order to reconstruct the frames that are out of sync, I wrote this function :


function reorderImage(clip clip, int yPos) {
return stackvertical(\
crop (clip, 0, yPos, Width(clip), 0),\
crop (clip, 0, 0, Width(clip), yPos)\
)
}


What I'm missing now: how to find the right yPos value automatically for each bad frame ?
I found that F2QCorrelation() (http://www.avisynth.nl/users/vcmohan/FQPlus/F2QCorrelation.html) from the plugin FQPlus (http://avisynth.nl/index.php/FQPlus) can create a file with the following informations :


...
frame 98 x = -1 y = -80
frame 99 x = -1 y = -82
frame 100 x = -1 y = -82
frame 101 x = -1 y = -42
frame 102 x = -2 y = 2
frame 103 x = -2 y = 0
...


Can someone tell me if it's possible to read the y variable of each line with AviSynth from this kind of file, or do I need to convert the file first to an appropriate format ?

If it turns out it's not the right approach, I'm thinking of developing a small web application that would allow me to manually align the frames and save the values to a file that would then be read by AviSynth.

johnmeyer
27th August 2020, 04:22
A lot depends on the exact nature and the duration of the jumps. You need to post a clip.

I have successfully fixed such things, but the jumps were only 1-3 frames in length, with relatively stable video for the next few frames.

Here is what I did with some film that had lost its loop in the camera, so the jump was "baked in" to the tape:

https://www.youtube.com/watch?v=uzMFodrGHDs

I wish I had posted the portion of the clip where the truck drives away, because it is just as smooth as this relatively low-motion clip. The fix involved a lot of manual work, marking the beginning of each jump, and then using motion estimation and frame duplication to fill the broken frames.

VideoOnTapes
29th August 2020, 15:30
Thank you for your comment.

Here is an excerpt of the video on which I base my tests: https://www.sendspace.com/file/7c5acv

As well as an animated gif :

https://s8.gifyu.com/images/Brainstorm.gif

This video is very damaged, but it illustrates the type of problem I am trying to deal with: very short and very important vertical jumps.
I am looking for a solution that can be adapted to other video files that would have this kind of problem.

johnmeyer
29th August 2020, 18:18
In your sample the damage lasts for half a dozen frames or more, so the gaps in time are way too long to fill with estimated frames. In addition, the damaged frames are not just rolling (loss of vertical sync), which is all I thought you were dealing with, but are also completely obliterated with noise. As a result, there is absolutely nothing that can be salvaged from those frames. If instead you simply had a vertical roll (classic loss of vertical sync like we used to see when the "vertical hold" adjustment on a TV wasn't correct), there are ways to take the bottom and top halves of the frame and stick them back together and somewhat recover the original image.

So, sadly, without access to the original tapes to re-capture while playing with the tracking control (which might have helped fix the problem), there is absolutely nothing you can do with this.

wonkey_monkey
29th August 2020, 21:46
Well there's always something that can be done, even if it means manually aligning the clips, although in this case not only is there is a lot of noise, whole chunks of the frame are also missing.

I would just buy the Blu-ray (https://www.amazon.com/dp/B007NR9WBG/).

johnmeyer
30th August 2020, 04:44
Well there's always something that can be done, even if it means manually aligning the clips, although in this case not only is there is a lot of noise, whole chunks of the frame are also missing.

I would just buy the Blu-ray (https://www.amazon.com/dp/B007NR9WBG/).I actually did spend a few minutes to see if I could do something, but the problem is the noise. You might be able to use the last good frame to fill in the top and bottom of the frame, feathering the place where the old frame joins the current frame. Then after that, run some really aggressive noise reduction.

But, after a few minutes, I realized that the result would be 100% as unwatchable as the original, only with different problems caused by the "fix" that look more artificial.