Python OpenCV VideoWriter set PixelFormat

asked 2016-03-11 09:36:26 -0500

Hello,

I'm using OpenCV Python binding v3.1.0 with Python v3.4 and I have troubles writing AVI video. There is a codec named UT Video which it is implemented in ffmpeg and you can read and write UT AVI videos fine (with openCV too). I 'm creating VideoWriter with the following code:

fourcc = cv2.VideoWriter_fourcc(*'ULRG')

out = cv2.VideoWriter('output.avi' ,fourcc, 25.0, (1920,1080))

The output file is UT Video but in YUV format and fourcc ULY2 (not ULRG) The problem is that UT Video file with fourcc is ULRG is in RGB format (pure ffmpeg command for producing ULRG it is like that

ffmpeg -i input.avi -vcodec utvideo -pix_fmt rgb24 output.avi

How can I set pixelformat to the VideoWriter class to be not YUV but RGB.

When I force codec section dialog with out = cv2.VideoWriter('output.avi' ,-1, 25.0, (1920,1080)) and select ULRG format the output file is with fourcc ULRG and RGB format.

edit retag flag offensive close merge delete