I have python code that generates frames with pil and then opencv compiles them to video. Everything works great on a computer, but now I try to run same code add tablet and I cant get right framerate.
Then I tried to add sleep(0.017)(60fps) between compiling the frames and it works! But now I need to wait same time as long the video is...
I dont know what do to. Tablet python is using 4.3.0 opencv and I cant update it...
Here is the code:
def create_video(frames, fps, duration, name):
duration_flip = 0
videodims = frames[0].size
fourcc = cv2.VideoWriter_fourcc(*'avc1')
cwd = os.getcwd()
video = cv2.VideoWriter(cwd + "\\" + name + ".mp4",fourcc, fps,videodims)
for frame in frames:
#print(frame)
for fps_frame in range(duration[duration_flip] * fps):
video.write(cv2.cvtColor(np.array(frame), cv2.COLOR_RGB2BGR))
duration_flip = 1 - duration_flip
#print(video)
video.release()
return 0