Advance Blender WebEngine N-015 through N-022 parity
This commit is contained in:
65
tools/web/generate-sequencer-fixture.py
Normal file
65
tools/web/generate-sequencer-fixture.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import pathlib
|
||||
import sys
|
||||
import wave
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def write_silence(path):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with wave.open(str(path), "wb") as stream:
|
||||
stream.setnchannels(1)
|
||||
stream.setsampwidth(2)
|
||||
stream.setframerate(8000)
|
||||
stream.writeframes(b"\0\0" * 8000)
|
||||
|
||||
|
||||
def main(output_path):
|
||||
output = pathlib.Path(output_path).resolve()
|
||||
media = output.parent / "media"
|
||||
audio_path = media / "sequencer-silence.wav"
|
||||
image_path = media / "sequencer-frame.png"
|
||||
write_silence(audio_path)
|
||||
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
image = bpy.data.images.new("SequencerFrame", width=8, height=8, alpha=True)
|
||||
image.generated_color = (0.2, 0.4, 0.8, 1.0)
|
||||
image.filepath_raw = str(image_path)
|
||||
image.file_format = "PNG"
|
||||
image.save()
|
||||
bpy.data.images.remove(image)
|
||||
|
||||
scene = bpy.context.scene
|
||||
scene.name = "SequencerScene"
|
||||
scene.render.fps = 24
|
||||
scene.render.fps_base = 1.001
|
||||
editor = scene.sequence_editor_create()
|
||||
|
||||
sound = editor.strips.new_sound("WebSound", str(audio_path), channel=1, frame_start=10)
|
||||
sound.mute = True
|
||||
sound.lock = True
|
||||
sound.sound.filepath = "//media/sequencer-silence.wav"
|
||||
|
||||
image_strip = editor.strips.new_image("WebImage", str(image_path), channel=2, frame_start=12)
|
||||
image_strip.directory = "//media/"
|
||||
image_strip.elements[0].filename = "sequencer-frame.png"
|
||||
image_strip.frame_final_duration = 20
|
||||
|
||||
second_image = editor.strips.new_image("WebImageB", str(image_path), channel=3, frame_start=12)
|
||||
second_image.directory = "//media/"
|
||||
second_image.elements[0].filename = "sequencer-frame.png"
|
||||
second_image.frame_final_duration = 20
|
||||
cross = editor.strips.new_effect(
|
||||
"WebCross", "CROSS", channel=4, frame_start=12, length=20, input1=image_strip, input2=second_image)
|
||||
cross.mute = True
|
||||
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(output), compress=False)
|
||||
print(f"sequencer-fixture-generated path={output} strips={len(editor.strips_all)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --python generate-sequencer-fixture.py -- output.blend")
|
||||
main(arguments[0])
|
||||
Reference in New Issue
Block a user