Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th October 2013, 03:01   #1  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
VHS Horizontal Lines: ReplaceFrameAvg()

Hello,

[Similar topic with no solution]
So I have a video sourced from VHS tape recorded in a TV studio. Every minute or so, for 1-5 frames, horizontal white lines appear on the clip and distort the image in those places.
What I have been doing is DeleteFrame() on each of these, until I realized that this does not sync audio, so I defined:
Code:
function DeleteFrame2(clip clp, int framenumber) {
    return clp.trim(0,framenumber-1) + clp.trim(framenumber+1,0)
}
However, this causes gaps in the audio.

I was thinking it would be ideal if I could somehow repair these with a ReplaceFrameAvg() function, which takes the average of the frame before and the frame after.

Any ideas?
AviUser is offline   Reply With Quote
Old 29th October 2013, 13:49   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
A simpler solution would be just to use FreezeFrame().

However, your request could be done as follows:
Code:
function ReplaceFrameAvg(clip c, int f) {
  # Note: assumes 0 < f < frameCount-1
  avg = Merge(c.SelectEvery(1,-1), c.SelectEvery(1,1))
  c.Trim(0, -f) + avg.Trim(f, -1) + c.Trim(f+1, 0)
  AudioDub(c) # preserve audio
}
If there are many frames to be replaced, then rather than multiple function calls, it would be more efficient to call Merge() once, do the Trims manually, and do a single AudioDub() after all replacements have been done.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 30th October 2013, 18:21   #3  |  Link
Evil_Burrito
Registered User
 
Join Date: Feb 2013
Posts: 23
Yes AviUser, there are hundreds ways to what you want. As Gavino mentioned freezeframe is one method. You could also delete the bad frame, then duplicate the previous one. If you don't want to spend so much time manually checking frames, you could use a temporal denoiser. Or even better, you could use a motion compensated temporal denoiser. Or you could learn how to use the DeScratch/DeSpot filters in combination with DePanEstimate (or mvtools). Although DeScratch/DeSpot results may vary because the settings can be difficult to configure.
Evil_Burrito is offline   Reply With Quote
Old 31st October 2013, 17:06   #4  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Thank you everyone for your help!
This solves my problem.
AviUser is offline   Reply With Quote
Old 9th November 2013, 23:01   #5  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Just to let you know the results when I applied your tips to a real video:
1. ReplaceFrameAvg() is the best, except causes ghost-like effects when there is movement and doesn't work when there are horizontal lines in two consecutive frames
2. I prefer FreezeFrame() over DeleteFrame2() because no audio blips will be introduced and it won't really increase the size of the video (identical frames compress well)
AviUser is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.