#!/bin/bash
######################################################################
#Copyright (C) 2022 Kris Occhipinti
#https://filmsbykris.com
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see .
#Based on code by Fire7ly
#https://gist.github.com/Fire7ly/8a46d6605dac976e140911cf8a45a090
######################################################################
url="https://www.youtube.com/watch?v=Nl6l63AYg7s"
tmp="/tmp/bootani"
mp4="$tmp/video.mp4"
rez="720"
fps=30
[[ -d "$tmp" ]] && rm -fr "$tmp"
mkdir -p "$tmp/part0"
youtube-dl -f 22 -o "$mp4" "$url"
ffmpeg -i "$mp4" "$tmp/part0/00%05d.jpg"
for i in $tmp/part0/*.jpg
do
convert $i -rotate 90 -resize $rez $i
done
size="$(identify -format '%w %h' $tmp/part0/0000001.jpg)"
echo "$size $fps" > "$tmp/desc.txt"
echo "p 1 0 part0" >> "$tmp/desc.txt"
cd "$tmp"
rm "$mp4"
zip -0r bootanimation part0 desc.txt
echo "Animation file at $tmp/bootanimation.zip"