Skip to content

Instantly share code, notes, and snippets.

@einarjh
Created July 11, 2016 21:06
Show Gist options
  • Save einarjh/cd290e911c40a9cf761f4472f4855bb5 to your computer and use it in GitHub Desktop.
Save einarjh/cd290e911c40a9cf761f4472f4855bb5 to your computer and use it in GitHub Desktop.
function makethumbnail() {
filename="$(basename ${1} .mp4)"
# Use the wadsworth constant to set the time when we want the thumbnail from
# http://knowyourmeme.com/memes/the-wadsworth-constant
wadsworth=$(echo "${2} * 0.3 / 1 * 60" | bc)
echo "INFO: Creating thumbnail for ${1} by skipping ${wadsworth} seconds ahead."
if [ ! -f ${filename}.jpg ]; then
${FFMPEGPATH}/ffmpeg -loglevel ${LOGLEVEL} -ss ${wadsworth} -i ${1} -vframes 1 -an ${filename}.jpg
if [ "${?}" -ne 0 ]; then
echo "ERROR: Creation of thumbnail for ${1} failed."
exit 1
else
echo "INFO: Creation of thumbnail ${filename}.jpg succeeded."
fi
else
echo "WARNING: Thumbnail ${filename}.jpg already exists."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment