#!/bin/bash

filename=$1
flag=$2  
video=$3
video_duration=$4
sleeptime=5

if [[ "$flag" ]]; then
	ffmpeg -loop 1 -re -i $filename -f v4l2 -vcodec rawvideo -s 854x480 -pix_fmt yuv420p $video
	sleep $sleeptime
	exit 0 
else
	ffmpeg -re -i $filename -map 0:v -f v4l2 -s 854x480 $video
	sleep $video_duration
fi
