PDA

View Full Version : Cutting And Joining...


EpheMeroN
15th September 2005, 09:51
I have 2 video files that are in VCD format. I want to join them together, and then cut up the video into 15 parts, and finally join them all together while adding an audio track as well. How can I do this in a script?

mg262
15th September 2005, 11:07
If you don't want to uncompressed video and recompress, you shouldn't use AVISynth. Otherwise it's just a question of using Trim and + ...

Trim(0, 100) + trim(150, 250) +...

And then audiodub...

EpheMeroN
15th September 2005, 17:21
And how would I merge the 2 videos into one? Would this suffice?
Video1 = DirectShowSource("C:\Video1.mpg")
Video2 = DirectShowSource("C:\Video2.mpg")
AlignedSplice(Video1,Video2)

And then I'd do all the Trim() calls here.

How would I work AudioDub into this?

movax
15th September 2005, 18:58
Splice the files and then dub a single file over them, though I think you could AudioDub each segment, and then Splice them.

EpheMeroN
16th September 2005, 04:19
Splice the files and then dub a single file over them, though I think you could AudioDub each segment, and then Splice them.
Explain in a sample script please?

stickboy
16th September 2005, 11:20
Video1 = DirectShowSource("C:\Video1.mpg")
Video2 = DirectShowSource("C:\Video2.mpg")
AlignedSplice(Video1,Video2) # This is the same as Video1 + Video2
AudioDub(last, WAVSource("foo.wav"))or if you prefer:Video1 = DirectShowSource("C:\Video1.mpg")
Video2 = DirectShowSource("C:\Video2.mpg")
video = AlignedSplice(Video1,Video2) # This is the same as Video1 + Video2
audio = WAVSource("foo.wav")
AudioDub(video, audio)

EpheMeroN
21st September 2005, 06:20
Okay, so I have a new script that works great (thanks stickboy) with all the perfect cuts to the videos that I want. But, how come when I try to load some blank seconds of video, and then fade it in / out, it doesn't happen? The video just starts up as if the blank clips and fades don't exist.

My Script:
Import("C:\Video Related\AviSynth v2.5.5\Plugins\FunkyDeblock.avs")

Video1 = DirectShowSource("C:\Documents and Settings\User\Desktop\CD1.mpg")
Video2 = DirectShowSource("C:\Documents and Settings\User\Desktop\CD2.mpg")
Blank1 = BlankClip(Video1).Trim(0,59).Amplify(0.0)
Blank2 = BlankClip(Video1).Trim(0,29).Amplify(0.0).FadeIn(29)
Blank3 = BlankClip(Video1).Trim(0,90).Amplify(0.0).FadeOut(90)
Video = AlignedSplice(Blank1,Blank2,Video1,Video2,Blank3,Blank1)
Audio = WAVSource("C:\Documents and Settings\User\Desktop\test.wav")
AudioDub(Video,Audio)

Trim(15300,15802)++Trim(29257,29573)++Trim(42823,42995)++Trim(53325,53725)
\ ++Trim(54197,54327)++Trim(63681,64213)++Trim(76576,76786)
\ ++Trim(89627,90045)++Trim(103319,103718)++Trim(114026,114369)
\ ++Trim(123493,123843)++Trim(135792,135919)++Trim(148399,148649)
\ ++Trim(149590,149845)++Trim(162049,162936)

ConvertToYV12(Interlaced=False)
FunkyDeblock()
LanczosResize(704,480)
AddBorders(8,0,8,0)

stickboy
21st September 2005, 10:06
But, how come when I try to load some blank seconds of video, and then fade it in / out, it doesn't happen? The video just starts up as if the blank clips and fades don't exist.Video = AlignedSplice(Blank1,Blank2,Video1,Video2,Blank3,Blank1)
Audio = WAVSource("C:\Documents and Settings\User\Desktop\test.wav")
AudioDub(Video,Audio)

Trim(15300,15802)++Trim(29257,29573)++Trim(42823,42995)++Trim(53325,53725)You spliced some things to the beginning and end but then you Trim'd them out.

movax
21st September 2005, 14:10
Yep, you have to compensate for the frames that are now being faded in/out.

EpheMeroN
21st September 2005, 18:02
How can I fix this then? I'm not that good with scripting yet.

foxyshadis
21st September 2005, 19:49
The easiest way from the start would be to splice the fades in after your trims, but since you'd need to change all your numbers now, you can just add trim(0,88)++...++trim(framecount()-149,0) around your other trims. That should include the fades and blackness.

EpheMeroN
22nd September 2005, 03:33
Okay, so if I put a Trim(0,88) as the first Trim call, that would allow for the blank seconds in the beginning, but how could I still fade that trim in?

stickboy
22nd September 2005, 07:28
The easiest way from the start would be to splice the fades in after your trims, but since you'd need to change all your numbers nowSince he didn't account for the fade he spliced in in the first place, I'm not sure EpheMeroN would need to adjust his numbers.
Okay, so if I put a Trim(0,88) as the first Trim call, that would allow for the blank seconds in the beginning, but how could I still fade that trim in?Assuming you actually did account for the fade you added before you determined the trim points, then you wouldn't need to do anything.

Here's what you're doing:

Original clip: 0 1 2 3 4 5 6 7 8 9Then you prepended a bunch of frames to the beginning and end:A B C 0 1 2 3 4 5 6 7 8 9 X Y ZThen you used Trim and selected some middle portions: 3 4 5So foxyshadis' suggestion effectively does:A B C 3 4 5 X Y Z

By the way:
It should be Trim(0, 89), not 88. You added Blank1 and Blank2 have a total length of 90 frames.
I'm not sure why you're using AlignedSplice in one place but ++ elsewhere.
You should use + (AlignedSplice) instead of ++ (UnalignedSplice) to join segments that weren't originally continuous. [Edit: Ack, ignore this bullet. I got mixed up.]
You're also not fading anything. You're fading blackness into blackness.

Here's how you fade things:
AVISource("someClip.avi")

# I want to fade in to frame 100 and start fading out at frame 200.
# Let's say I want the fade-in to last for 10 frames and the fade-out
# to last for 30.
Trim(100 - 10, 200 + 20)
FadeIn(10)
FadeOut(30)

# Let's say I want to start and end with some blank frames too.
BlankClip(last, length=5) + last + BlankClip(last, length=5)

mg262
22nd September 2005, 09:48
You should use + (AlignedSplice) instead of ++ (UnalignedSplice) to join segments that weren't originally continuous.

Typo there?
Avisynth's scripting language provides + and ++ operators as synonyms for UnalignedSplice and AlignedSplice respectively.

stickboy
22nd September 2005, 10:01
Whoops. No, not a typo; I just mixed them up. :)