#!/bin/bash

if [[ -e sg.vob ]]; then
	rm sg.vob
fi

if [[ -e Stargate.m4v ]]; then
	rm Stargate.m4v
fi

# Get the first 9 minutes or so of the episode
mplayer dvd://2 -dvd-device SG1_V1.ISO -chapter 1-1 -dumpstream -dumpfile sg.vob

# Convert five minutes of it & add frame count
ffmpeg -i sg.vob -ss 00:00:00 -t 00:05:00 -vf "drawtext=fontfile=Arial.ttf: text='%{frame_num}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: fontsize=20: box=1: boxcolor=black: boxborderw=5" Stargate.m4v
