commit 730785a7c0bfbe71270191006056025543202106 Author: askiiart Date: Sat May 6 19:40:22 2023 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd78447 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +temp/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3a04fa --- /dev/null +++ b/README.md @@ -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` diff --git a/animator.py b/animator.py new file mode 100644 index 0000000..cdaaa09 --- /dev/null +++ b/animator.py @@ -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') \ No newline at end of file