#! /bin/bash

# looped still frame to yuv mov o/p for
# color_range testing

# check existence of source
if [ $# -lt 1 ] ; then
echo usage $0 input file
exit 1
elif [ ! -e "$1" ] ; then
echo Error: Source file doesn not exist
exit 1
fi

# set up coding parameters
in_file=$1
tmp=$(basename $1)
tmp=${tmp%.*} #strip random file extension
#range="0" # auto
#range="1" # 16-235
#range="2" # 0-255

for range in 0 1 2
do
# range output
out_file=${tmp}.${range}.avi
ffmpeg -v 9 -loglevel 99  -f image2 -loop 1 -i $1 -t 5 -vcodec rawvideo -pix_fmt uyvy422 -color_range $range -vtag 2vuy -an -y "$out_file"

# range input
out_file=${range}.${tmp}.avi
ffmpeg -v 9 -loglevel 99  -f image2 -loop 1 -color_range $range -i $1 -t 5 -vcodec rawvideo -pix_fmt uyvy422 -vtag 2vuy -an -y "$out_file"

done
exit 0