-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
VideoWriter ffmpeg pixel format lossy for lossless encodings #10583
Description
System information (version)
- OpenCV => master
- Operating System / Platform => Any
- Compiler => Any
Objective
Reduce image errors when dealing with the following situations involving VideoWriter with ffmpeg backend
- lossless codecs of RGB data (e.g. PNG, FFV1)
- rawvideo output of RGB data (for applicable container files, e.g. AVI with RGBA fourcc)
- grayscale 16 bit writing (e.g. as simply as PNG encoding)
- RGBA data
Detailed description
When using lossless codecs with ffmpeg backend the pixel format selected is lossy by encoding the pixels as yuv420p. This affects the useful lossless encodings such as ffv1 huffyuv and png
ffmpeg -h encoder=ffv1 -v quiet
ffmpeg -h encoder=huffyuv -v quiet
ffmpeg -h encoder=png -v quiet
ffmpeg -h encoder=jpegls -v quiet
FFV1 supports: yuv420p yuva420p yuva422p yuv444p yuva444p yuv440p yuv422p yuv411p yuv410p bgr0 bgra yuv420p16le yuv422p16le yuv444p16le yuv444p9le yuv422p9le yuv420p9le yuv420p10le yuv422p10le yuv444p10le yuv420p12le yuv422p12le yuv444p12le yuva444p16le yuva422p16le yuva420p16le yuva444p10le yuva422p10le yuva420p10le yuva444p9le yuva422p9le yuva420p9le gray16le gray gbrp9le gbrp10le gbrp12le gbrp14le ya8 gray10le gray12le gbrp16le rgb48le
PNG supports: rgb24 rgba rgb48be rgba64be pal8 gray ya8 gray16be ya16be monob
HUFFYUV supports: yuv422p rgb24 bgra
JPEGLS supports: bgr24 rgb24 gray gray16le
Note that even yuv444p can be lossy due to integer arithmetics
Steps to reproduce
Easily using VideoWriter and manually generated image files