diff --git a/host/gifstream.py b/host/gifstream.py new file mode 100755 index 0000000..a580ae1 --- /dev/null +++ b/host/gifstream.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +# This script eats CRAP and outputs a live GIF-over-HTTP stream. The required bandwidth is about 20kB/s + +import io +import math +import threading +import struct +import argparse +from itertools import chain +from contextlib import suppress + +from PIL import Image, ImageFile +from flask import Flask, Response + +import config + +import crap + + +frame = None +frame_cond = threading.Condition() + +def framestream(): + global frame + while True: + with frame_cond: + frame_cond.wait() + img = Image.frombuffer('RGB', (config.display_width, config.display_height), frame, 'raw', 'RGB', 0, 1) + yield encode_image(img) + +def putframe(f): + global frame + with frame_cond: + frame = f + frame_cond.notify_all() + +def file_headers(w, h): + yield (b'GIF89a' + + struct.pack('