forked from jaredrummler/bootanimation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
youtube2boot.sh
executable file
·66 lines (56 loc) · 1.45 KB
/
youtube2boot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
################################################################################
#
# youtube2boot.sh
#
# DESCRIPTION: Download a YouTube video and convert it into a simple Android boot animation.
# You need youtube-dl and ffmpeg to run this script.
#
#
# USAGE:
#
# youtube2boot.sh VIDEOID [DESTINATION]
#
#
# VIDEOID The video id at the end of a YouTube URL
#
# DESTINATION The output file
#
# Example usage: youtube2boot.sh Ynm6Vgyzah4
#
case $1 in
-h|--help) # never done this before ༽つ۞﹏۞༼つ
println=false; echo
while read line; do
case $line in
\#*DESCRIPTION*) println=true; echo ${line:1} ;;
\#*) if $println; then echo ${line:1}; fi ;;
*) break;
esac;
done < "$0"
exit 0
esac
video_id=$1
destination=${2:-./${video_id}.zip}
url="https://www.youtube.com/watch?v=$video_id"
temp=./$video_id
out="$temp/out.mp4"
# Use youtube-dl to download the video
# https://github.com/rg3/youtube-dl
youtube-dl -o "$out" "$url"
# Make the directory for the frames to be extracted to
mkdir -p "$temp/part0"
# Use ffmpeg to extract frames from the video
ffmpeg -i "$out" "$temp/part0/00%05d.jpg"
size=`identify -format '%w %h' $temp/part0/0000001.jpg`
# Create the desc.txt file
echo "$size 30" > "$temp/desc.txt"
echo "p 1 0 part0" >> "$temp/desc.txt"
# Create the bootanimation
pwd=$(pwd)
cd "$temp"
zip -0r bootanimation part0 desc.txt
cd "$pwd"
echo $pwd
cp "$temp/bootanimation.zip" "$destination"
rm -rf "$temp"