#!/bin/sh

if [ -z $(which ffmpeg) ]
then
    echo "Missing ffmpeg package, please install it!"
    exit 1
fi

if [ ! -z $1 ]
then
    if [ $1 == 'cut' ] 
    then
       ffmpeg -i "$2" -ss $3 -t $4 -c:v copy -c:a copy "$5"
    fi
    
    if [ $1 == 'shrink' ]
    then
       ffmpeg -i "$2" -vcodec libx264 -crf 20 -filter:v fps=30 "$3"
    fi
fi