Skip to content

Instantly share code, notes, and snippets.

@edtjones
Last active August 29, 2015 14:07
Show Gist options
  • Save edtjones/5963ddcd522070a34603 to your computer and use it in GitHub Desktop.
Save edtjones/5963ddcd522070a34603 to your computer and use it in GitHub Desktop.
Add thumbnails (named the same as the movie) for Mov, MP4 and M4V files
#!/bin/bash
while getopts ":t:" opt; do
case $opt in
t)
time=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ -z "$time" ]; then
time=10
fi
for i in *.mov *.MOV *.m4v *.mp4; do
show_name=${i%.*}
image_name=$show_name.jpg
folder_name=${PWD##*/}
if [ ! -f "$image_name" ]; then
rotation=`mediainfo --Inform="Video;%Rotation%" $i`;
rounded_rotation=`echo $rotation | awk '{ print sprintf("%.0f", $0) }'`;
ffmpeg -y -ss $time -i "$i" -vframes 1 -vf "yadif,rotate='$rounded_rotation*PI/180',scale=320:-1" "$image_name"
atomicparsley "$i" --artwork "$image_name" --album "$folder_name" --artist "$folder_name" --TVShowName "$folder_name" --stik "TV Show" --TVEpisode "$show_name" --overWrite
else
echo "Skipping $image_name"
fi
done
@edtjones
Copy link
Author

This generates thumbs for all the video files in the working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment