View Full Version : First time using avisynth, need advice
kutjong
4th January 2009, 21:31
I have about 24 min of DV PAL (interlaced, BFF) footage that I want to convert to xvid. For a target size, I would be happy with about 200 mb.
Ok, so first I believe I want to deinterlace, because I want to end up with progressive 25 fps. What is a good deinterlacer for this purpose? IMO, this footage shouldn't be too hard to deinterlace since the camera remains static all the time and movement is fairly limited.
I may also want to do some mild denoising, as DV is quite noisy, especially in dark areas and I think denoising makes compression easier. What denoising filters do you recommend?
As for aspect ratio, the resolution is standard PAL (720x576) and DAR is 16/9. I guess the best solution for this is to resize to 720x405?
This is how my script looks thus far:
Load_Stdcall_plugin("yadif.dll")
AVISource("C:\Casbah.avi")
Yadif(clip, int "0", int "0")
FastBicubicResize(720,405)
This is my first time using avisynth and I don't know where to go from here... I appreciate any help. :)
Oh, and here's a sample (http://koti.mbnet.fi/mara87/misc/Casbah.rar).
Nightshiver
4th January 2009, 23:36
You have an .avi for a sample? No mpeg files?
neuron2
4th January 2009, 23:40
His source is DV. Why would he post an MPEG file?
IanB
4th January 2009, 23:55
Yadif is a reasonable smart bob. The correct syntax is Yadif(0, 0)
I would choose a sharper resizer like the internal Spline36Resize(). FastBicubicResize() is a fairly old external plugin and the internal resizers are very fast.
For Xvid the height needs to be an even number and preferable a number divisible by 16.
Popular 16:9 mod16 Xvid sizes with the aspect error.
512x288 0%
544xx304 1.2%
576x320 2.2%
592x336 -1.6%
624x352 -0.5%
656x368 0.5%
688x384 1.4%
704x400 -1.8%
For decoding DV I would recommend Cedocida (http://neuron2.net/misc/cedocida020.zip).
Seeing you have an interlaced source working in "YUY2" may avoid any chroma problems. AVISource("C:\Casbah.avi", pixel_type="YUY2").
24 Minutes and 200mb would be 1000kbits video and 128kbits audio, this is generous and extra denoising may not be necessary.
Gavino
5th January 2009, 00:10
The correct syntax is Yadif(clip, 0, 0)
To clarify that, in the context of kutjong's original script, it would be simply Yadif(0, 0).
kutjong
5th January 2009, 01:57
Thanks for your help thus far! :)
My script now looks like this:
Load_Stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")
AVISource("Casbah.avi")
Yadif(0, 0)
Spline36Resize(656, 368)
Any other recommendations for deinterlacer? Speed is not an issue. :)
For decoding DV I would recommend Cedocida.
Seeing you have an interlaced source working in "YUY2" may avoid any chroma problems. AVISource("C:\Casbah.avi", pixel_type="YUY2").
I don't understand what you mean here... The source is YV12. :confused:
Another thing, what YV12 option should I check Cedocida's options? My guess would be DV?
Also, I hope it's ok if I additionally ask for advice with xvid encoder settings.
Bitrate will be quite high, about 1200 kbps, so for matrix I guess MPEG is fine, I haven't looked into any custom matrices...
Additional settings (unrestricted):
Adaptive quantization, Qpel, GMC, Trellis quantization
B-Vops 2, Q ratio 1.5, Q offset 1, packed bitstream
Motion search precision 6 (ultra), VHQ 1, VHQ B-frames, chroma motion, turbo
Any settings anybody thinks I should change? I'm going to put keyframes to every tenth frame since there is no scene change in this footage, the camera remains static all the way. :cool:
thetoof
5th January 2009, 21:07
Any other recommendations for deinterlacer? Speed is not an issue. :)
http://avisynth.org/mediawiki/External_filters#Deinterlacing
IanB
5th January 2009, 22:46
I don't understand what you mean here... The source is YV12.
Another thing, what YV12 option should I check Cedocida's options? My guess would be DV?Your source is Pal DV, i.e. it has DV's unusual chroma placement, and there are a whole raft of issues with interlaced YV12. Cedocida can do YV12 in 3 flavours, hence my recommending the YUY2 option.
Cedocida does a fully correct job converting DV chroma to YUY2. I wanted to make it easy for you and just make the issues go away, hence YUY2.
IIRC the panasonic DV decoder outputs RGB24 and it does a poxy job on aligning the chroma and has luma range issues. Yadif only does YUY2 and YV12.
With YUY2 from Cedocida, there are no level issues, what is on your tape ends up in YUY2, i.e. you get to choose how to control the levels if anything needs to be done.
With YUY2 there are no chroma placement issues, YUY2 has no vertical subsampling.
As Xvid is a 4:2:0 format and matches Avisynth's default YV12, you can convert to YV12 after all the interlaced issues have been eliminated.Load_Stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")
AVISource("Casbah.avi", Pixel_type="YUY2") # Using Cedocida for DV
Yadif(0, 0) # Deinterlace
ConvertToYV12()
Spline36Resize(656, 368)
For the Xvid I am inclined to leave QPel and GMC off. Many hardware player still fubar them and they do not offer very much quality wise on generous bandwidth encodes.
Blue_MiSfit
7th January 2009, 02:20
All excellent advice, so far!
As far as the denoising goes, I'd suggest fft3dfilter, or fft3dgpu if you have a fast graphics card.
DV usually has very noisy chroma, so I'd clean that right off the bat (after deinterlacing). So, taking the existing script and modifying it a bit:
Load_Stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")
AVISource("Casbah.avi", Pixel_type="YUY2") # Using Cedocida for DV
Yadif(0, 0) # Deinterlace
ConvertToYV12()
fft3dfilter(plane=3, sigma=2) #clean the chroma planes, tweak sigma as necessary
fft3dfilter(plane=0, sigma=1, sigma2=2, sigma3=2, sigma4=1) #clean the luma plane, tweak the sigmas as necessary
gradfunkmirror(1.51) #Dither the banding that fft3dfilter might reveal
Spline36Resize(1024, 576) #why not expand horizontally to 1:1, or leave at 720x576 and set 16x9 when muxing?
Also, if you're not happy with the loss of motion fluidity inherent in 25i -> 25p, you might encode in 50p (i.e. set YADIF to mode=1).
Just some thoughts :)
~MiSfit
kutjong
10th January 2009, 20:02
Where can I get the plugin required for gradfunkmirror? Googling this function didn't show up much...
thetoof
10th January 2009, 20:53
3rd link of "gradfunkmirror" on google:http://forum.doom9.org/showthread.php?p=1111315#post1111315
you'll also need gradfun2db http://kosmos.kawaii-shoujo.net/gradfun2db/
kutjong
10th January 2009, 21:04
Yes I looked into that thread, but I don't know what to do with the code... :o Where do I insert it?
And gradfun2db I have installed. :)
thetoof
10th January 2009, 21:27
oh, when you have script functions like this, save them as functionname.avsi in your plugins directory and they'll be autoloaded just like dlls.
Blue_MiSfit
10th January 2009, 22:18
Yeah, gradfunkmirror is just a little wrapper for gradfun2db that fixes its curious behavior of not dithering the edges of images.
kutjong
11th January 2009, 00:21
Ok, thanks. :) I've also switched to x264 for compression and I intend to keep resolution and just use PAR flags in MKV.
BTW, when examining the original DV avi file with gspot, it tells me that there is "1.35 GB unneeded bytes at end of file". Is there an easy way to get rid of these unneeded bytes?
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.