Ask Your Question

Revision history [back]

Images get modified when converted to video

Hi all,

I've come into a weird issue when developing some code in opencv (python 3).

I'm using the VideoWritter class to generate a one-second video composed of just 2 images. The task is simple, the video will be generated with 30 fps rate and each image will take 15 frames (15 + 15 = 30 frames -> 1 second @ 30 fps rate). I have used the HFYU fourcc codec (supposed to be a lossless encoding).

video = cv2.VideoWriter('out.avi', cv2.VideoWriter_fourcc('H', 'F', 'Y', 'U'), 30, (width, height))

However, when I generate the video and I break it down into separate frames (obviously 30 of them), there are subtle differences between the original images (from which the video is generated) and the resulting frames. These differences ar not visible by the human eye but they DO exist when the image is analysed via a simple "absdiff" function.