Skip to content

Instantly share code, notes, and snippets.

@mcfiredrill
Created October 29, 2012 20:58
Show Gist options
  • Save mcfiredrill/3976502 to your computer and use it in GitHub Desktop.
Save mcfiredrill/3976502 to your computer and use it in GitHub Desktop.
#!/bin/bash
FFMPEG=`which ffmpeg`
if [ "$FFMPEG" = "" ] ; then
echo "Please install ffmpeg.";
exit 0;
fi
if [ $# != 3 ] ; then
echo "Usage: $0 <image_file> <mp3_file> <output_file.avi>";
exit 0;
fi
if [ ! -f $1 ] ; then
echo "Source image '$1' not found.";
exit 0;
fi
if [ -f $3 ] ; then
echo "Output file '$3' exists. Overwrite? (y/n)";
read CONFIRM
if [ "$CONFIRM" == "y" ] ; then
echo "Overwriting '$3'"
else
if [ "$CONFIRM" == "Y" ] ; then
echo "Overwriting '$3'"
else
echo "Operation canceled.";
exit 0;
fi
fi
fi
TIME=`$FFMPEG -i $2 |& grep 'Duration' | awk '{ print $2; }' | sed -e 's/,//g'`
$FFMPEG -loop 1 -i $1 -i $2 -acodec copy -y -t $TIME $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment