Chen Clarence
Chen Clarence

Reputation: 11

OpenCV Video Write-out Size is Reduced

I am trying to combine frames into a video using openCV, using the following codes. However, the total size of frames in png format is over 500 megabytes, yet the output video is only 360 kilobytes. How can I write out the video without any compression?

#setting fourcc
fourcc = cv2.VideoWriter_fourcc(*'XVID')
#creating the writer object
writer=cv2.VideoWriter('Screen1.avi', fourcc, 30, (unitWidth, unitHeight), True)
#writing out the frames into video
for i in range(Frames):
    img=cv2.imread('./Screen1/frame'+str(i)+'.png')
    writer.write(img)
writer.release()

Upvotes: 0

Views: 2225

Answers (1)

jdslab
jdslab

Reputation: 11

If you are worrying about video quality, try a lossless codec like the Huffman Lossless Codec.

fourcc = cv2.VideoWriter_fourcc(*'HFYU')

Or search for any other lossless codec.

If you want absolutely no compression at all, you can try fourcc = 0, which will output every frame raw and result in very large file size.

Upvotes: 1

Related Questions