Answer the question
In order to leave comments, you need to log in
How to set bitrate in opencv?
I'm piecing together multiple videos using opencv. Everything turns out fine, but the size of the output file is 300-400 mb, and the total size of the input files is no more than 30 mb. I looked at the metadata of the output video, the bitrate is 30000 kb / s. You can change the bitrate with ffmpeg:
ffmpeg -i end.mp4 -b:v 500k -b:a 500k output_video.mp4
video_index = 0
cap = VideoCapture(videofiles[0])
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('result.avi', fourcc, fps, (w,h))
while(cap.isOpened()):
ret, frame = cap.read()
if frame is None:
print ('Обработали видео', videofiles[video_index])
video_index += 1
if video_index >= len(videofiles):
break
cap = VideoCapture(videofiles[ video_index ])
ret, frame = cap.read()
out.write(frame)
if waitKey(1) & 0xFF == ord('q'):
break
cap.release()
out.release()
destroyAllWindows()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question