-
Notifications
You must be signed in to change notification settings - Fork 8
/
get-payload-from-web.sh
executable file
·134 lines (100 loc) · 2.88 KB
/
get-payload-from-web.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
#
# This script, designed to work with ubuntu (but could easily work with
# OS X or another variety of linux if you remove the apt-get line), will
# get the payload that is used in the piggypack.rb script.
#
# It does the following:
#
# 1. Makes sure you have gcc, ffmpeg, wget, imagemagick, and python.
#
# 2. Creates a working directory to do everything from.
#
# 3. Downloads a python script, youtube-dl that downloads
# videos from youtube and saves them to disk.
#
# 4. Download a specific youtube id and extract the audio
# from it, resulting in an m4a file.
#
# 5. Download the 3GPP reference encoder from codingtechnologies.com
# (snagged before they were bought by Dolby).
#
# 6. Unzips the reference encoder, compiles it.
#
# 7. Waits until the youtube video is downloaded and converted.
#
# 8. Converts the m4a to a 48Khz WAV file (needed by the
# reference encoder).
#
# 9. Generates a mono 12Khz 3GPP file, puts it into the
# top directory.
#
# 10. Get the original cat image (see http://qaa.ath.cx/PiggyPack.html)
#
# 11. Convert it to ppm.
#
ytid=dQw4w9WgXcQ
top=$PWD
base=$top/temp
cat=zJ1cx.png
#
# Step 1: Makes sure you have gcc, ffmpeg, wget, and python.
#
sudo apt-get install libaudio-dev python gcc ffmpeg wget imagemagick
#
# Step 2: Creates a working directory to do everything from.
#
[ -e $base ] || mkdir $base
cd $base
#
# Step 3: Downloads a python script, youtube-dl that downloads
# videos from youtube and saves them to disk.
#
if [ ! -e youtube-dl ]; then
wget --no-check-certificate https://yt-dl.org/downloads/2014.06.04/youtube-dl
chmod +x youtube-dl
fi
#
# Step 4: Download a specific youtube id and extract the audio
# from it, resulting in an m4a file.
#
[ -e ${ytid}.m4a ] || ./youtube-dl --id -f 140 $ytid &
#
# Step 5: Download the 3GPP reference encoder from codingtechnologies.com
# (snagged before they were bought by Dolby).
#
if [ ! -e 26411-800-ANSI-C_source_code.zip ]; then
wget getpostdelete.com/26411-800-ANSI-C_source_code.zip
#
# Step 6: Unzips the reference encoder, compiles it.
#
unzip 26411-800-ANSI-C_source_code.zip
cd 3GPP_enhanced_aacPlus_etsiopsrc_200907/ETSI_aacPlusenc
make
cp enhAacPlusEnc $base
cd $base
fi
#
# Step 7: Waits until the youtube video is downloaded and converted.
#
while [ ! -e ${ytid}.m4a ]; do
sleep 1
done
#
# Step 8: Converts the aac to a 48Khz WAV file (needed by the
# reference encoder).
#
[ -e ${ytid}.wav ] || ffmpeg -i ${ytid}.m4a -ar 48000 -ac 2 ${ytid}.wav
#
# Step 9: Generates a mono 12Khz 3GPP file, puts it into the
# top directory.
#
[ -e $top/astley.3gp ] || ./enhAacPlusEnc ${ytid}.wav $top/astley.3gp 12000 m
#
# Step 10: Get the original cat image.
#
[ -e $cat ] || wget http://i.imgur.com/$cat
#
# Step 11: Convert it to ppm.
#
[ -e $top/astley.ppm ] || convert $cat -compress None $top/astley.ppm