0
votes

I'm looking for an OpenCV fourcc codec that can be used in cv2.VideoWriter which allows the video to be played back through a HTML file. I've tried, *'DIVX' and *mp4v through cv2.VideoWriter_fourcc, but both don't seem to work in the following HTML file:

<video width="320" height="240" controls>
    <source src=<FILE PATH> type="video/mp4">
    Your browser does not support the video tag.
</video>

NOTE: When I say they "don't work", I mean that the video element is there, but I cannot play the video i.e. no frames are loaded into the video element

I'm also looking for a codec that doesn't need external installations and works just with cv2

1

1 Answers

0
votes

Browser support for video containers and codecs is diverse. You can hope to get support for the "WebM" container (based on matroska) and its specified codecs.

Most browsers also support MP4 with H.264 video, so you can try "AVC1" as fourcc with a ".mp4" extension.

"DIVX" is certainly unlikely to be supported. "mp4v" may or may not work (doesn't necessarily imply H.264).

All of that requires OpenCV to have been built with some actual media library (ffmpeg is common). OpenCV natively only supports MJPEG inside an AVI container.