Log in

View Full Version : Req help with decimating


FredThompson
24th May 2003, 04:46
I just found I've processed a video clip without decombing it first (a la Donald Graft's excellent filter.) The source was film, the carrier medium was NTSC satellite TV, the storage medium was NTSC DV.

Well, I've now got a progressive, 2d cleaned file but the frame rate and frame contents are screwy. The result has a 29.97 frame rate which is way off. The source files are long gone and the tape was resused. Sigh.

There is the definite 2,3 pattern of combined, proper frames.

For example:

"bad" frames: 7717 7718
good frames : 7719 7720 7721

then the pattern repeats.

If I've done the math properly, this means frames 0 and 1 are good, 2 and 3 are bad, 4 is good and it repeats.

In reality, the first 2 or 3 seconds are black leader with no sound clipped from another portion of the capture. I don't really know what their pattern is but the pattern of the actual content is what should determine how this is fixed.

I've tried running this mess I've created through decomb without any modified settings. The frame rate was proper but the contents weren't filtered properly.

So, the question is, how do I properly use an AviSynth filter to get this back down to film framerate?

Guest
24th May 2003, 05:05
If it has a clean 3:2 pattern, then it should be good to go with Decomb. Unless of course you did something really dumb like deinterlace it as normal video, or resize it before deinterlacing/IVTC. The only way for us to know is for you to tell us how you processed it and/or post a short clip. At a minimum, the 5 sequential frame grabs would be illuminating.

Oh, reading your post again, it sounds like you deinterlaced it as video and then ran a spatial cleaner over it. If so, you're screwed as far as IVTCing it is concerned. Sorry.

But if you just want to get back to 24fps (why?), you can Decimate() it using mode=0 or mode=3, or you can use ChangeFPS() for better results, or MotionPerfect for best results.

FredThompson
24th May 2003, 05:59
I have no idea what I did. 20-hour days all week and all kinds of stuff going on. Maybe I did deinterlace in VirtualDub then smooth. Looking at it with that in mind, sure looks that way.

Why 24fps? The source is film. There's nothing to be gained by staying at 30 and a lot of bandwidth to be lost.

Oh, I think I see where you were going. Use your multidecimate to get rid of the bad frames then use MotionPerfect to create some semblance of real physics? End product is to be SVCD but the source is DV so there's lots of room to manipulate the source without too much loss in the end product.

oh, crud, I don't know how to put anything on my web space. OK, I'll learn how to do that but, in the meantime, uh, I've just emailed a small PNG to you. It shows parts of four successive frames. The middle two are the junk.

Guest
24th May 2003, 06:54
MultiDecimate() isn't going to preferentially get rid of the bad frames. So it won't help you.

By deinterlacing the 3:2 material you have turned the original sequence [a b c d] into [a a/b b/c c d] where a/b represents a blend. That is correct if you had blend=true. If you interpolated you changed it to [a a' b' c d] or [a b' c' c d], where a' is a half vertical resolution frame, depending on what deinterlacer you used.

So, if you blended, you're screwed; just leave it at 30fps to avoid making it jerky. If you interpolated, then you can simply Decimate(5) to get it back. But you'll still end up with one half resolution frame in the latter case.

FredThompson
24th May 2003, 07:08
The only time I've used blend is if the subject is in very rapid motion with homemade DV because the camcorder goes nuts. All those settings for "shutter" speed are great except it doesn't match well with florescent lighting.

Probable the later of the two things you mention. OK, so I might wtill have some junk? Well, I'm willing to give it a shot and see what happens. Maybe sometime some other doofus will have done the same thing and they'll come across this thread.

Oh, when I deinterlace I use your smart deinterlacer set for interpolate, maybe motion, usually set for field or field-and-frame.

FredThompson
24th May 2003, 07:31
OK, I've tried it. You're right, the frame rate comes back down but there is also still a little nastiness. There's got to be a better way.

You mentioned MotionPerfect. I'm willing to give that a try.

To summarize, I've taken an NTSC broadcast stream of 29.970fps and deinterlaced by interpolating then did a 2D cleaning and saved the file. Problem was, the original was film and should have been decombed to 23.976fps. The original is lost and I'm trying to find a way to get rid of the corrupted frames AND have smooth playback.

My plan is to remove 2 sequential frames of every 5 then use MotionPerfect to "restore" the "missing" frames. It will actually be creating an entirely new set of all frames which stinks but it's worth a shot. It might be more accurate to substitue a combined frame in place of the two that are being removed (interpreted heavily from frames 1 and 4 with a little input from the two deleted frames as they DO have some good info) then do a MotionPerfect rebuild but I'm too tired to think of a way to do that right now.

I need to wipe out frames 2 and 3, 7 and 8 (2+5 and 3+5), and so on.

Framerate decimation doesn't seem to give the control I need. The easiest way to do this, numerically, is to work backwards through the stream because deleting changes the relative frame numbers further down the stream. Hence, decimate by 5 doesn't help at all because it's starting from the front. At least, that's what it looks like. AviSynth doesn't seem to have programatic flow support to let me do this so, in the interest of time...

I made a fairly large AVS script that loads my clip then has a slew of DeleteFrame commands. There's about a thousand frames in the section and 2 of every 5, corresponding to the ginked up frames, were deleted in descending numeric order. Then, the frame rate was manually adjusted to 17.987 in VirtualDub and the test sample rendered.

The audio stream is fairly easy to handle. I just load the starting 29.970fps file with Donald's basic Decomb script for AviSynth:

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\decomb.dll")
AVISource("file.avi")
Telecide()
Decimate(cycle=5)
ResampleAudio(48000)

Then I saved the WAV which is for the complete clip. If the test go well and this removal and regeneration of frames looks ok, I'll add that audio in place of the original to the generated AVI using VirtualDubMod.

Well, the test continues and I'm going to bed.

FredThompson
24th May 2003, 10:21
Well, MotionPerfect finished the test sample just as I finished that last post.

It worked. There are a few ripples but it DID do a great job. I'm wondering if increasing the frame rate then doing a reduction would help improve that. Dunno but it sounds logical. I'm sure there are techniques to fixing jerkiness. Maybe expaning by a non-multiple of the film frame rate and reducing again.

The samples on DynaPel's site are so small it's hard to tell what "imperfections" might have been hidden by image reduction. The section I tested didn't have a lot of action, either. I'll play with this some more.

Actually, the file with 2 frames deleted looked pretty good, too. Won't work for encoding to a SVCD, though, so the conversion still has to be done.

Holy cow, that MotionPerfect thing is a lifesaver. I don't know how it will do on the entire stream. I guess something with a lot of jerky motion wouldn't be too good. Basketball championships are probably out of the question.

So, the only difficult part seems to be removal of the "offending" frames. Manually creating a huge script seems a waste but maybe it's something that only needs to be done once since the pattern of this deinterlacing mistake is always 2 of 5. Wonder what happens when you tell AviSynth to delete a frame that doesn't exist?

I'll test that later when I can think. G'night.

Guest
24th May 2003, 19:30
Did you use Xpert mode in MotionPerfect to specify frames to be recreated? If not, that is why it came out jerky.

You're sure willing to spend a lot of time on a one-off screw-up. :)

FredThompson
24th May 2003, 21:14
Well, I'm also learning a lot and somebody else will do the same thing and stumble across this thread.

Any ideas on how to do the frame deletion?

Guest
24th May 2003, 21:28
If you don't answer my questions, I won't answer yours. :)

FredThompson
24th May 2003, 21:40
You mean about Xpert mode? No, I didn't do that and I'm playing with it now.

You're proposing manually clicking on all those dots for the bad frames, are you? Turns out this clip is about 12 minutes. That's a LOT of clicking.

FredThompson
24th May 2003, 21:49
Oh, I see. click-n-drag.

FredThompson
24th May 2003, 22:19
No, I don't see. I see that in the help but I don't see how it's supposed to work. When I click on the "analyze" button there's a display of file statistics, sort of like GSpot. The help has some short tutorial things but those seem to be more explanations of what gaps are the the theory of how they're filled. Do I have to run the entire job first to fill some kind of testing buffer? The window I think you're talking about, on the lower left, brings up the input file selection window.

I'm playing the source in the little preview window. Looks fine as a postage stamp ;)

Do you think the install got corrupted? I could remove, clean the registry and reinstall.

Guest
25th May 2003, 03:35
I wasn't suggesting to use Xpert mode, just asking if you did. If you did not, then you won't be repairing just the bad frames, and the result will probably be jerky. If you want to do it right, you want to have MotionPerfect replace only the bad frames with created interpolants. But specifying it is very tedious, as you realized.

FredThompson
26th May 2003, 04:38
I don't mind it being difficult. There's a lot of cases with the video that comes my way where MotionPerfect would be helpful. (What passes as "professional" video is sometimes amazing.) Thing is, neither MotionPerfect nor VideoScope will analyze my DV files. Maybe there's a conflict with the MainConcept DV codec. I've seen mentino about that and MotionPerfect has a setting specifically regarding the M$ DV codec (whatever that is) so I've got to solve this first.

I don't think it's going to be that hard to wipe out frames 2 and 3 of every five because it looks like resizing the complete Motion Perfect window would set the number of columns in the analyze portion. If that is so, it should be fairly easy to set ten columns and wipe out four of them. Then again, I might just do the AVS file I mentioned earlier. Still gotta get the analysis working properly. The numbers of columns idea is just an idea until the columns actually work.

It seems to be only linear re-timing, no acceleration/deceleration. Still, for $50 it does a heck of a job. Gotta be nice for converting PAL<->NTSC. Need to learn a lot more about color models and, obviously, need to letterbox/crop as appropriate.