This commit implements two changes to the sequencer API:
- Sequence.new_movie() gets a new, optional parameter file_must_exist=True. This default value will keep Blender's behaviour of disallowing the creation of the strip for non-existent files. Passing file_must_exist=False will allow the creation of the strip for non-existent files.
- MovieSequence.has_source is a new read-only RNA property that evaluates to True when the movie sequence strip has a valid source, and False otherwise. It does not perform any disk access to see if the file can be loaded.
This allows for the following:
import bpy
scene = bpy.context.scene
vse = scene.sequence_editor_create()
filepath = bpy.path.abspath('//demo.mkv')
strip = vse.sequences.new_movie("movie", filepath,
channel=2,
frame_start=47,
file_must_exist=False)
strip.frame_final_end = 327This will create a new movie strip, even when demo.mkv does not exist. In that case, strip.has_source will be False.
Once demo.mkv has appeared at the expected location, strip.filepath = strip.filepath will load it.
Note that image and sound strips behave differently. Even though they also directly refer to files on disk, they do allow creating the strips when the files are missing. That's why this commit only addresses movie strips.
Here are the test files:
To test, do this (instructions are also available in a text block in the blend file):
- Make sure that demo.mkv does not exist.
- Run the Python code that's shown in the text editor.
- Run in the Python console:
strip = C.scene.sequence_editor.sequences_all['movie'] strip.reload_if_needed()
- Check that the last line returns False.
- Make sure that demo.mkv exists.
- Run in the Python console:
strip.reload_if_needed()
- Check that now True is returned, and that the video file has been loaded.