forked from jnohlgard/python-v4l2capture
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvideooutfile.py
44 lines (35 loc) · 983 Bytes
/
videooutfile.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
import videolive, time, random
import numpy as np
import scipy.misc as misc
if __name__=="__main__":
outManager = videolive.Video_out_file_manager()
print outManager
lena = misc.imread("Lenna.png")
print lena.shape
w = lena.shape[1]
h = lena.shape[0]
fina = "test.wmv"
realTimeFrames = 0
outManager.open(fina, 640, 480)
print "set_video_codec"
outManager.set_video_codec(fina, "H264", 800000)
print "set_frame_rate"
outManager.set_frame_rate(fina, 25)
imgLen = w * h * 3
#img = np.ones(shape=(imgLen,), dtype=np.uint8) * 0
#for i in range(imgLen):
# if (i % 3) == 0:
# img[i] = 0xff
# if (i % 3) == 1:
# img[i] = random.randint(0,255)
for frNum in range(200):
#img = np.random.randint(0, 255, size=(imgLen,))
#for i in range(imgLen):
# if (i % 500) <= 250:
# img[i] = 128
print "Frame", frNum
outManager.send_frame(fina, str(lena.tostring()), "RGB24", w, h)
if realTimeFrames:
time.sleep(frNum / 500.)
else:
time.sleep(0.01)