Initial commit

This commit is contained in:
askiiart 2023-05-06 19:40:22 -05:00
commit 730785a7c0
3 changed files with 45 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
temp/

5
README.md Normal file
View file

@ -0,0 +1,5 @@
# askiiart/marlin-auto-animation
1. Make your video into images. Make it the right resolution and framerate using Handbrake (or ffmpeg), don't use RF=0. Then, make it into images using ffmpeg (`mkdir images; ffmpeg -i video.mp4 images/%05d.png`).
2. Adjust the variables near the start of `animator.py`
3. Run `python3 animator.py`

39
animator.py Normal file
View file

@ -0,0 +1,39 @@
from subprocess import getoutput
import os
import random
output = '/home/ben/Documents/bad_apple_Bootscreen.h'
video = '/home/ben/Videos/bad_apple_5fps.mp4'
# Make video into xbm files
os.mkdir('temp')
os.mkdir('temp/pngs')
os.mkdir('temp/xbms')
# Convert video to pngs
getoutput(f'ffmpeg -i {video} temp/pngs/%d.png')
# Convert pngs to xbms
pngs = os.listdir('temp/pngs')
filenames = [os.path.splitext(os.path.basename(filename))[0] for filename in pngs]
for filename in filenames:
getoutput(f'convert temp/pngs/{filename}.png temp/xbms/{filename}.xbm')
# make some pngs for debugging
debug = True
if debug:
os.mkdir('temp/debug_pngs')
for filename in filenames:
if random.random() < 0.01:
getoutput(f'convert temp/xbms/{filename}.xbm temp/debug_pngs/{filename}.png')
'''
for filename in filenames:
f = open(f'temp/xbms/{filename}.xbm', 'r')
lines = [line.strip() for line in f.readlines()[3:]]
os.touch(f'{output}')
f.close()
exit()
'''
#os.rmdir('temp')