Deinterlacing - Page 4 at DVinfo.net
DV Info Net

Go Back   DV Info Net > Special Interest Areas > Techniques for Independent Production
Register FAQ Today's Posts Buyer's Guides

Techniques for Independent Production
The challenges of creating Digital Cinema and other narrative forms.

Reply
 
Thread Tools Search this Thread
Old April 11th, 2005, 06:53 PM   #46
Regular Crew
 
Join Date: May 2004
Posts: 61
Here is another script you might want to give a try. It converts 60i to 24p. I doesn't do any other filtering, just 60i to 24p.

Copy the following function between the dotted lines in notepad and save it as "convert60ito24p.avsi" in your Avisynth 2.5\plugin directory. Make sure you save it as an AVSI and not an AVS file.

-------------------------------------

function convert60ito24p (clip video, int mode, int offset)
{
work = assumefieldbased(video)

out =(mode==3) ? interleave(
\selectevery(
\layer(trim(work, 1, 0),
\layer(work, trim(work, 2, 0), "fast"),
\"fast"), 5, 0 + offset),
\selectevery(
\layer(
\layer(work, trim(work, 3, 0),"fast"),
\layer(trim(work, 2, 0), trim(work, 1, 0),"fast"),
\level = 170), 5, 2 + offset)) :

\ (mode==2) ? interleave(
\selectevery(
\layer(trim(work, 1, 0),
\layer(work, trim(work, 2, 0), "fast"),
\"fast"), 5, 0 + offset),
\selectevery(
\layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==1) ? interleave(
\selectevery(trim(work, 1, 0), 5, 0 + offset),
\selectevery(layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==0) ? selectevery(work, 5, 1 + offset, 4 + offset) : work

assumeframebased(out)
}

-----------------------------------------------

Now copy the following AVS file to notepad and change the 3rd line to whatever the filename of your AVI you want to convert. Save it as "convert60ito24p.avs" anywhere you want. This assumes your video is bottom field first, RBG24.

-----------------------------------------------

Import("C:\Program Files\AviSynth 2.5\plugins\convert60ito24p.avsi")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\dgbob.dll")
AVISource("C:\YourVideoHere.avi")
AssumeBFF()
ConvertToYUY2(interlaced=true)
dgbob(0)
convert60ito24p(2,0)
ConvertToRGB24(interlaced=false)

------------------------------------------------

Now open Virtualdub, from the file menu choose "open video file" and open the above AVS file. Once it loads, from the file menu choose "save as AVI" and your done.
Rokta Bija is offline   Reply With Quote
Old April 11th, 2005, 07:01 PM   #47
Regular Crew
 
Join Date: May 2004
Posts: 61
Speaking of comparing videos, here's a script that will show your before and after video side by side and show the difference below.

Copy the follwing between dotted lines to notepad, put your orignal video name and location in the line starting with v1, and modified video in v2. Save as BeforeandAfter.avs Open with Virtualdub.
-------------------------------------------------

# If Videos start at different frames
frameadjust=0

# Videos to compare: (v1 is original, v2 is encoded or whatever)

v1 = AviSource("C:\Original.avi").trim(frameadjust,0)
v2 = AviSource("C:\Modified.avi")
sub = v1.subtract(v2)
substrong = sub.levels(122,1,132,0,255)

return StackVertical(StackHorizontal(v1.subtitle("original"),v2.subtitle("encoded")),StackHorizontal(sub.su btitle("Difference"),substrong.subtitle("Difference amplified")))

--------------------------------------------------

The last line 'amplified")))' is supposed to be on the end of the line above it
Rokta Bija is offline   Reply With Quote
Old April 11th, 2005, 10:57 PM   #48
Regular Crew
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 182
That convert60ito24p script also has the benefit of being way way way faster than the equivilent MV Tools version. On my 1.6 Ghz Athlon, the MVTools convert only does a frame about every 45 seconds -- but switching out DGBob and Rokta's converter, I can run 4-5 frames per second -- roughly a 10x speed increase.

Depending on the source, it can be good enough for final quality. And if not -- you can use it for proofing and run the MV version overnight once you've got everything right.

Haven't tried the difference function yet... that one's next!
__________________
http://www.aqua-web.com
Jonathon Wilson is offline   Reply With Quote
Old April 12th, 2005, 08:52 PM   #49
New Boot
 
Join Date: Nov 2004
Posts: 23
function merge(clip a,clip b,float "opacity"){
opacity=default(opacity,0.5)
return a.MergeLuma(b,opacity).MergeChroma(b,opacity)
}

function convert60ito24p (clip video, int mode, int offset)
{
work = assumefieldbased(video)

out =(mode==3) ? interleave(
\selectevery(
\merge(trim(work, 1, 0),
\merge(work, trim(work, 2, 0))
\), 5, 0 + offset),
\selectevery(
\merge(
\merge(work, trim(work, 3, 0)),
\merge(trim(work, 2, 0), trim(work, 1, 0)),
\level = 170), 5, 2 + offset)) :

\ (mode==2) ? interleave(
\selectevery(
\merge(trim(work, 1, 0),
\merge(work, trim(work, 2, 0))
\), 5, 0 + offset),
\selectevery(
\merge(work, trim(work, 1, 0)), 5, 3 + offset)) :

\ (mode==1) ? interleave(
\selectevery(trim(work, 1, 0), 5, 0 + offset),
\selectevery(merge(work, trim(work, 1, 0)), 5, 3 + offset)) :

\ (mode==0) ? selectevery(work, 5, 1 + offset, 4 + offset) : work

assumeframebased(out)
}

That is the function I use. It runs a lot faster then the version above. The reason being is because they are using "layer". With that you MUST be in the YUY2 color space. With this you can easily be in the YV12 as well as other multiple color spaces as well as a big increase in speed.

I would also recommend using TDeint() instead of dgbob(). dgbob() does yield fair quality, but TDeint() blows it away by far. And if you have the time to render use MVBob(). That uses motion compensated deinterlacing methods to reconstruct a progressive frame from an interlaced frame. Then use either this method or use the function mv60ito24p(). If you use MVBob() with mv60ito24p() you will get the BEST quality possible (only if you can stand the rendering time).

Regards,
Josh
Josh Barker is offline   Reply With Quote
Old April 12th, 2005, 10:47 PM   #50
Regular Crew
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 182
MvBob!!!

Unbelievable! I've never tried MVBob before... it is simply heads and tails above all the others. It almost seems to 'restore' progressive resolution (not possible, but it almost looks like it). Plus -- it's not all _that_ slow... I was seeing several frames per second (3 maybe) on full DV source material. I can live with that for these results!

Thanks for the kick, Josh -- that was definitely worth trying out! I doubt I'll use anything else, now.
__________________
http://www.aqua-web.com
Jonathon Wilson is offline   Reply With Quote
Old April 13th, 2005, 12:41 PM   #51
Major Player
 
Join Date: Jul 2003
Location: Oklahoma
Posts: 424
hey josh what are the AVSI and AVS scripts for the mvbob method you talk about? thanks
Riley Harmon is offline   Reply With Quote
Old April 13th, 2005, 01:55 PM   #52
New Boot
 
Join Date: Nov 2004
Posts: 23
I lurk around the Doom9 forums at http://forum.doom9.org/ in the AviSynth forum. You can find MVBob() there. Here is a direct link to the page which gives you all the filters you need to get MVBob() to work:

http://forum.doom9.org/showthread.php?threadid=84725&perpage=20&highlight=mvbob&pagenumber=4#post606487

@ Jonathon Wilson: Glad you like the results! I do too :-), it is probably the best deinterlacer there is. Usually one such as this one (motion-compensated) is used in television series and anything that is being converted to the big-screen. And it usually costs MEGA $$$ and is done by hardware. We now have a nice software version (little slower, but it works wonders!).
Josh Barker is offline   Reply With Quote
Old April 13th, 2005, 02:13 PM   #53
Regular Crew
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 182
MVBob link

The thread is long with many different iterating versions of the script. However well into the thread, there is a link to an archive containing the finished script and all the plugins needed. You can get it at the following:

http://home.arcor.de/scharfis_brain/mvbob/mvbob.rar

At least for now. Riley, what I did was unrar this whole thing into a directory of its own (something like c:/avisynthwork/mvbob).

Then I added an include at the top of my avisynth script which just includes the mvbob script from that directory:

include("c:/avisynthwork/mvbob/mvbob.avs")

This loads up all the right versions of the plugins etc. (at least it did for me...)

Then you can just:

fixed = src.mvbob()

easy peasy.
__________________
http://www.aqua-web.com
Jonathon Wilson is offline   Reply With Quote
Old April 13th, 2005, 03:24 PM   #54
Regular Crew
 
Join Date: May 2004
Posts: 61
Jonathon, are you getting 3fps at 60ito60p or 60ito30p?

I get 3fps if I leave it at 59.94p but I'm only getting 1-2fps with MVbob for 60ito30p. From 60ito24p I'm getting less than .05fps (15 sec per frame) using mv60ito24p in default mode, and .5fps in mode3. Painful !

Josh, are you using the default settings with mvbob or? Also are you using the mvfps function inside the mv60ito24p in your AVS?

Here is what I am using. See anything that would cause the slowdown?

import("C:\Program Files\AviSynth 2.5\filters\MVBOB\mvbob.avs")
import("C:\Program Files\AviSynth 2.5\filters\MVbob\mv60ito24p.avs")
AVISource("f:\test7\4months - Clip 001.avi")
assumebff()
ConvertToYV12(interlaced=true)
mvbob()
mv60ito24p(mode=3)
ConvertToRGB24()
Rokta Bija is offline   Reply With Quote
Old April 13th, 2005, 06:11 PM   #55
New Boot
 
Join Date: Nov 2004
Posts: 23
I am using mode 2 for mv60ito24p(). I have a hefty computer (3.2 Ghz HT, 1 GB RAM) and rendering is around 1-3 fps. HT is enabled and I've heard (since AviSynth doesn't support dual processors) it may be faster when disabled (haven't tested it yet).

Script I am using:
-------------------------

LoadPlugin("J:\Program Files\AviSynth 2.5\oldplugins\LoadPluginEx2.dll")
LoadPlugin("J:\Program Files\AviSynth 2.5\oldplugins\warpsharp.dll")
ImportPlugin("mvbob.avs")

AVISource("G:\Final Drunk Driving 1.avi",fourCC="CDVC")
TrimTime("00:21:00:00","00:21:20:00") #trimtime function by me

FixBrokenChromaUpsampling() #fixes bug in dv codec
ReInterpolate411() #ntsc capture bug fix

AspectRatio().AddBorders(0,1,0,2) #4:3 to 16:9

AssumeTFF() #not assumebff, I added borders so it shifted to tff
converttoyv12(interlaced=true)

MVBob() #deinterlace
mv60ito24p(2) #60p to 24p

ColorYuv(levels="TV->PC") #fix colors
Levels(10,1.0,255,0,255)

LimitedSharpen(overshoot=7,strength=100) #sharpen the picture

AddBorders(0,37,0,36) #letterbox 16:9
AddAudio() #add fake audio due to dv type-I, I use

ConvertToRGB().GiCoCU("J:\link2\s-curve.amp",photoshop=true) #apply film gamma s-curve

ConvertToYUY2() #not necessary if converting to mpeg-2


-------------------

You may also increase in speed with mv60ito24p() if you use the following instead of the one you downloaded (I modified it to actually increase the speed):

-------------------

function mv60ito24p(clip x, int "mode")
{

mode = default(mode,2)
mbl=0.1
fwd=mvtools0962_mvanalyse(x,isb=false,lambda=4000)
bwd=mvtools0962_mvanalyse(x,isb=true, lambda=4000)

y=x.mvtools0962_mvinterpolate(bwd, fwd, nb = 4,bl = 0.5-mbl, el = 0.5+mbl, wf = "uniform")
interleave(y,x)
mode0=selectevery(5,2)
mode1=merge(selectevery(5,3),selectevery(5,2),opacity=0.5)
mode2=merge(merge(selectevery(5,1),selectevery(5,3),opacity=0.5),selectevery(5,2),opacity=0.3)
mode3=merge(merge(selectevery(5,0),selectevery(5,3),opacity=0.5),merge(selectevery(5,1),selectevery( 5,2),opacity=0.5),opacity=0.5)

(mode==0) ? mode0 : (mode==1) ? mode1 : (mode==2) ? mode2 : mode3

}

function merge(clip a,clip b,float "opacity"){
opacity=default(opacity,0.5)
return a.MergeLuma(b,opacity).MergeChroma(b,opacity)
}
Josh Barker is offline   Reply With Quote
Old April 15th, 2005, 06:33 PM   #56
Regular Crew
 
Join Date: May 2004
Posts: 61
I tired the modified mv60ito24p and it is faster, thanks. I also put the mvbob() function inside the AVS instead of importing it and that picked up speed also.

In the Avisource line, are you forcing a different codec with the fourcc command?

I had not used the overshoot parameter in LimitedSharpen, I liked the result. When I tried some other numbers, I didn't notice much difference from 7.

What do these two lines do:

ColorYuv(levels="TV->PC") #fix colors
Levels(10,1.0,255,0,255)

Am I correct in thinking the ColorYuv(levels="TV->PC") scales a 16-235 to 0-255? And what is levels() doing?
Rokta Bija is offline   Reply With Quote
Old April 20th, 2005, 08:53 PM   #57
Major Player
 
Join Date: Sep 2004
Location: Maryland, USA
Posts: 382
What's a good format to save the final 24P to (I'm assuming a lossless, progressive format)?
Patrick Jenkins is offline   Reply With Quote
Old April 20th, 2005, 10:41 PM   #58
Major Player
 
Join Date: Nov 2004
Location: LI, NY
Posts: 274
Quote:
Originally Posted by Patrick Jenkins
What's a good format to save the final 24P to (I'm assuming a lossless, progressive format)?
Encode to your final product straight from the script. If not, try HUFFYUV or Lagarith, both lossless. Or, why not DV again?
Kyle Edwards is offline   Reply With Quote
Old April 21st, 2005, 10:18 AM   #59
Major Player
 
Join Date: Sep 2004
Location: Maryland, USA
Posts: 382
Well.. DV isn't lossless so there's degeneration to worry about, but also, won't saving as DV effectively reinterlace your material - at the very least bring back fields? Also, NTSC DV is stuck w/ 29.97 (or there abouts) frame rate, so inorder to save the 23.976 you'd have to do some sort of pull down (or something) - but I'm still trying to figure this process out.

Wouldn't it be all around better to use a final file format that's progressive and lossless (I've got Huffy, I'll experiement with that)?
Patrick Jenkins is offline   Reply With Quote
Old April 21st, 2005, 10:58 AM   #60
Regular Crew
 
Join Date: Jul 2004
Location: Plano, TX
Posts: 120
HuffYUV is a good choice. It's what I use, too! (But the files are BBBIIIIIIIGGGG)
Kin Kwan is offline   Reply
Reply

DV Info Net refers all where-to-buy and where-to-rent questions exclusively to these trusted full line dealers and rental houses...

B&H Photo Video
(866) 521-7381
New York, NY USA

Scan Computers Int. Ltd.
+44 0871-472-4747
Bolton, Lancashire UK


DV Info Net also encourages you to support local businesses and buy from an authorized dealer in your neighborhood.
  You are here: DV Info Net > Special Interest Areas > Techniques for Independent Production


 



All times are GMT -6. The time now is 10:34 AM.


DV Info Net -- Real Names, Real People, Real Info!
1998-2024 The Digital Video Information Network