#!/bin/sh

method="-raw"
file="$1"
in="$2"
out="$3"
rate="$4"
video="$5"
audio="$6"
ntsc="$7"

if [ "$audio" != "-1" ]
then
	if [ "$rate" != 0 ]
	then	rate="-r $rate"
	else	rate=""
	fi

	exec ffmpeg2raw $method $ntsc $rate -o $in -e $out -vt $video -at $audio "$file"
else
	normalisation=pal

	[ "$ntsc" = "-n" ] && normalisation=ntsc

	exec ffmpeg -i "$file" -f imagepipe -img ppm -r $normalisation -
fi
