Log in

View Full Version : Multiple sources in one avs file.


mattstan
4th August 2008, 11:25
Sorry for the newbie question I just can't seem to find out how to do this, what I would think would be, simple task.

Can I have multiple source files in one .avs file and get them to play one after the other?

The code below apparently just plays Vid_03.rm - but I guess what it's doing is loading 01, and then seeing a second load instruction straight away and loading 02, and then loading 03 and playing that. How do I specify not to load the subsequent files till the first ones have played through?

DirectShowSource("D:\Test\Vid_01.rm")
DirectShowSource("D:\Test\Vid_02.rm")
DirectShowSource("D:\Test\Vid_03.rm")

Thanks.

Gavino
4th August 2008, 11:34
DirectShowSource("D:\Test\Vid_01.rm")
\ + DirectShowSource("D:\Test\Vid_02.rm")
\ + DirectShowSource("D:\Test\Vid_03.rm")

mattstan
4th August 2008, 12:06
Thanks Gavino. I couldn't work out the notation. Cheers.

Guest
4th August 2008, 13:27
You probably want ++ instead of + to avoid sync problems.

mattstan
4th August 2008, 13:29
You probably want ++ instead of + to avoid sync problems.
As in:

DirectShowSource("D:\Test\Vid_01.rm")
\ ++ DirectShowSource("D:\Test\Vid_02.rm")
\ ++ DirectShowSource("D:\Test\Vid_03.rm")

Can you explain why to me please?

Many thanks.

Edit--

Forget that I just found the (un)AllignedSplice page:
http://avisynth.org/mediawiki/Splice

Yes I want AlignedSplice - Thanks.

--End Edit

themostestultimategenius
5th August 2008, 14:34
a = DirectShowSource("Video 1")
b = DirectShowSource("Video 2")
c = DirectShowSource("Video 3")
d = a++b++c
Return d

mattstan
5th August 2008, 15:23
a = DirectShowSource("Video 1")
b = DirectShowSource("Video 2")
c = DirectShowSource("Video 3")
d = a++b++c
Return d

Hi themostestultimategenius,

Is there any difference between doing it as I did:

DirectShowSource("D:\Test\Vid_01.rm")
\ ++ DirectShowSource("D:\Test\Vid_02.rm")
\ ++ DirectShowSource("D:\Test\Vid_03.rm")

and using variables as you did?

a = DirectShowSource("Video 1")
b = DirectShowSource("Video 2")
c = DirectShowSource("Video 3")
d = a++b++c
Return d

Or is it just a difference in notation and the end result is identical?

Thanks.

Gavino
5th August 2008, 15:58
The end result is identical - it's mostly a matter of taste and what you find easier to remember and understand.

The '\' is actually a 'line continuator', allowing you to split a statement over more than one line, so using the direct approach (that I posted) you could replace all 3 lines by just one long one.

OTOH, if your script is more complicated than this, and you want to refer to the individual sources later on (to apply different filters to each, say), assignment to variables as shown by themostestultimategenius, is needed.

mattstan
5th August 2008, 19:54
Thanks Gavino. Got it.
Cheers.

chriszxl
6th August 2008, 04:16
Anyone can tell me ,if form different source ....as:

1,
DirectShowSource("D:\Test\Vid_01.rm")
Trim(200,500)
fft3dfilter(bt=-1)
2,
AVISource("D:\Test\Vid_02.avi")
crop(6,6,702,472)
LanczosResize(512,288)
3,
DGDecode_mpeg2source("D:\Test\Vid_03.d2v")
LanczosResize(512,288)
ChangeFPS(25)

how to merge them all...thx...

hanfrunz
6th August 2008, 08:16
try
v1=DirectShowSource("D:\Test\Vid_01.rm").Trim(200,500).fft3dfilter(bt=-1)
v2=AVISource("D:\Test\Vid_02.avi").crop(6,6,702,472).LanczosResize(512,288)
v3=DGDecode_mpeg2source("D:\Test\Vid_03.d2v").LanczosResize(512,288).ChangeFPS(25)

v1+v2+v3

all clips must have the same size, framerate and colorspace

chriszxl
6th August 2008, 09:27
try
all clips must have the same size, framerate and colorspace

thx a lot.....of course all same, so means I can use any filter in what i wanna merge..then last use "lanczosresize(same).changefps(same).converttoyv12()"

mikeytown2
6th August 2008, 18:14
@chriszxl If you're encountering Aspect Ratio errors with the resize, you could give ZoomBox (http://forum.doom9.org/showthread.php?p=1111789#post1111789) a try. In default mode it will letterbox your content in order to keep the aspect ratio the same. So replace lanczosresize(same) with this in your example filter chain, filling in width and height.


ZoomBox(width,height, ResizeMethod="LanczosResize")


Framerate() (http://avisynth.org/mediawiki/Clip_properties) will get the framerate of a clip btw.

HymnToLife
6th August 2008, 23:06
thx a lot.....of course all same, so means I can use any filter in what i wanna merge..then last use "lanczosresize(same).changefps(same).converttoyv12()"

Yes, but you can imagine that if you have lots of filters to apply to your clips, doing it that way quickly becomes quite unreadable. I personnally prefer to do it like this :


DirectShowSource("D:\Test\Vid_01.rm")
Trim(200,500)
fft3dfilter(bt=-1)
c1 = last

AVISource("D:\Test\Vid_02.avi")
crop(6,6,702,472)
LanczosResize(512,288)
c2 = last

DGDecode_mpeg2source("D:\Test\Vid_03.d2v")
LanczosResize(512,288)
ChangeFPS(25)

c1 + c2 + last

last is a special keyword that represents the output of the last function. So here, before we source another clip that would overwrite what we have done before, we store it in a variable so we can reuse it later.

Gavino
6th August 2008, 23:40
last is a special keyword that represents the output of the last function.
Strictly speaking, last is not a keyword but a special variable. When a statement has no explicit assignment (and only then), Avisynth assigns the value produced by that statement to the variable last.

chriszxl
7th August 2008, 00:03
thx u two guys...:-)
and thr no need c3 = last for DGDecode??
then: c1 + c2 + c3 + last
and how about c1 ++ c2 ++ c3 ++ last?

HymnToLife
7th August 2008, 00:17
and thr no need c3 = last for DGDecode??
then: c1 + c2 + c3 + last


That will not work. If you do this:


DirectShowSource("D:\Test\Vid_01.rm")
Trim(200,500)
fft3dfilter(bt=-1)
c1 = last

AVISource("D:\Test\Vid_02.avi")
crop(6,6,702,472)
LanczosResize(512,288)
c2 = last

DGDecode_mpeg2source("D:\Test\Vid_03.d2v")
LanczosResize(512,288)
ChangeFPS(25)
c3 = last

c1 + c2 + c3 + last

The third clip will be added twice, because due to the c3 = last assignment, both the c3 and last variables contain it. However, you can, if you prefer, do it like this:


DirectShowSource("D:\Test\Vid_01.rm")
Trim(200,500)
fft3dfilter(bt=-1)
c1 = last

AVISource("D:\Test\Vid_02.avi")
crop(6,6,702,472)
LanczosResize(512,288)
c2 = last

DGDecode_mpeg2source("D:\Test\Vid_03.d2v")
LanczosResize(512,288)
ChangeFPS(25)
c3 = last

c1 + c2 + c3

but it is not required to store the third clip in a c3 variable, because the last variable doesn't get overwritten before we spice the clips, so we can use in our splice.

Gavino
7th August 2008, 00:27
and how about c1 ++ c2 ++ c3 ++ last?
As neuron2 pointed out in post #4, it probably should be ++ rather than + here to avoid possible synch problems.
But of course as HymnToLife says, it would be just c1 ++ c2 ++ c3.

I tend (wrongly) to forget about the +/++ distinction - perhaps it's more of an issue with NTSC material, where you don't have a whole number of audio samples per frame.