ii-vision/main.py
kris c00300147e Integrated audio + video player!
- Introduce a new Movie() class that multiplexes audio and video.

- Every N audio frames we grab a new video frame and begin pulling
  opcodes from the audio and video streams

- Grab frames from the input video using bmp2dhr if the .BIN file does
  not already exist.  Run bmp2dhr in a background thread to not block
  encoding

- move the output byte streaming from Video to Movie

- For now, manually clip updates to pages > 56 since the client doesn't
support them yet

The way we encode video is now:
- iterate in descending order over update_priority
- begin a new (page, content) opcode
- for all of the other offset bytes in that page, compute the error
  between the candidate content byte and the target content byte
- iterate over offsets in order of increasing error and decreasing
  update_priority to fill out the remaining opcode
2019-03-07 23:07:24 +00:00

29 lines
548 B
Python

import frame_grabber
import movie
import opcodes
import screen
import video
MAX_OUT = 10 * 1024 * 1024
VIDEO_FPS = 30
APPLE_FPS = 30
def main():
filename = "Computer Chronicles - 06x05 - The Apple II.mp4"
m = movie.Movie(filename, audio_normalization=3.0)
with open("out.bin", "wb") as out:
for bytes_out, b in enumerate(m.emit_stream(m.encode())):
out.write(bytearray([b]))
if bytes_out >= MAX_OUT:
break
out.write(bytes(m.done()))
if __name__ == "__main__":
main()