Log in

View Full Version : Tool to find field order/deinterlacing options?


aNToK
13th January 2011, 07:57
OK, I freely admit that I use the "analyze" feature in MeGui to guide me when dealing with interlaced content (and the info in dgindex when it can't figure it out).

I have a vcr tape I'm trying to convert to dvd with a Diamond VC500 capture device and I can't figure out how to properly deinterlace it.
If I rip it as dvd mpeg, dgindex says it's progressive while megui analysis says M-in-5 decimation and triticale decimate. The results are horrible.

If I use the avi capture option, dgindex can't open it and megui can't analyze it. I tried yadif (bff and tff, both looked the same to me) and it improved somewhat, but I'd really prefer to know what exactly it is I'm dealing with. Also had to convert to YV12 to make the filters work. RGB colorspace? No clue.

Is there any program to analyze avi files for this type of content so I can improve it?

Sorry for the rambling, but I'm on a timetable to have clips from this video for a school project.

manono
13th January 2011, 08:57
From the Decomb Tutorial:
To determine the field order, make an Avisynth script that serves the raw clip without any processing. If it were an AVI, then just AviSource() would be used. For our examples, we'll use AviSource(). Add a script line to separate the fields using top field first, as follows:

AviSource("your_clip.avi")
AssumeTFF().SeparateFields()

Now serve the script into VirtualDub and find an area with motion. Single step forward through the motion. Note whether the motion progresses always forward as it should, or whether it jumps back and forth as it proceeds. For example, if the field order is wrong, an object moving steadily from left to right would move right, then jump back left a little, then move right again, etc. If the field order is correct, it moves steadily to the right.

If the motion is correct with AssumeTFF().SeparateFields(), then your field order is top field first and you must use AssumeTFF(). If the motion is incorrect, then your field order is bottom field first and you must use AssumeBFF(). If you want to double check things, you can use AssumeBFF.SeparateFields() to check correct operation for bottom field first.

Deinterlacing Options:

http://avisynth.org/mediawiki/External_filters#Deinterlacing

A sample would be good also.

aNToK
13th January 2011, 10:31
I was going to do a sample, but the 12 second clip is just over a gig. I'll try the dvd capture and up a sample of the mpeg

aNToK
13th January 2011, 11:25
OK, fiddled around with 2 different capture apps and half a dozen settings. With the included "one touch" software in .avi mode, I get what looks to be interlaced video that plays pretty smooth at 59.9ish frames (fields?) per second with all the associated jaggies. Switching to the "dvd" capture mode gives a deinterlaced (blended?) soft, fuzzy look with plenty of jerks during sideways motion and comes in at 29.9fps.

Here's a short clip of the "raw" avi in all it's jagged glory. I tried stepping the frame one by one and with TFF, I got one backwards jump every 4th or 6-7th frame with what looks like regular repeated frames. With BFF, I got backwards jumps all over the place. Help!

btw, sorry about the 120+meg filesize. I kept it down to 6 seconds and the best example of sideways motion and interlace artifacts as I could.
Thanks in advance for any help anyone can offer.

http://www.mediafire.com/?qbrg8s058838dsa

manono
13th January 2011, 12:15
Since the VHS tape wouldn't be 59.94fps, I'm not sure why your AVI is. Anyway, I'm sure there are better ways to handle it, but unless and until someone else comes along with something better, this may do for that sample:

AssumeTFF()
TFM(PP=0)
TFM(PP=0)
TDecimate(Mode=0,Cycle=10,CycleR=6)

If the residual minor interlacing bothers you, turn on the post-processing (remove the PP=0, but most of the frames will get deinterlaced), or add Vinverse afterwards.

aNToK
13th January 2011, 12:45
I think it's just calculating each field as a frame. I'll give your suggestions a try in the am. Just realized it's a quarter to 4 and I have 3 lectures tomorrow, ugh.

Thanks so much for your help!

aNToK
14th January 2011, 11:51
OK, so after much playing with this thing after all the suggestions, I'm going to let this run overnight to see how it turns out. The script I'm using is:

AVISource("D:\MANZANAR\Raw.avi", audio=false)
converttoyv12
checkmate()
AssumeTFF()
TFM(PP=0)
TFM(PP=0)
TDecimate(Mode=0,Cycle=10,CycleR=6)
vinverse()
DeSpot(p1=35, p2=14, mthres=25)
mctemporaldenoise(settings="medium", edgeclean=true,ecmode="removegrain(4,4)",stabilize=true,maxr=3,ttstr=4)

I remembered putting checkmate first from my other thread, but wasn't sure where to put the despot one and frankly, haven't tweaked it much as the settings I copied did a nice job on the worst of the film spots. At 2 hours and 24 minutes and 2-3fps, I think I'll be stopping it in the morning to check various scenes and do the "real" job this weekend.

Thanks again for the advice, especially manono here and tengo6dedos from another thread for the checkmate tip. Any thoughts on filter placement or improvements are always greatly appreciated. I'll be transferring quite a few vids and home movies from vhs in the coming weeks, so at least I have a good starting point!

aNToK
16th January 2011, 22:59
OK, after using the hints graciously provided, I've finally ended up with an acceptable video. Now I just need to get the audio to sync up and this little project will be complete.

It seems that the raw capture I did (all 178 gigs of it...) has the same sync issue, but it seems to be in sync when I play the tape in the capture program (Diamond One-Touch video capture, supplied with my adapter.) I don't know if it's some non-standard compression thing or something, but if I use a different capture program (virtualdub, etc.) the video is just horizontal lines and static, so I'm kind of stuck with it.

Is there a way to adjust the audio to sync back? I've dug through the threads I could find, but no joy so far.

manono
17th January 2011, 03:00
If it's off by the same amount all the way through, just set a delay when muxing, or remove the delay entirely using DelayCut.

aNToK
17th January 2011, 03:37
Ah, I wish. At about 5 minutes, it's slightly off, but it works it's way to a full 2+ seconds off 2 hours into it. I'm recapturing it with a different program now that saves it as PCM audio (the other gave me a 170+gig video file with an itty-bitty 128Kbps constant mp3 file. Since it appeared in the original capture, I doubt that the change from 59fps to the eventual 23.9 fps had anything to do with it.
I wish there was an application besides the bundled one that would preserve the interlace and audio. The others want me to route it through my soundcard and it sounds terrible.

Mug Funky
17th January 2011, 04:08
sounds like audio and video ADC clocks are not locked together.

are you capturing audio through a separate sound card or something?

drifting sync like this happens when audio and video are digitized with separate clocks.

if at all possible, you should capture audio through the video capture device. failing that you'll need to spend hours "rubber-banding" your audio in an editor to keep it in sync.

aNToK
17th January 2011, 05:43
OK, recaptured the tape, this time in dvd mode and it's in sync, so now I have one clean video and one icky video with sync'd pcm audio. I'm going to try trimming both vids to the same start/end points, extract the audio from the new rip and mux it with the old vid that I've cleaned up. Am I barking up a doomed tree or can this actually work?

Mug Funky
17th January 2011, 06:10
theory says it can work.

a frame is a frame. video clocks are usually phase-locked to the playback signal, so if the tape is stretched, the capture ADC will stretch with it (which is probably why the audio went out - it had a stable clock that didn't move with the tape's errors).

before you jump into a big encode, i'd make sure the audio's in sync.

aNToK
17th January 2011, 07:40
Ah, after adjusting framerates, redoing this, that, and the other, I stepped through the original capture again and found a few blips in the video. Not sure what caused them, but they're there.

Rechecked the original vhs and it plays smooth in those parts, so I'm guessing that some background process or something decided to pop on? Guess I'll try re-ripping this in it's "raw" form(whatever it is that produced that huge 170gig original one more time and see what happens. I'll post back when I've got something.

aNToK
17th January 2011, 08:40
Hmm.. If I use the audio=true option, I end up with a nice little PCM audio file that appears to stay in sync. Cross my fingers that it stays that way for the whole thing...

aNToK
17th January 2011, 11:34
OK, just captured the whole thing again, and the same problem. This time, I only captured the movie and not the 40 minutes of extras, and the audio ended up about 1 second ahead of the video at the end. Again with the gradual sync issue, but couldn't find any of the video hiccups like I did in the first capture. Only seems to do it when I capture it in the device's "avi" mode which it says is uncompressed. Can't seem to find another program to capture it with the interlace intact, and all the progressive captures look too blurry to mess with. Any clues?

aNToK
18th January 2011, 08:22
Well, after downloading what turned out to be a useless program to work with Win7 from Diamond support (nice guys, just didn't have a solution) (btw, who makes a program that needs audio input that doesn't work with Realtek audio? It's only the most popular on-board one out there...)
I ended up spending most of the day splitting up my little vid and doing manual timeshifts on the audio. Now if it only stays in sync after filtering and stitching back together, my little Frankenstein monster might actually be viewable without my eyes resigning in protest!

One more day of filtering to go....

aNToK
20th January 2011, 03:24
Oof. Had to chop it up into 14 different clips to get the audio to line up correctly but it's done.

The only major thing I would like to improve is the horizontal shakiness that shows up through the whole vid. Is it impossible to remove these from an old vcr source?

I used the script from I believe the 7th post with the tdecimate, vinverse, etc. and it's now watchable.

Is it possible to minimize the shaky effect? I'm uploading a short clip (2 seconds) of my final Huffyuv encode. The man's sleeve shows a clear shot of what I'm referring to. I'm guessing no, but I still have the uncompressed original if there's something that can be done.

http://www.mediafire.com/?all5t8t86rjq67f

Floatingshed
21st January 2011, 16:04
Rather than chopping the file up to re-sync sections you could play with Timestretch(rate=) to bring back the sync. Use Delayaudio() to get the start of the video in sync then play with the value of "rate" to bring the end into sync...

aNToK
21st January 2011, 19:12
I tried, but there are several sections in the middle where the audio was ahead, then behind, then ahead. Never had a problem like this one. Once my system's refreshed, I'll be capturing a few more vcr tapes to see how it goes...

Gavino
21st January 2011, 19:40
I tried, but there are several sections in the middle where the audio was ahead, then behind, then ahead.
ajp_anton recently posted a script that handles multiple sync points in a clip, matching up each section accordingly.
http://forum.doom9.org/showthread.php?t=159070

aNToK
22nd January 2011, 00:55
I'll take a peek at it for next time, thanks!