Could not find encoder for codec id 27: Encoder not found | python opencv

Abstract

This is an error when trying to export an mp4 format video with python's opencv-python.

error contents

Could not find encoder for codec id 27: Encoder not found

Error cause (code excerpt)

video_FourCC = int(vid.get(cv2.CAP_PROP_FOURCC))
output_path = "test.mp4"
out = cv2.VideoWriter(output_path, video_FourCC, video_fps, video_size

The cause was that the format of video_FourCC was not good. It seems that there is an error when output_path is in mp4 format.

After error correction (code excerpt)

video_FourCC = cv2.VideoWriter_fourcc(*"mp4v")
output_path = "test.mp4"
out = cv2.VideoWriter(output_path, video_FourCC, video_fps, video_size

Rewriting video_FourCC as above will work correctly.

Recommended Posts

Could not find encoder for codec id 27: Encoder not found | python opencv
OpenCV for Python beginners
Today's python error: HTTPError: 404 Client Error: Not Found for url:
filter rollbar python 404 not found
OpenCV3 installation for Python3 @macOS
Notes for using OpenCV on Windows10 Python 3.8.3.