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()