I have ubuntu 16.04 LTS and OpenCV 3.4.0 Installed(Intel i5 and AMD graphics card), I need to create a browser supported video, which is playable in browser.
If I'm using H264 im getting
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1' [h264_nvenc @ 0x7f4e0407f5e0] Cannot load libcuda.so.1 Could not open codec 'h264_nvenc': Unspecified error
if I'm using webm VP8
OpenCV: FFMPEG: tag 0x30385056/'VP80' is not supported with codec id 139 and format 'webm / WebM'
if I'm using webm VP9
OpenCV: FFMPEG: tag 0x30395056/'VP90' is not supported with codec id 167 and format 'webm / WebM'
I'm using this code for conversion.
fourcc = cv2.VideoWriter_fourcc(*'VP80')
frame = cv2.imread(movements[0].file_path)
height, width, _ = frame.shape
event_video_name = video.file_name.split('.')[0] + '_eventvideo.webm'
event_video = cv2.VideoWriter(path + event_video_name, fourcc, 5, (width, height))
for _, image in enumerate(movements):
image = Image.objects.get(id=image.id)
frame = cv2.imread(image.file_path)
event_video.write(frame)
event_video.release()
Thanks for the answer I fixed the issue by using multi threading. Since write method takes more time, during that time the opencv might miss the reference frame so I used seperate thread for read and write. Then used to queue to store the images before writing to disk.