Images get modified when converted to video

asked 2015-09-17 11:52:19 -0500

RubenMartinez gravatar image

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.

edit retag flag offensive close merge delete

Comments

As it is written here it's not exactely lossless encoding. It is true when color space matches. May be in yours images new color occur and hence low loss compression is performed.

May be you can test it :

send 15 times same images to compressor ( I think you can swap pixel inside images. this will not change color space)

send 15 times another images . Problem must occured at transition.

LBerger gravatar imageLBerger ( 2015-09-18 04:00:32 -0500 )edit