Created
July 6, 2017 16:27
-
-
Save abachman/1c2c1b4b413b52e03cb10484dd1a6c81 to your computer and use it in GitHub Desktop.
Glitch images in Base64, recombine into video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# take in piped data | |
f1 = '' | |
while line = gets | |
f1 << line.strip | |
end | |
# valid Base64 characters, not including A (binary 0) | |
set = "RizBSj0CTk1DUl2EVm3FWn4GXo5HYp6IZq7Jar8Kbs9Lct+Mdu/NevOfwPgxQhy".chars | |
# pick a spot and change character, 840 roughly offsets JPG header data | |
idx = (rand() * (f1.size - 840)).to_i + 840 | |
f1[idx] = set.sample | |
# output | |
puts f1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
mkdir -p .images | |
cat image.jpg | base64 > image.b64 | |
# generate and store 100 glitched images based on original jpg | |
for i in $(seq -f "%03g" 1 100) | |
do | |
echo $i | |
cat image.b64 | ruby glitch.rb | base64 -D > .images/image-$i.glitch.jpg | |
done | |
ffmpeg -y -r 10 -f image2 -pattern_type glob -i '.images/image-*.glitch.jpg' glitch.mp4 |
Author
abachman
commented
Jul 6, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment