I am getting a significantly larger file after processing a video. Is MJPG fourcc codec compressing properly or is this supposed to happen? The original video size is 2.51 mb, the result video file size is 16.8 mb. In this code, there is no processed image to reference, it is using the same images as before, but the size increases.
Here is my code.
import os
import cv2
width=960
height=540
fps=25.0
#video=cv2.VideoWriter('ntest\\video.avi',-1,1,(width,height))
fourcc=cv2.VideoWriter_fourcc(*'MJPG')
video = cv2.VideoWriter('ntest\\output.avi',fourcc, fps, (width,height))
cap = cv2.VideoCapture('in.mp4')
count = 0
prename="ntest\\frame"
extension=".jpg"
while cap.isOpened():
ret,frame = cap.read()
#after processing, replace frame with processed image
cv2.imshow('window-name',frame)
name=prename+str(count)+extension
cv2.imwrite(name, frame)
a=cv2.imread(name)
video.write(a)
os.remove(name) #deletes image file, only keeps video
count = count + 1
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cap.destroyAllWindows()
cv2.destroyAllWindows()
video.release()