The Blender Python API can be very useful not only for working with meshes or nodes but also when editing video files in the Video Sequence Editor.
We can add a new video strip to the VSE sequencer by executing the following command:
1 2 3 4 5 6 7 8 |
strip = bpy.context.scene.sequence_editor.sequences.new_movie( name='New Movie Strip', filepath='d:/movie.mp4', channel=1, frame_start=1 ) # <bpy_struct, MovieSequence("New Movie Strip") at 0x0000027F5FE99608> |
with:
name – here we can set any convenient name for further reference to the strip by name,
filepath – full path to the video file,
channel – track number on which the added strip will be placed,
frame_start – frame number to which the beginning of the strip will be set.
We can refer to the added strip in the future by the given name:
1 2 3 4 |
strip = bpy.context.scene.sequence_editor.sequences['New Movie Strip'] print(strip) # bpy.data.scenes['Scene'].sequence_editor.sequences_all["New Movie Strip"] |
For example, to set the blending mode:
1 |
strip.blend_type = 'ALPHA_OVER' |
The “Alpha Over” mode indicates that the strip should be blended with others by the background transparency.