-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
35 lines (34 loc) · 1.04 KB
/
main.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
try: from PIL.Image import open
except: from Image import open
from sys import stdout
from datetime import timedelta
from cv2 import VideoCapture, imencode, resize
from io import BytesIO
import math
def I2T(File):
im = open(File)
(w, h) = im.size
mim = im.convert("1")
data = list(mim.getdata())
counter = 0
field = True
stdout.write("badapplevalue = `")
for pixel in data:
if field:
if pixel > 127: stdout.write("⬜")
else: stdout.write("⬛")
counter = counter + 1
if counter >= w:
counter = 0
if field: stdout.write("\n")
field = not field
stdout.write("`")
vidcap = VideoCapture('C:/Users/Edson/Documents/htmlbut1/video.mp4')
success, image = vidcap.read()
index = 0
while success:
index += 1
print("setTimeout(() => {")
I2T(BytesIO(imencode(".jpg", resize(image, (24, 32), interpolation = 3))[1]))
print("}, " + str(math.floor(index * (100 / 3))) + ")")
success, image = vidcap.read()