Skip to content

Instantly share code, notes, and snippets.

@MattLoyeD
Created July 20, 2020 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattLoyeD/f6289000742a29ee68cca2b9fa5f78e7 to your computer and use it in GitHub Desktop.
Save MattLoyeD/f6289000742a29ee68cca2b9fa5f78e7 to your computer and use it in GitHub Desktop.
Make thumbnail and compress mp4 video for web use
#!/bin/bash
# $1 = Filename
# $2 = S3 Bucket Name
base=$(basename -- "$1")
extension="${base##*.}"
filename="${base%.*}"
# p720="./videos/720p/$filename.mp4"
p1080="./videos/1080p/$filename.mp4"
png="./videos/jpg/$base.png"
jpg="./videos/jpg/$filename.jpg"
#/usr/local/bin/HandBrakeCLI -Z "Vimeo YouTube HQ 720p60" -i "$1" -o $p720
/usr/local/bin/HandBrakeCLI -Z "Vimeo YouTube HQ 1080p60" -i "$1" -o $p1080
/usr/bin/qlmanage -t "$1" -s 1080 -o "/videos/jpg/"
/usr/local/bin/magick convert $png $jpg
rm $png
if [ -n "$2" ]; then
bucket=$2
#s3cmd put --acl-public --guess-mime-type $p720 "s3://$bucket/720p/$base"
s3cmd put --acl-public --guess-mime-type $p1080 "s3://$bucket/1080p/$base"
s3cmd put --acl-public --guess-mime-type $jpg "s3://$bucket/jpg/$filename.jpg"
fi
echo "$base";
echo "$filename.jpg;
@MattLoyeD
Copy link
Author

Kudos to https://tyler.io/diy-video-hosting/ for the ressource

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