Log in

View Full Version : Help needed creating a function


Boulder
7th November 2004, 16:27
Hi all,

this question/problem derives from Scharfi's answer to my problem regarding converting Monty Python DVD's back to PAL.

He gave me the function to use on the interlaced based parts and I'm going to use Restore24 to get the progressive based parts restored. The source material is a mixture of these two cases and that's why I would like to treat them in the same script, combining the parts in the end and saving the intermediate file, which I would then process like a normal PAL encode.

My script is like this:


LoadPlugin("c:\progra~1\avisynth 2.5\cplugins\avisynth_c.dll")
LoadCPlugin("c:\progra~1\avisynth 2.5\cplugins\smartdecimate.dll")
video=MPEG2Source("c:\temp\dvd-rip\python\python.d2v",idct=7,cpu=4,ipp=true)
audio=WAVSource("g:\python\python.wav").ConverttoMono()
AudioDub(video,audio)

part1=Trim(0,1525).r24()
part2=Trim(1526,3753).ntsc2pal()
part3=Trim(3754,4345).r24()
part4=Trim(4346,7040).ntsc2pal()
part5=Trim(7041,7229).r24()
part6=Trim(7230,12696).ntsc2pal()
part7=Trim(12697,13734).r24()
part8=Trim(13735,26720).ntsc2pal()
part9=Trim(26721,27797).r24()
part10=Trim(27798,27992).ntsc2pal()
part11=Trim(27993,30056).r24()
part12=Trim(30057,36367).ntsc2pal()
part13=Trim(36368,47773).r24()
part14=Trim(47774,52780).ntsc2pal()
part15=Trim(52781,0).r24()

part1+part2+part3+part4+part5+part6+part7+part8+part9+part10+part11+part12+part13+part14+part15

function ntsc2pal(clip last){
x=KernelBob(order=1).AssumeFrameBased()
a=x.Trim(1,0).MergeLuma(x,0.5).MergeChroma(x,0.5)
b1=x.DeleteFrame(0).MergeLuma(x.DuplicateFrame(0),0.5).MergeChroma(x.DuplicateFrame(0),0.5)
b=b1.MergeLuma(x,0.5).MergeChroma(x,0.5)
Interleave(b,a).ChangeFPS(25)
}

function r24(clip last){
in=AssumeTFF().R24KernelBob(0)
out=AssumeTFF().MatchBob()
Restore24(in,out,1250,2997)
}


As I'm a total newbie when it comes to creating functions (I've studied very little C++ long time ago) and since there appears to be no tutorials regarding the matter, I need some help to get it working. Currently it only displays the last part (part15).

Could anyone please bash the thing in order?

stickboy
7th November 2004, 21:13
Originally posted by Boulder
As I'm a total newbie when it comes to creating functions (I've studied very little C++ long time ago) and since there appears to be no tutorials regarding the matter, I need some help to get it working.I don't see anything obviously wrong. The functions themselves look like they should be fine, at least.
Currently it only displays the last part (part15).What is "it"? You mean the script only displays the last part?

scharfis_brain
7th November 2004, 21:23
it is NOT a good idea (it is due to AVIsynth strangenesses) , splitting the video and calling several instances of r24 before the processing.


I suggest this - maybe more complex - way:


function ntsc2pal(clip last){
x=KernelBob(order=1).AssumeFrameBased()
a=x.Trim(1,0).MergeLuma(x,0.5).MergeChroma(x,0.5)
b1=x.DeleteFrame(0).MergeLuma(x.DuplicateFrame(0),0.5).MergeChroma(x.DuplicateFrame(0),0.5)
b=b1.MergeLuma(x,0.5).MergeChroma(x,0.5)
Interleave(b,a).ChangeFPS(25)
}

function r24(clip last){
in=AssumeTFF().R24KernelBob(0)
out=AssumeTFF().MatchBob()
Restore24(in,out,1250,2997)
}
xxxsource("video.xxx")

x=r24()
y=ntsc2pal()
x+y


render this to a file.

open that file after processing again:


avisource("processed-file.avi")
x=last.trim(0,framecount(last))
y=last.trim(framecount(last),0)

#now to the cuts:
part1=x.trim(0,1433)
part2=y.trim(1434,4564)
#....

part1+part2+....

Leak
7th November 2004, 21:45
Originally posted by scharfis_brain
it is NOT a good idea (it is due to AVIsynth strangenesses) , splitting the video and calling several instances of r24 before the processing.

True, but why not do it the easier way:


LoadPlugin("c:\progra~1\avisynth 2.5\cplugins\avisynth_c.dll")
LoadCPlugin("c:\progra~1\avisynth 2.5\cplugins\smartdecimate.dll")
video=MPEG2Source("c:\temp\dvd-rip\python\python.d2v",idct=7,cpu=4,ipp=true)
audio=WAVSource("g:\python\python.wav").ConverttoMono()
AudioDub(video,audio)

a=r24()
b=ntsc2pal()

part1=a.Trim(0,1525)
part2=b.Trim(1526,3753)
part3=a.Trim(3754,4345)
part4=b.Trim(4346,7040)
part5=a.Trim(7041,7229)
part6=b.Trim(7230,12696)
part7=a.Trim(12697,13734)
part8=b.Trim(13735,26720)
part9=a.Trim(26721,27797)
part10=b.Trim(27798,27992)
part11=a.Trim(27993,30056)
part12=b.Trim(30057,36367)
part13=a.Trim(36368,47773)
part14=b.Trim(47774,52780)
part15=a.Trim(52781,0)

part1+part2+part3+part4+part5+part6+part7+part8+part9+part10+part11+part12+part13+part14+part15

function ntsc2pal(clip last){
x=KernelBob(order=1).AssumeFrameBased()
a=x.Trim(1,0).MergeLuma(x,0.5).MergeChroma(x,0.5)
b1=x.DeleteFrame(0).MergeLuma(x.DuplicateFrame(0),0.5).MergeChroma(x.DuplicateFrame(0),0.5)
b=b1.MergeLuma(x,0.5).MergeChroma(x,0.5)
Interleave(b,a).ChangeFPS(25)
}

function r24(clip last){
in=AssumeTFF().R24KernelBob(0)
out=AssumeTFF().MatchBob()
Restore24(in,out,1250,2997)
}


That'll do basically the same thing with just one instance of each filter and without the need for an intermediate file...

np: Gold Chains & Sue Cie - Crowd Control (When The World Was Our Friend)

scharfis_brain
7th November 2004, 21:55
hi leak.
it probably won't be easier.

I also thought about exactly this approach!

mainly one reason, that makes it more complicated:

for finding the cuts, you need several passes (editing script, reopen it, editing it, reopen it...)

this can take a very long time, cause r24 is slow and not very nice with user interaction.
also some on/off (due to the trims) switches of r24 aren't that good, too.

the cut-frames from boulders very first script won't fit in your version (in mine, they won't fit, too. of course)

but that's just my opinion, let boulder decide :)

Boulder
7th November 2004, 22:17
Thanks to everyone, lots of food for thought:)

Scharfi's method might suit me just fine since I would go via an intermediate file anyway. Fortunately the episodes are around 30 minutes each so the size won't be a problem even with lossless codecs. You wouldn't happen to know a good choice with YV12 support? VBLE might do since the output material will be progressive.

My initial script produces a clip that has a proper length but only shows the last part that is added. My guess is that this is mostly due to Avisynth and the complexity of Restore24.