Log in

View Full Version : Search for dropouts - how to mark or output ?


Fudoh
29th May 2006, 01:50
Hi fellows,

I've started digitizing old VHS tapes recently. As some of them are in very bad condition, there are bad fields (completely green) in the captured videos from time time.

Since I don't have the time to watch the captures in realtime, I've done this script to find the bad fields

clip = AviSource("d:\temp\source.avi").ConvertToYV12
white = AviSource("d:\temp\dropouts\white.avi").ConvertToYV12
black = AviSource("d:\temp\dropouts\black.avi").ConvertToYV12

ConditionalFilter(clip, white, black, "UDifferenceFromPrevious()", ">", "25", true)

white.avi is 2 hours solid white, black.avi is solid black.

The output is completely black with a white frame every time a bad (green) field appears in the source video. With the video output I can use the "find next transition" button in Virtual Dub to find the exact locations of the bad fields easily.

Problem is that it's only approx. 1/2 realtime and I have to note down the frame position and push the scan button again after every bad field. (BUT I can do while doing more important things on the PC anyway...)

So - I wonder - can the ImageWriter or ScriptClip function be combined with this one in any way ?? It would be great if the bad frames from the source.avi could be saved via ImageWriter in some way. Since only a field is bad when a dropout occurs I could still identify the position with a framegrab from this position...

I've seen that ScriptClip can even output the frame's' number, but I cannot figure out how to combine it with the conditionalfilter....

Any ideas or hints would be highly appreciated !!

Thanks,
Fudoh

Mug Funky
29th May 2006, 04:20
i have a dropped-frame interpolator that could be modded easily to replace any fully green field with a frame "morphed" from the adjacent frames. i'll dig it up and post it, but you'll have to do the modding - i'm at lunch :)

[edit]

function filldrops (clip c, int "idx")
{
idx=default(idx,1)

vf=c.mvanalyse(truemotion=true,pel=2,isb=false,delta=1,idx=idx)
vb=c.mvanalyse(truemotion=true,pel=2,isb=true,delta=1,idx=idx)
global filldrops_d = c.mvflowinter(vb,vf,time=50,idx=idx)
global filldrops_c = c
c.scriptclip("""ydifferencefromprevious()==0? filldrops_d : filldrops_c""")

}

now this works on full frames only, but i imagine it can be modified without too much of a speed hit (as it is, it runs well above realtime and can maintain realtime playback on my machine, even when there's tons of drops).

you'll need a newer version of the MVtools.

hanfrunz
29th May 2006, 21:21
what's the size of the black/white clips? Try to resize it to 8x8 pixels for speed increase. You could also use blankclip() to produce a black/white clip...

Fudoh
30th May 2006, 13:58
@Mug Funky

Thanks ! This is unfortunately way above my understanding of the avisynth script language. Problem with it might be that I need to exame the dropouts by myself since some are longer than a single frame...

@hanfrunz

Thanks for the hint ! The script is now running slightly above realtime.

Nobody any idea how to combine the basic idea above with ScriptClip and ExportingSingleImage to make the script output the frames found marked with their framenumber ?

US$50 (via paypal) to the one who can help me out with a working solution !!

Tobias

hanfrunz
31st May 2006, 15:07
look at the manual page of conditionalfilter. There is an example (Advanced conditional filtering: part II). This could be adapted to write the framenumbers of the dropouts to a text file. In a second script you can use conditionalreader and only extract the frames you need with imagewriter

could you upload a samplevideo?

hanfrunz

tsp
31st May 2006, 15:46
else you might be able to make something out of this old thread:
http://forum.doom9.org/showthread.php?t=82066

Fudoh
5th June 2006, 23:12
Thanks to everybody contributing (@tsp: amazing script, but way too complicated for me to even understand it) !!

Here's the result:

#
# dropout.avs
#

# settings
global dir = "d:\temp\"
global infile = dir + "Capture_20060605-134049.avi"
global logfile = dir + "test.log"

# code
clip = AviSource(infile).ConvertToYV12

WriteFileIf(clip, logfile, "(UDifferenceFromPrevious>20)", "current_frame", """ ":" """, "UDifferenceFromPrevious")
WriteFileStart(logfile, """ "Start" """, append = false)
WriteFileEnd(logfile, """ "End" """)

ConvertToYUY2


Specials thanks to Marc W. for the input and the script :)

When this script is run in any Media Player or VDub it outputs all dropouts (framenumbers) into a log file.

The remaining question for me: is there a way to speed it up ? Or in other words: how can I run the script without rendering the actual video to an output ? When I run it in VDub with input and output disabled it runs through (at 25x speed), but doesn't find and dropouts - probably because no actual frames from the video are requested.

But shouldn't there be any way to have AVISynth process the script (here do the "UDifferenceFromPrevious" function on the video), but without outputting the actual video ??

Thanks,
Tobias

hanfrunz
6th June 2006, 08:11
if you disable input+output no video will be rendered. Try VIDEO->Scan video streams for errors in VDUB. Or use a command line tool (see sticky-thread)

hanfrunz