0

For some reason some resolutions work and others don't. Many codec-container combinations work but some don't. I know not all containers work with all codecs but it seems weird.

The code below is a version with the same behavior.

import cv2
import numpy
import os

os.chdir(os.path.expanduser("~/Desktop"))
shape = (640, 480)
frame = numpy.zeros(tuple([*shape] + [3]), numpy.uint8)

video_name = 'output.avi'
fps = 60
video = cv2.VideoWriter(video_name, cv2.VideoWriter_fourcc(*'XVID'), fps, shape)

for i in range(fps * 5):
    video.write(frame)

video.release()
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Opencv works (height, width) while numpy (width, height) when defining the shape. so i need to reverse the tuple before using it to define the VideoWriter shape