Skip to content

Instantly share code, notes, and snippets.

@abachman
Created July 6, 2017 16:27
Show Gist options
  • Save abachman/1c2c1b4b413b52e03cb10484dd1a6c81 to your computer and use it in GitHub Desktop.
Save abachman/1c2c1b4b413b52e03cb10484dd1a6c81 to your computer and use it in GitHub Desktop.
Glitch images in Base64, recombine into video
# 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
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
@abachman
Copy link
Author

abachman commented Jul 6, 2017

glitch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment