I am generating a video from a set of images using
cv2.VideoWriter(filename,fourcc,fps,size)
I want to use a particular bitrate for my output videos to reduce the file sizes. I am trying to mimic a ffmpeg command which generated videos with smaller sizes. One prominent difference I noticed is the bitrate. Resolution, codec, video length are all similar.
How do I change the bitrate when I generate videos using opencv in python?
cv2.VideoWriter
is oriented toward convenience over flexibility. There are many similar questions (use Google). It's probably possible to control the bitrate using GStreamer backend. I recommend you to use other Python package for encoding the video. For using FFmpeg directly, you may take a look at my following answer.skvideo.io.FFmpegWriter
as in the following post. If you must use OpenCV, I think it's possible using GStreamer backend (note that the default opencv-python package is not built with GStreamer backend, and GStreamer syntax is complicated). If you find an option using OpenCV and FFmpeg backend please let me know.