Log in

View Full Version : cutting AVI in AVIsynth


slavik
13th March 2005, 03:41
I have an AVI which has some commercials and I want to cut them out and the append them together and re-encode at original settings (basically, just keep the parts I want)

I can use vdubmod to cut out parts I need, and then put them together, which will take time (not as much copying as using the program)

or if there is a way, I would rather use avisynth for this kind of thing (to have a bot more autamation)

I know where I want to cut the avi (frame# and time).

Ebobtron
13th March 2005, 03:51
Very easy just use:
Trim(int first_frame, int last_frame)+trim(#,#)

Use + between the trims to keep the sound synced.

slavik
13th March 2005, 03:55
thanks a lot :)

I know that Yatta created a line like that, but I wasn't sure on the actual usage ...

stickboy
13th March 2005, 06:30
Originally posted by Ebobtron
Use + between the trims to keep the sound synced.If he's cutting out commercials, no, he should use ++ (AlignedSplice).

Ebobtron
13th March 2005, 14:25
stickboy is correct, ++.

Scarfac3
13th March 2005, 15:56
but he won't be able to direct stream copy if he'll use avs for that
he should use VDM

slavik
13th March 2005, 19:10
I figured out a way to go around that, especially since lame doesn't like non WAV files for me ...

EDIT: a single + works for me (audio is in sync) ... should I use ++ anyway?

Originally posted by Scarfac3
but he won't be able to direct stream copy if he'll use avs for that
he should use VDM

Bexley
13th March 2005, 21:05
An alternate way to do the same thing:

cap1=Trim(AVISource("G:\capture.avi"),618,1201)
cap2=Trim(AVISource("G:\capture.avi"),2917,19229)
cap3=Trim(AVISource("G:\capture.avi"),22045,42831)
AlignedSplice(cap1,cap2,cap3)

I normally do my captures in segments, so I have a lot of separate files to splice together. In that case, I find this to be a lot less cumbersome than the while +/++ syntax. However, if you're working with a single file I don't suppose it makes much difference. It's all about choice. :)

stickboy
13th March 2005, 22:51
Originally posted by slavik
EDIT: a single + works for me (audio is in sync) ... should I use ++ anyway?The difference between + and ++ should be minor, but if you do a lot of splicing, the differences could accumulate.
Originally posted by Bexley
I normally do my captures in segments, so I have a lot of separate files to splice together. In that case, I find this to be a lot less cumbersome than the while +/++ syntax. However, if you're working with a single file I don't suppose it makes much difference.Also, if you're working with a single file, the identical AVISource calls are wasteful.

Seed
14th March 2005, 04:29
Originally posted by Bexley
An alternate way to do the same thing:

cap1=Trim(AVISource("G:\capture.avi"),618,1201)
cap2=Trim(AVISource("G:\capture.avi"),2917,19229)
cap3=Trim(AVISource("G:\capture.avi"),22045,42831)
AlignedSplice(cap1,cap2,cap3)



Not really adding any more useful info on functionality of trim and splice than what Stickboy has said, it is somewhat more concise in syntax to write:

AVISource("G:\capture.avi")
cap1=Trim(618,1201)
cap2=Trim(2917,19229)
cap3=Trim(22045,42831)
AlignedSplice(cap1,cap2,cap3)



For me, I am too lazy to to type AlignedSplice, so I use "++". I agree that it is cumbersome to write "trim(..., ...) ++ trim(..,..) ++ trim(..,..) ++ trim(..,...)" horizontally (especially in your case where you put in AVISource("G:\capture.avi") blah blah). Making use of line separator "\", there is a way to make this both concise and visually presentable:


AVISource("G:\capture.avi")
trim(618,1201) ++\
trim(2917,19229) ++\
trim(22045,42831)


or for multiple captured avi files:

AVISource("G:\capture1.avi").trim(618,1201) ++\
AVISource("G:\capture2.avi").trim(2917,19229) ++\
AVISource("G:\capture3.avi").trim(22045,42831)

slavik
14th March 2005, 14:34
so ... I should switch to ++ instead of +?

Also, how would I get rid of audio inside avisynth so that it just outputs the video to vdubmod?

Boulder
14th March 2005, 16:00
Use KillAudio(), or the parameter audio=false in AVISource.

slavik
15th March 2005, 00:13
thanks for the audio solution :) (makes it a lot easier since I don't have to go through vdubmod to disable it)

what about the + and ++, should I switch my scripts from + to ++?

Ebobtron
15th March 2005, 00:24
from the documention

AlignedSplice (clip1, clip2 [, ...])
UnAlignedSplice (clip1, clip2 [, ...])

AlignedSplice and UnalignedSplice join two or more video clips end to end. The difference between the filters lies in the way they treat the sound track. UnalignedSplice simply concatenates the sound tracks without regard to synchronization with the video. AlignedSplice cuts off the first sound track or inserts silence as necessary to ensure that the second sound track remains synchronized with the video.

You should use UnalignedSplice when the soundtracks being joined were originally contiguous - for example, when you're joining files captured with AVI_IO. Slight timing errors may lead to glitches in the sound if you use AlignedSplice in these situations.

Avisynth's scripting language provides + and ++ operators as synonyms for UnalignedSplice and AlignedSplice respectively.
----------------
I'd test both and see which keeps the Sync. I have had trouble with AlignedSplice as described.