DV Info Net

DV Info Net (https://www.dvinfo.net/forum/)
-   Techniques for Independent Production (https://www.dvinfo.net/forum/techniques-independent-production/)
-   -   Deinterlacing (https://www.dvinfo.net/forum/techniques-independent-production/38539-deinterlacing.html)

Drew Mandac April 8th, 2005 10:46 AM

Johnathon (or any other AVISynth experts). I get CFHD and DVSD fourcc errors. Do you know how I go about telling AVISynth where the decompressors are on my computer? Is there some sort of "include" line that needs to be in the script?

TIA...


EDIT: I seemed to have solved the DVSD error by downloading the Panasonic codec from http://users.tpg.com.au/mtam/install_panvfwdv.htm

Jonathon Wilson April 8th, 2005 02:50 PM

Avisynth relies on the underlying operating system for codec registration. There's no separate avisynth-specific 'registration' of codecs. If it's available to windows, its available to avisynth. However, this varies by the type of source function you use:

AVISource() needs proper VFW (Video For Windows) registration. I've found these to be things like straight uncompressed AVI and HuffyYUV, and little else.

If your codec is a DirectShow codec (which I'm guessing yours are), you'll need to use:

DirectShowSource() instead of AVISource. The big trick here is to specify the framerate of your source material. Given that you're in the USA, I'm guessing your framerate will be 29.970.

Try a line like:

Code:

src = DirectShowSource("C:\MyAviFile.avi", 29.970)
return src


Kyle Edwards April 10th, 2005 12:18 AM

<<<-- Originally posted by Jonathon Wilson : AVISource() needs proper VFW (Video For Windows) registration. I've found these to be things like straight uncompressed AVI and HuffyYUV, and little else.-->>>

Just about everything minus WMV, RM, and Cineform's codec that comes with Premiere. Directshow takes care of that just fine.

Benjamin Durin April 11th, 2005 01:21 AM

Jonathon, your tutorial is great. I already used avisynth to convert some video before but I especially liked the comparison you made of the different filters. I find it very useful. The only reproach I would make is the jpeg compression is too much. The artifacts don't help to compare the filters. Otherwise it's all good !

Jonathon Wilson April 11th, 2005 06:25 AM

new 'Film Look' article available
 
Agreed! It's even worse for movies, as any kind of compression on the video makes it really hard to compare... but making full AVIs available isn't really a possibility unfortunately. However, providing links to PNGs or similar for images is probably a good idea. I'll see if I can do some retrofitting.

By the way -- I've added a new article, which makes an attempt at a 'Film Look' using some footage provided by Riley.

See it here: http://aqua-web.dyndns.org/d/page.php?ID=Avisynth24p

And yep -- the images are JPGs again. They are saved with 100% quality, but there's still compression. Movies also have pretty serious compression, but that's the reality of limited bandwidth.

On another note, Kin provided me with his script for cleaning video using Avisynth and it really works well. I've had the chance to run it, and it has some really nice features -- which I will now be including in my own stuff :) Another advantage for some of you overseas folks -- his original script is for PAL sources. I've adapted it for NTSC and will include links to both versions.

Once I get the time, I'll put another article up showing his approach. Highlights include a nice 'deringer' for removing oversharpening, and good noise reduction, among others.

Rokta Bija April 11th, 2005 06:53 PM

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 April 11th, 2005 07:01 PM

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

Jonathon Wilson April 11th, 2005 10:57 PM

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!

Josh Barker April 12th, 2005 08:52 PM

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

Jonathon Wilson April 12th, 2005 10:47 PM

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.

Riley Harmon April 13th, 2005 12:41 PM

hey josh what are the AVSI and AVS scripts for the mvbob method you talk about? thanks

Josh Barker April 13th, 2005 01:55 PM

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!).

Jonathon Wilson April 13th, 2005 02:13 PM

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.

Rokta Bija April 13th, 2005 03:24 PM

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()

Josh Barker April 13th, 2005 06:11 PM

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)
}

Rokta Bija April 15th, 2005 06:33 PM

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?

Patrick Jenkins April 20th, 2005 08:53 PM

What's a good format to save the final 24P to (I'm assuming a lossless, progressive format)?

Kyle Edwards April 20th, 2005 10:41 PM

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?

Patrick Jenkins April 21st, 2005 10:18 AM

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)?

Kin Kwan April 21st, 2005 10:58 AM

HuffYUV is a good choice. It's what I use, too! (But the files are BBBIIIIIIIGGGG)

Kyle Edwards April 21st, 2005 12:08 PM

Quote:

Originally Posted by Patrick Jenkins
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)?

All comes back down to, what is your final product? Are you putting the video on the web, archiving your work, or putting onto DVD? DV isn't stuck at 29.976, just 720x480. I've made plenty of 18fps and 23.976 DV files.

HUFFYUV and Lagarith (which is basically HUFFYUV but tweaked, you get much smaller file sizes) are great for archiving, but they will take up alot of room.


All times are GMT -6. The time now is 12:40 PM.

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