View Full Version : Deinterlacing using AVISynth
Seraphic-
19th May 2006, 09:50
Hi,
My issue is with "motion artifacts" as my capture card has something called "use both video fields for high resolution images". This means still images and video look great, but there is interlacing during motion. I could turn this off and have no interlacing, but I think the quality looks much better with in on. However, I'm not sure what to do because after the deinterlacing the quality might be less then with it turned off.
I pasted the below motionbased deinterlacer code into "RealMedia ProducerV1.94's AVISynth" but it seems to lock up when I start the encode. Could anyone tell me what I'm doing wrong or give me some ideas/recommendations? (I'm new to using these programs)
AviSource("C:\Documents and Settings\Admin\Desktop\capture.avi")
Trim(begin, end)
KernelDeint(order=0)
Also, here are my capture settings: S-Video/NTSC/YUY2/30FPS/720x480 - test video is 13.7GB full uncompressed
Thanks
Abond
19th May 2006, 10:15
Trim(begin, end)
Hopefuly this is only pseudocode. Here you should put frame numbers.
If you want to check the script open it in VDub(Mod) - there would be a message if something is wrong.
Seraphic-
19th May 2006, 10:25
Hi, thanks for the reply.
Well, the thing is I’m not sure what AVISynth code would produce the best results. Could you perhaps post the code you would recommend I try?
Abond
19th May 2006, 10:34
Well, the thing is I’m not sure what AVISynth code would produce the best results.
Me too:o . Your approach looks ok to me.
foxyshadis
19th May 2006, 12:08
Can you post a short sample of huffyuv compressed video? Video games might need different treatment than normal movies.
If not, though, you could use anything in the range of LeakKernelDeint (fastest, most artfacts) to mvbob (slowest, least artifacts). Others to look at are securedeint (part of mvbob), tdeint, and tomsmocomp. There's also a combo of eedi2 and tdeint that's killer for animation, maybe it would work here.
neuron2
19th May 2006, 14:27
Well, the thing is I’m not sure what AVISynth code would produce the best results. We don't discuss "best" per forum rule 12.
It's very important to get the order parameter correct with (Leak)KernelDeint(). Are you sure you have it right?
Seraphic-
19th May 2006, 20:59
Hi,
Here is a short huffyuv clip from the video. If you need a better example I can create another video from a different game.
Also, is deinterlacing using AVISynth lossy of lossless?
neuron2
19th May 2006, 21:21
Yes, you had the order parameter wrong. Try this script and see if you like the result:
loadplugin("leakkerneldeint.dll")
avisource("1.avi")
trim(2,0)
leakkerneldeint(order=1,sharp=true)
I trimmed the first two frames because it seems that the cutting you did messed up the field order of those relative to the rest of the clip.
Please refer to the LeakKernelDeint() help file for a description of a method you can use to determine the correct field order.
Any deinterlacing is going to be lossy (you lose the combing!). But at least for an adaptive deinterlacer, the loss will be in "moving" areas only. If you set map=true, you can visualize the moving areas. Non-moving areas are not touched by the filter.
I'll try tdeint+eedi2 when I get home tonight and let you know how it looks.
Seraphic-
19th May 2006, 22:45
Hi,
Thanks, i'll give that a try. Also, let me know how tdeint+eedi2 looks.
How much loss are we talking about in the "moving" areas. I mean, since deinterlacing is lossy, would you recommend I just capture with "use both video fields for high resolution images" turned off? Because after the deinterlacing the quality might be less then with it turned off anyway.
neuron2
19th May 2006, 23:18
No, don't capture like that! If you do, you throw away an entire field, which means that every part of the picture loses half it's vertical resolution. If you capture both fields and then use an adaptive deinterlacer, as I said, you lose resolution only in the moving areas.
The whole reason these adaptive deinterlacers exist is to minimize the quality loss by keeping full resoultion in the picture where it is possible to do so, i.e., in the static areas. The resolution loss is less noticable in moving areas because they are, well, moving.
I'll post a processed clip from TDeint+Eedi2 in a few hours, together with the script. I'll give you screenshots comparing field discarding vs. adaptive deinterlacing, as well. You'll see immediately what I am talking about.
Seraphic-
20th May 2006, 01:57
What are you using AVISynth with? From what I can tell it isn't a stand-alone program, correct?
neuron2
20th May 2006, 02:18
Here is the link to my processed version of your clip. It looks real good to me. I won't bother making the screenshot comparison. You can compare this to your field discarding idea. It's night and day!
http://neuron2.net/misc/1deint.avi
Here is the script I used:
avisource("1.avi")
trim(2,0)
converttoyuy2(interlaced=true)
assumetff()
interp = separatefields().selecteven().EEDI2(field=1)
tdeint(order=1,field=1,edeint=interp)
msharpen(highq=true)
Seraphic-
20th May 2006, 02:34
Hi,
What are you using AVISynth with? It doesn't seem to work in "Easy RealMedia ProducerV1.94".
Also, you didn't try with "map=true"? Is the below code right?
avisource("1.avi")
trim(2,0)
converttoyuy2(interlaced=true)
assumetff()
interp = separatefields().selecteven().EEDI2(field=1)
tdeint(order=1,field=1,edeint=interp)
msharpen(highq=true,map=true)
neuron2
20th May 2006, 02:54
What are you using AVISynth with? It doesn't seem to work in "Easy RealMedia ProducerV1.94". Uh-oh. You don't know what Avisynth is and how to use it? Have you even installed Avisynth? You make your AVS script and then open the script in your application. Is that what you did? I just opened the script in VirtualDub and BSPlayer and played it.
If it turns out that "Easy RealMedia ProducerV1.94" (which I never heard of) doesn't open AVS scripts, then you can use DGVfapi (or equivalents) to convert the AVS script to a "fake" AVI that "Easy RealMedia ProducerV1.94" can open.
Also, you didn't try with "map=true"? Is the below code right? Why do you want to encode the sharpening map? I had that there because I had it set to true just to see if the msharpen() threshold was good. For encoding you want it to be false. You can delete the msharpen() call if you don't want the sharpening.
Seraphic-
20th May 2006, 02:59
Yeah, I'm new to using these programs
Avisynth came with "Easy RealMedia ProducerV1.94" but it seems to lock up when I use code with it. So I’ll try downloading it from avisynth.org/
And as for the map, I only wanted to add it because I thought you said it would just be lossy on the "moving" areas.
neuron2
20th May 2006, 03:03
Please read this and the other materials at the site:
http://www.avisynth.org/index.php?page=YourFirstScript
I did a Google and found that Easy RealMedia ProducerV1.94 provides support for Avisynth scripting, but you still have to install Avisynth itself. I suggest learning the basics first, i.e., do your scripting manually and then learn how Easy RealMedia ProducerV1.94 scripting support can help make it easier.
foxyshadis
20th May 2006, 03:13
I like
assumetff()
interp = separatefields().EEDI2(field=-2)
tdeint(mode=1,edeint=interp)
selecteven()
Simply because changing the field order only requires changing assumetff to assumebff. :p Otherwise identical, and hey, that looks very nice indeed.
neuron2
20th May 2006, 03:26
Yeah, that's a cool revision. Thanks for sharing it.
EDIT: Oops, it doesn't work for me:
Tdeint: number of frames in edeint clip doesn't match that of the input clip!
You're missing the select filter. That must be adjusted for the field order too.
foxyshadis
20th May 2006, 03:38
oh, sorry, I use it for mode 1 bobbing, forgot about that. ^^;
Seraphic-
20th May 2006, 03:39
Okay I made my script and opened it in VirtualDub. However, it errors saying "there is no function named EEDI2". Is that something I need to download as an add-on?
Also, Easy RealMedia ProducerV1.94 has a thread on this forum - http://forum.doom9.org/showthread.php?t=73228
The reason I was bringing it up is because I plan to use RealVideo 10 as the compressor for the final video.
neuron2
20th May 2006, 03:43
oh, sorry, I use it for mode 1 bobbing, forgot about that. ^^; No pb. It would be good to have a version that adjusts like you propose, though. Maybe just selecting from two different functions?
neuron2
20th May 2006, 03:45
Okay I made my script and opened it in VirtualDub. However, it errors saying "there is no function named EEDI2". Is that something I need to download as an add-on? Yes, you need tritical's TDeint and Eedi2, which you can get here:
http://www.missouri.edu/~kes25c/
The Avisynth docs explain how to load them. You can either put them in your Avisynth plugins directory, or you can explicitly load them with LoadPlugin().
And BTW, tritical's stuff is brilliant. Check out his other stuff too when you get a chance.
Seraphic-
20th May 2006, 03:52
Alright, I downloaded those an installed them. However, it's asking for "msharpen" and I don't see that on that page. I'll look around and see if I can find it until you reply.
EDIT: I found msharpen "Version 1.10 beta 2" so I’ll give this one a try. If you have a newer version please give me a link. Thanks
foxyshadis
20th May 2006, 04:22
No pb. It would be good to have a version that adjusts like you propose, though. Maybe just selecting from two different functions?
I edited the post. Even or Odd can be used to taste, once it's bobbed (and speed should be identical since eedi isn't temporal).
neuron2
20th May 2006, 04:25
EDIT: I found msharpen "Version 1.10 beta 2" so I’ll give this one a try. If you have a newer version please give me a link. Thanks Gosh, I wonder where you found that. :)
That is the latest version.
neuron2
20th May 2006, 04:28
I edited the post. Even or Odd can be used to taste, once it's bobbed (and speed should be identical since eedi isn't temporal). Isn't eedi2 acting on twice as many frames, though?
Seraphic-
20th May 2006, 05:34
neuron2, did the code you gave me to try have the "adaptive deinterlacer for moving areas only" you talked about turned on?
Thanks
neuron2
20th May 2006, 06:40
Read the documents and try to answer it yourself. At some point spoon feeding comes to an end. :)
Hint: read about TDeint.
EDIT: The answer is yes, of course. :)
Seraphic-
20th May 2006, 06:45
Alright. Well, thanks for all your help.
foxyshadis
20th May 2006, 07:52
Isn't eedi2 acting on twice as many frames, though?
Benchmark it. ;) TDeint will not ask for neighboring frames from edeint, it only uses it to fill the holes that it would normally interpolate itself.
Seraphic-
30th May 2006, 07:52
Hi, neuron2
I've done some testing but I wanted to get your feedback on this. How would a "adaptive deinterlacer" compare to using VirtualDub's "Blend fields together" deinterlacer?
Thanks
Boulder
30th May 2006, 07:59
An adaptive deinterlacer will give you much better quality. Besides, VDub's filtering uses RGB32 (or 24?) for processing which will force at least two colorspace conversions, original colorspace->RGB->final colorspace.
neuron2
30th May 2006, 13:27
Boulder is spot on.
I would add that many people find the ghosting that results from blend deinterlacing to be highly objectionable.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.