简体   繁体   中英

x264 stream color shift

I was using swscale + x264 to encode a sequence of RGB images to an h264 stream. When the RGB values in the input image (in red) are all (255, 0, 0) , the YUV outputted by swscale + x264 is (81, 90, 240) . By using swscale, this YUV value can be transformed back to the original RGB value. However there is color shifting when I used PotPlayer to play the stream.

I captured the first frame and saved it as a bmp file. The RGB value in the bmp file is (255, 24, 0) , where the green channel is not zero.

How to solve this color-shift problem?

I solve this problem by changing the ITU-601 color space to ITU-709 using sws_setColorspaceDetails .

This could be due to multiple reasons. If swsscale is converting RGB to anything other than YUV444, then you are losing some chroma precision in the subsampling process. And since H264 is lossy compression, you would lose some information in compression process as well. It is difficult to tell which one is causing the difference until you analyse the output of each stage but it looks like the loss is caused from lossy encoding than color conversion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM