0
votes

I try to create a video by images in cv2, I succeeded to create a mp4 video:

fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('video.mp4', fourcc, FRAME_RATE,
                  (img.shape[1], img.shape[0]))

How can I create ogg and webm video file? What is the fourcc codec for these format?

1
MP4, WebM and Ogg are containers, and FOURCC applies codec. A container may support multiple codecs (multiple FOURCC options). You may check Wikipedia for video codecs supported by the container, and look for FOURCC code that applies the codec (and supported by OpenCV). Example: WebM container supports VP8 and VP9 video codecs. And FOURCC code of VP9 codec is VP09Rotem
@Rotem Thank you! When I try fourcc = cv2.VideoWriter_fourcc('V','P','0','9') for webm I get an error: OpenCV: FFMPEG: tag 0x39305056/'VP09' is not supported with codec id 167 and format 'webm / WebM' What could be the problem?ron kolel
I don't know... what is the version of OpenCV, what operation system and what platform? I am using OpenCV 4.2 on Windows 10, and it's working.Rotem
@Rotem it is very strange, I am also using OpenCV 4.2.0.32 and Windows 10, I get the error: "OpenCV: FFMPEG: tag 0x39305056/'VP09' is not supported with codec id 167 and format 'webm / WebM'"ron kolel

1 Answers

0
votes

ogg has codec 'theo':

fourcc = cv2.VideoWriter_fourcc(*'theo')

You should also be able to do this format:

fourcc = cv2.VideoWriter_fourcc('T', 'H', 'E', 'O')