Log in

View Full Version : AviSynth script to decode PAL DV


tebasuna51
20th February 2010, 02:32
After read many post in this thread I'm not sure about the script to use (I don't know very much about video management).

I'm running XP SP3 in a intel Dual core and Cedocida 0.2 installed.

I want make a copy of my old miniDV tapes (holydays and family) filmed with a Sony DCR-TRV8E (PAL 4:3). I want the video progressive, 50fps and PAR 1:1 to encode with x264.

Maybe a first approach can be:
AviSource("D:\Test_dv.avi")

Crop(0,4,0,0) # The sources have noise in first 4 lines

AssumeBFF()

edi=nnedi2(field=-2)
YADIFmod(mode=1, edeint=edi)

Spline36Resize(720,528) # verified with a square filmed with my camera

ConvertToYV12() # to encode with x264
Is correct?

Some other filters to modify the chroma?
I see some samples in the thread but I don't know if is only for NTSC.

Some denoisers recommended for this kind of source?

Thanks!

hydra3333
21st February 2010, 08:21
Looks OK to me. See this http://forum.doom9.org/showthread.php?p=1375446#post1375446
It was supposed to also do motion stabilization too (assuming the source clip) is relatively clean, and re-interlace afterward ... you could omit those. Omitting re-interlacing leaves it 50fps progressive like your script.

Here http://forum.doom9.org/showthread.php?p=1374359#post1374359 is some amazing deinterlacing... please see the example clip in the post underneath that one, to get a feel if this is "better" for you depending on the nature of your source. That example is really amazing.

That denoises with the newer mvtools2's MDegrain2 although you could use 1 or 3 according to your source, examples at http://avisynth.org.ru/mvtools/mvtools2.html#examples

Spain... PAL ? ... I am unsure why you are vertically resizing (shrinking just the vertical component) from 576-4 to 528 instead of adding 4 black lines back at the end in after cropping and leaving it at the standard PAL 720x576.

hydra3333
21st February 2010, 08:43
Just for fun, here's a few functions I use to tell what's done to a clip with processing. Hint, to compare "before" and "after" clips they must be the same dimensions/rate/interlacing etc. In you case, position the function calls sort of like this (to test you might like to TRIM some part of the source after the avisource/bff.

# you might want to do a TRIM hereabouts
Crop(4,0,0,0) # The sources have noise in first 4 lines
AssumeBFF()
edi=nnedi2(field=-2)
YADIFmod(mode=1, edeint=edi)
# now assume you do your denoising etc about here
original=LAST # save clip before processing
# denoising etc here
L=LAST # save clip after processing
# show compared
zzzBox2(original,"original",L,"processed")
# or zzzBox4(original,"original",L,"processed")
# or zzzBox8(original,"original",L,"processed")

# finish off with a resize to your preferred height
Spline36Resize(720,528) # verified with a square filmed with my camera
ConvertToYV12() # to encode with x264
### define functions
Function zzzBox2(Clip a, string asub, Clip b, string bsub) {
hClip = a.height()
wClip = a.width()
stackvertical(stackhorizontal(a.crop(0*wClip/2,0*hClip/2,-1*wClip/2,-1*hClip/2).subtitle(aSub,size=10), \
b.crop(1*wClip/2,0*hClip/2,-0*wClip/2,-1*hClip/2).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/2,1*hClip/2,-1*wClip/2,-0*hClip/2).subtitle(bSub,size=10), \
a.crop(1*wClip/2,1*hClip/2,-0*wClip/2,-0*hClip/2).subtitle(aSub,size=10)))
}
Function zzzBox4(Clip a, string asub, Clip b, string bsub) {
hClip = a.height()
wClip = a.width()
stackvertical(stackhorizontal(a.crop(0*wClip/4,0*hClip/4,-3*wClip/4,-3*hClip/4).subtitle(aSub,size=10), \
b.crop(1*wClip/4,0*hClip/4,-2*wClip/4,-3*hClip/4).subtitle(bSub,size=10), \
a.crop(2*wClip/4,0*hClip/4,-1*wClip/4,-3*hClip/4).subtitle(aSub,size=10), \
b.crop(3*wClip/4,0*hClip/4,-0*wClip/4,-3*hClip/4).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/4,1*hClip/4,-3*wClip/4,-2*hClip/4).subtitle(bSub,size=10), \
a.crop(1*wClip/4,1*hClip/4,-2*wClip/4,-2*hClip/4).subtitle(aSub,size=10), \
b.crop(2*wClip/4,1*hClip/4,-1*wClip/4,-2*hClip/4).subtitle(bSub,size=10), \
a.crop(3*wClip/4,1*hClip/4,-0*wClip/4,-2*hClip/4).subtitle(aSub,size=10)), \
stackhorizontal(a.crop(0*wClip/4,2*hClip/4,-3*wClip/4,-1*hClip/4).subtitle(aSub,size=10), \
b.crop(1*wClip/4,2*hClip/4,-2*wClip/4,-1*hClip/4).subtitle(bSub,size=10), \
a.crop(2*wClip/4,2*hClip/4,-1*wClip/4,-1*hClip/4).subtitle(aSub,size=10), \
b.crop(3*wClip/4,2*hClip/4,-0*wClip/4,-1*hClip/4).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/4,3*hClip/4,-3*wClip/4,-0*hClip/4).subtitle(bSub,size=10), \
a.crop(1*wClip/4,3*hClip/4,-2*wClip/4,-0*hClip/4).subtitle(aSub,size=10), \
b.crop(2*wClip/4,3*hClip/4,-1*wClip/4,-0*hClip/4).subtitle(bSub,size=10), \
a.crop(3*wClip/4,3*hClip/4,-0*wClip/4,-0*hClip/4).subtitle(aSub,size=10)))
}
Function zzzBox8(Clip a, string asub, Clip b, string bsub) {
hClip = a.height()
wClip = a.width()
stackvertical(stackhorizontal(a.crop(0*wClip/8,0*hClip/8,-7*wClip/8,-7*hClip/8).subtitle(aSub,size=10), \
b.crop(1*wClip/8,0*hClip/8,-6*wClip/8,-7*hClip/8).subtitle(bSub,size=10), \
a.crop(2*wClip/8,0*hClip/8,-5*wClip/8,-7*hClip/8).subtitle(aSub,size=10), \
b.crop(3*wClip/8,0*hClip/8,-4*wClip/8,-7*hClip/8).subtitle(bSub,size=10), \
a.crop(4*wClip/8,0*hClip/8,-3*wClip/8,-7*hClip/8).subtitle(aSub,size=10), \
b.crop(5*wClip/8,0*hClip/8,-2*wClip/8,-7*hClip/8).subtitle(bSub,size=10), \
a.crop(6*wClip/8,0*hClip/8,-1*wClip/8,-7*hClip/8).subtitle(aSub,size=10), \
b.crop(7*wClip/8,0*hClip/8,-0*wClip/8,-7*hClip/8).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/8,1*hClip/8,-7*wClip/8,-6*hClip/8).subtitle(bSub,size=10), \
a.crop(1*wClip/8,1*hClip/8,-6*wClip/8,-6*hClip/8).subtitle(aSub,size=10), \
b.crop(2*wClip/8,1*hClip/8,-5*wClip/8,-6*hClip/8).subtitle(bSub,size=10), \
a.crop(3*wClip/8,1*hClip/8,-4*wClip/8,-6*hClip/8).subtitle(aSub,size=10), \
b.crop(4*wClip/8,1*hClip/8,-3*wClip/8,-6*hClip/8).subtitle(bSub,size=10), \
a.crop(5*wClip/8,1*hClip/8,-2*wClip/8,-6*hClip/8).subtitle(aSub,size=10), \
b.crop(6*wClip/8,1*hClip/8,-1*wClip/8,-6*hClip/8).subtitle(bSub,size=10), \
a.crop(7*wClip/8,1*hClip/8,-0*wClip/8,-6*hClip/8).subtitle(aSub,size=10)), \
stackhorizontal(a.crop(0*wClip/8,2*hClip/8,-7*wClip/8,-5*hClip/8).subtitle(aSub,size=10), \
b.crop(1*wClip/8,2*hClip/8,-6*wClip/8,-5*hClip/8).subtitle(bSub,size=10), \
a.crop(2*wClip/8,2*hClip/8,-5*wClip/8,-5*hClip/8).subtitle(aSub,size=10), \
b.crop(3*wClip/8,2*hClip/8,-4*wClip/8,-5*hClip/8).subtitle(bSub,size=10), \
a.crop(4*wClip/8,2*hClip/8,-3*wClip/8,-5*hClip/8).subtitle(aSub,size=10), \
b.crop(5*wClip/8,2*hClip/8,-2*wClip/8,-5*hClip/8).subtitle(bSub,size=10), \
a.crop(6*wClip/8,2*hClip/8,-1*wClip/8,-5*hClip/8).subtitle(aSub,size=10), \
b.crop(7*wClip/8,2*hClip/8,-0*wClip/8,-5*hClip/8).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/8,3*hClip/8,-7*wClip/8,-4*hClip/8).subtitle(bSub,size=10), \
a.crop(1*wClip/8,3*hClip/8,-6*wClip/8,-4*hClip/8).subtitle(aSub,size=10), \
b.crop(2*wClip/8,3*hClip/8,-5*wClip/8,-4*hClip/8).subtitle(bSub,size=10), \
a.crop(3*wClip/8,3*hClip/8,-4*wClip/8,-4*hClip/8).subtitle(aSub,size=10), \
b.crop(4*wClip/8,3*hClip/8,-3*wClip/8,-4*hClip/8).subtitle(bSub,size=10), \
a.crop(5*wClip/8,3*hClip/8,-2*wClip/8,-4*hClip/8).subtitle(aSub,size=10), \
b.crop(6*wClip/8,3*hClip/8,-1*wClip/8,-4*hClip/8).subtitle(bSub,size=10), \
a.crop(7*wClip/8,3*hClip/8,-0*wClip/8,-4*hClip/8).subtitle(aSub,size=10)), \
stackhorizontal(a.crop(0*wClip/8,4*hClip/8,-7*wClip/8,-3*hClip/8).subtitle(aSub,size=10), \
b.crop(1*wClip/8,4*hClip/8,-6*wClip/8,-3*hClip/8).subtitle(bSub,size=10), \
a.crop(2*wClip/8,4*hClip/8,-5*wClip/8,-3*hClip/8).subtitle(aSub,size=10), \
b.crop(3*wClip/8,4*hClip/8,-4*wClip/8,-3*hClip/8).subtitle(bSub,size=10), \
a.crop(4*wClip/8,4*hClip/8,-3*wClip/8,-3*hClip/8).subtitle(aSub,size=10), \
b.crop(5*wClip/8,4*hClip/8,-2*wClip/8,-3*hClip/8).subtitle(bSub,size=10), \
a.crop(6*wClip/8,4*hClip/8,-1*wClip/8,-3*hClip/8).subtitle(aSub,size=10), \
b.crop(7*wClip/8,4*hClip/8,-0*wClip/8,-3*hClip/8).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/8,5*hClip/8,-7*wClip/8,-2*hClip/8).subtitle(bSub,size=10), \
a.crop(1*wClip/8,5*hClip/8,-6*wClip/8,-2*hClip/8).subtitle(aSub,size=10), \
b.crop(2*wClip/8,5*hClip/8,-5*wClip/8,-2*hClip/8).subtitle(bSub,size=10), \
a.crop(3*wClip/8,5*hClip/8,-4*wClip/8,-2*hClip/8).subtitle(aSub,size=10), \
b.crop(4*wClip/8,5*hClip/8,-3*wClip/8,-2*hClip/8).subtitle(bSub,size=10), \
a.crop(5*wClip/8,5*hClip/8,-2*wClip/8,-2*hClip/8).subtitle(aSub,size=10), \
b.crop(6*wClip/8,5*hClip/8,-1*wClip/8,-2*hClip/8).subtitle(bSub,size=10), \
a.crop(7*wClip/8,5*hClip/8,-0*wClip/8,-2*hClip/8).subtitle(aSub,size=10)), \
stackhorizontal(a.crop(0*wClip/8,6*hClip/8,-7*wClip/8,-1*hClip/8).subtitle(aSub,size=10), \
b.crop(1*wClip/8,6*hClip/8,-6*wClip/8,-1*hClip/8).subtitle(bSub,size=10), \
a.crop(2*wClip/8,6*hClip/8,-5*wClip/8,-1*hClip/8).subtitle(aSub,size=10), \
b.crop(3*wClip/8,6*hClip/8,-4*wClip/8,-1*hClip/8).subtitle(bSub,size=10), \
a.crop(4*wClip/8,6*hClip/8,-3*wClip/8,-1*hClip/8).subtitle(aSub,size=10), \
b.crop(5*wClip/8,6*hClip/8,-2*wClip/8,-1*hClip/8).subtitle(bSub,size=10), \
a.crop(6*wClip/8,6*hClip/8,-1*wClip/8,-1*hClip/8).subtitle(aSub,size=10), \
b.crop(7*wClip/8,6*hClip/8,-0*wClip/8,-1*hClip/8).subtitle(bSub,size=10)), \
stackhorizontal(b.crop(0*wClip/8,7*hClip/8,-7*wClip/8,-0*hClip/8).subtitle(bSub,size=10), \
a.crop(1*wClip/8,7*hClip/8,-6*wClip/8,-0*hClip/8).subtitle(aSub,size=10), \
b.crop(2*wClip/8,7*hClip/8,-5*wClip/8,-0*hClip/8).subtitle(bSub,size=10), \
a.crop(3*wClip/8,7*hClip/8,-4*wClip/8,-0*hClip/8).subtitle(aSub,size=10), \
b.crop(4*wClip/8,7*hClip/8,-3*wClip/8,-0*hClip/8).subtitle(bSub,size=10), \
a.crop(5*wClip/8,7*hClip/8,-2*wClip/8,-0*hClip/8).subtitle(aSub,size=10), \
b.crop(6*wClip/8,7*hClip/8,-1*wClip/8,-0*hClip/8).subtitle(bSub,size=10), \
a.crop(7*wClip/8,7*hClip/8,-0*wClip/8,-0*hClip/8).subtitle(aSub,size=10)))
}

tebasuna51
21st February 2010, 18:46
Thanks, I'll make some test with that.

2Bdecided
22nd February 2010, 16:11
TGMC for deinterlacing.

Whatever you want for denoising (lots of options).

People usually resize up (e.g. 768x576 or 786x576) rather than down (720x528 or 720x540) but it's up to you. You're probably not losing much, if anything, if it's a low end camera.

I'd keep the DV-AVI originals - far easier to edit than what you're creating - and you might decide the deinterlacing and denoising you choose today could be (far) better in five years time. Also a better source for upscaling to HD.

(Potentially - it might be true that the x264 encodes you produce are about as good as the footage will ever look, and keeping the 25Mbps DV-AVIs is overkill).

Cheers,
David.

tebasuna51
22nd February 2010, 17:33
TGMC for deinterlacing.

Thanks, I'll try TGMC also.

People usually resize up (e.g. 768x576 or 786x576) rather than down (720x528 or 720x540) but it's up to you. You're probably not losing much, if anything, if it's a low end camera.
But I resize up, 720x576i 25fps to 720x528p 50fps, the two fields 720x288 are converted to 720x528

I'd keep the DV-AVI originals - far easier to edit than what you're creating - and you might decide the deinterlacing and denoising you choose today could be (far) better in five years time. Also a better source for upscaling to HD.

Of course I keep the original tapes. I want only a copy to store in hard-disk and see with hardware players like WD TV, Xtreamer, ... than don't support DV codec.

um3k
22nd February 2010, 22:31
But I resize up, 720x576i 25fps to 720x528p 50fps, the two fields 720x288 are converted to 720x528

That would be true if you were using a dumb bob, but since you are using a smart bobber like TGMC, you will theoretically lose a bit of resolution scaling down.

tebasuna51
23rd February 2010, 11:07
That would be true if you were using a dumb bob, but since you are using a smart bobber like TGMC, you will theoretically lose a bit of resolution scaling down.

I don't know what is the difference between a 'dumb bob' and a 'smart bob'.
Can you explain me?
Is better upscale to 784x576?

I see TGMC is better than Yadif with my sample (I have noticeable less flicker), then:
AviSource("D:\Test_DV.avi")

Crop(4,4,0,0) # The sources have noise in first 4 lines/columns
AssumeBFF() # Now we have 716x572, 25 fps

tempgaussmc_beta1u(1,1,0,0,0,0,edimode="nnedi2(field=-2)",SVthin=0.0,pelsearch=1) # 50 fps

Spline36Resize(784,576) # (49x16):(36x16) DAR 49:36

ConvertToYV12() # to encode with x264

2Bdecided
23rd February 2010, 11:16
Assuming your camera actually captured it, TGMC gives you a full 720x576. 528 is less than 576. ;)

Typically interlaced video is pre-filtered to the equivalent of less than 576, but not always. It's almost never as little as 288 - a good deinterlacer can almost always recover more than 288 picture lines of effective resolution.

Anyway, far more important: WD TV, Xtreamer etc are going to scale the video again to send to the display. As long as you pick a resolution that doesn't degrade your source, and that your streamer scales nicely to your display's resolution, you'll be fine.

Cheers,
David.