Adding strips to the Blender Video Sequencer Editor

We can programmatically add various types of strips – video, audio, images, and image sequences to the Video Sequence Editor with the Blender Python API.

Images, audio, and video files are added to the desired Sequencer channels by creating new items in the “sequences” property collection of the “bpy.types.SequenceEditor” object.

Adding sound

To add a sound file to the Sequencer, we can use the “new_sound” function

with the following parameters:

name – the name of the strip being created

filepath – full path to source sound file

channel – number of the sequencer channel on which this strip should be placed

frame_start – frame number where the beginning of this strip should be placed

Adding a video

To add a video strip to the Sequencer, we can use the “new_movie” function

with the same parameters.

Adding an image

To add an image to the sequencer, use the “new_image” function

with the same parameters.

All of these functions return a pointer to the created strip.

Adding an Image Sequence

To create a strip with an image sequence – a set of sequential images, we need to use the “sequencer.image_strip_add” operator:

with:

directory – full path to the directory that contains the required set of images

files – list of dictionaries, each of which consists of a pair: “name” – file name with extension. In this list, through such dictionary pairs, we need to specify all the images that need to be loaded into the strip.

channel – number of the sequencer channel on which this strip should be placed

frame_start – frame number where the beginning of this strip should be placed

When using this operator, keep in mind that it is context sensitive. If we call it not from the context of the Sequence Editor area, but for example from a Text Editor area, we must specify the correct context for it, otherwise the operator will throw an error:

Operator bpy.ops.sequencer.image_strip_add.poll() failed, context is incorrect

Let’s override the context to the context of the Sequence Editor area and call the operator as follows:

Now we loaded all the required strips to the Video Sequence Editor.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comment
Inline Feedbacks
View all comments