-
Notifications
You must be signed in to change notification settings - Fork 2
/
what_glitch_rgb.sh~
executable file
·67 lines (46 loc) · 1.42 KB
/
what_glitch_rgb.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
#!/bin/bash
file=$1
#make a directory to do the glitching
rand=$RANDOM
mkdir /tmp/temp_$rand
cd /tmp/temp_$rand
#get bitrate
bitRate=$(avprobe $1 2>&1 | grep bitrate | cut -d ':' -f 6 | sed s/"kb\/s"//)
#convert the movie to frames
avconv -i $file -b "$bitRate"k out_%d.bmp
#count the number files in the directory
fileno=$(ls out_*.bmp -1 | wc -l)
#begin the glitch loop
no=1
while [ $no -le $fileno ]
do
rand1=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 1)
rand2=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 1)
rand3=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 1)
rand4=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 1)
rand5=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 2)
rand6=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 2)
convert -separate out_$no.bmp in_%d.bmp
#glitch the red channel
sed -i s/$rand1/$rand4/g in_0.bmp
#glitch the green channel
sed -i s/$rand2/$rand5/g in_1.bmp
#glitch the blue channel
sed -i s/$rand3/$rand6/g in_2.bmp
#combine the channels into one image
convert in_0.bmp in_1.bmp in_2.bmp -combine out_$no.bmp
#clear the directory of files
rm in_*.bmp
echo -e "Glitched file $no of $fileno"
no=`expr $no + 1`
done
#get path of file
path=$( readlink -f "$( dirname "$file" )" )
#get filename minus extension
file1=$(basename "$file")
filename="${file1%.*}"
#combine the images into a video
avconv -i out_%d.bmp -b "$bitRate"k "$file"_bmprgb.mkv
#remove the temporary directory
cd ../
rm -rf temp_$rand/