-
Notifications
You must be signed in to change notification settings - Fork 0
/
video.py
63 lines (49 loc) · 2.47 KB
/
video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
### This plays the proccessed video file created by VideoToBadge.py ###
### This file is to be put in the \animations folder along with the proccessed video file of the Defon Furs badge ###
import uzlib
import dcfurs
# Video File you want to play
video_file_name = "beemovie_2.7fps_24color_1bright_nocontrast.gz"
# Frame Rate that was used to process the video file
frameRate = 7
# Can be 8 or 24. Enter what was used to process the video
colorDepth = 24
videoFile = open("animations\\" + video_file_name, 'rb')
decoder = uzlib.DecompIO(videoFile, 31)
class video:
global frameRate
def __init__(self):
global frameRate
self.interval = int(1000 / frameRate)
def draw(self):
global frameRate
global decoder
global videoFile
global colorDepth
if colorDepth == 8: frameSize = 112
elif colorDepth == 24: frameSize = 336
# Represents the positions of the missing pixels on the badge
# These are used in the display algorithm to skip the missing pixels. Used to save ~14% on file size of the video.
deadPixels0 = (0, 17) # The missing pixels on the first row
deadPixels5 = (7, 8, 9, 10) # The missing pixels on row 5
deadPixels6 = (0, 6, 7, 8, 9, 10, 11, 17) # The missing pixels on row 6
framePos = 0
frame = decoder.read(frameSize) # The amount of bytes per frame
# Reloads the video file if it reaches the end.
if frame == b'':
del decoder
videoFile.close()
videoFile = open("animations\\" + video_file_name, 'rb')
decoder = uzlib.DecompIO(videoFile, 31)
frame = decoder.read(frameSize)
for y in range(0, 7, 1): # A step for every vertical pixel on the badge
for x in range(0, 18, 1): # Step for every horizontal pixel on the badge
if not (y == 0 and x in deadPixels0): # Skips missing pixels
if not (y == 5 and x in deadPixels5):
if not (y == 6 and x in deadPixels6):
#testnum = ord(frame[framePos])
if colorDepth == 24:
dcfurs.set_pix_rgb(x, y, int.from_bytes(frame[framePos * 3: framePos * 3 + 3], "big"))
elif colorDepth == 8:
dcfurs.set_pixel(x, y, frame[framePos])
framePos += 1