Editing a scene in a video with avisynth plus.

As pointed out in an early post Avisynth can read a video file and present it to other tools for editing. To pull out a single scene the function is trim … Use as follows …


That script will produce frames 150 to 300 from example.avi … use any other video program to edit the clipped scene or create a new one. to combine the video with the clip using the original video sound track. use the following …

v = AVIsource("example.avi").trim(0,150) 
  \+ AVIsource("newscene.avi") 
  \+ AVIsource("example.avi").trim(300,9999) 
a = AVIsource("example.avi")

This is a more than single line script.

On the first line we assemble the video as a variable v.  we want only replace frames 150 through 300. So we get the original begining. Then add the replaced Scene. And finally add the end from our original clip.

The second line pulls out the audio from the original clip.

The last line combines the video and audio back into a video output.  I am assuming the replacement scene is 150 frames, if it were not the audio would go out of sync with this script by the number of frames that is different. That of course can be corrected in the script with more lines of code. Or the audio could be included with the replaced scene.

Having the audio be part of the replaced scene would make the script be one line of adding three sources.

  \+ AVIsource("newscene.avi") 
  \+ AVIsource("example.avi").trim(300,9999)

No need to use variables in that case and the length of the replacement scene can be any length.

Note \ allows you to use the next line to continue to format the code for readability.


Note the two following scripts are produce the same results.





What gets supplied or returned by AVIsynth is the last or final video.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: