#!/usr/bin/env python3
# Copyright (C) 2017 The Antares Authors
# This file is part of Antares, a tactical space combat game.
# Antares is free software, distributed under the LGPL+. See COPYING.

"""Turns the output of a replay into a movie.

usage: replay-to-movie replay/screens/ out.aiff movie.webm
"""

import subprocess
import sys

_, screens, sounds, outfile = sys.argv

assert subprocess.call([
    "ffmpeg",
    "-r", "60",
    "-i", screens + "/%06d.png",
    "-pix_fmt", "yuv420p",
    "-vcodec", "libvpx",
    "-vpre", "720p50_60",
    "-pass", "1",
    "-r", "60",
    "-b", "5M",
    outfile,
]) == 0

assert subprocess.call([
    "ffmpeg",
    "-r", "60",
    "-i", screens + "/%06d.png",
    "-i", sounds,
    "-pix_fmt", "yuv420p",
    "-vcodec", "libvpx",
    "-vpre", "720p50_60",
    "-pass", "2",
    "-r", "60",
    "-b", "5M",
    "-y", outfile,
]) == 0
