#!/bin/sh filename=$1 if [ -z "$filename" ]; then echo "You must provide a file for the script." echo "Example:" echo " `basename $0` foo.mp4" exit 1 fi if [ ! -f "$filename" ]; then echo "The file provided does not exist." exit 1 fi friendly_filename=`sed -E 's/[^[:alnum:][:space:]]+/_/g' <<< "$filename"` out_dirname="frames-$friendly_filename" #debug if false; then echo "filename:" echo " $filename" echo "out_dirname:" echo " $out_dirname" echo "friendly_filename:" echo " $friendly_filename" exit 0 fi mkdir -p $out_dirname ffmpeg -i $filename -c:v png $out_dirname/frame%04d.png if [ $? -ne 0 ]; then echo "" echo "" echo "" echo "The ffmpeg command did not return an exit status of 0." echo "Exiting script..." rm -r $out_dirname exit 1 fi