#!/usr/bin/env python3 # Published copy. Nothing is changed except this line. The sha256 of the original is in sha256.txt. """make_video.py [frames=240] [size=720] Renders a turntable, writes turntable.mp4 (render only) and sbs.mp4 (input image left, turntable right). ffmpeg -nostdin.""" import os, subprocess, sys py, rt, ply, cam, inp, out = sys.argv[1:7] frames = int(sys.argv[7]) if len(sys.argv) > 7 else 240 size = int(sys.argv[8]) if len(sys.argv) > 8 else 720 BG = (12, 14, 18) os.makedirs(out, exist_ok=True) subprocess.run([py, "-I", rt, ply, cam, out, "--frames", str(frames), "--size", str(size), "--bg", "%d,%d,%d" % BG], check=True) from PIL import Image # noqa: E402 im = Image.open(inp).convert("RGBA") bg = Image.new("RGBA", im.size, BG + (255,)) bg.alpha_composite(im) bg.convert("RGB").resize((size, size), Image.LANCZOS).save(os.path.join(out, "input_bg.png")) fr = os.path.join(out, "frames", "f_%04d.png") base = ["ffmpeg", "-nostdin", "-y", "-loglevel", "error", "-framerate", "30", "-i", fr] subprocess.run(base + ["-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-movflags", "+faststart", os.path.join(out, "turntable.mp4")], check=True) subprocess.run(["ffmpeg", "-nostdin", "-y", "-loglevel", "error", "-loop", "1", "-framerate", "30", "-i", os.path.join(out, "input_bg.png"), "-framerate", "30", "-i", fr, "-filter_complex", "[0:v][1:v]hstack=inputs=2:shortest=1", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-movflags", "+faststart", os.path.join(out, "sbs.mp4")], check=True) print("videos in", out)