ralfbiedert / openh264-rs

Idiomatic Rust wrappers around OpenH264.
66 stars 32 forks source link

Washed out colors when using the decoder #42

Open MahitMehta opened 8 months ago

MahitMehta commented 8 months ago

I've been using this library for encoding and decoding for a few days now and realized that upon decoding the video stream all of the colors become washed out and dull. Initially, I thought maybe the encoder compresses the stream in such a way that the original colors can't be retrieved. However, after trying to playback the h264 stream using Elmedia player and VLC, I noticed both players were able to recover the original colors. I'm not sure if this is a limitation of the Openh264 decoder, but I couldn't find anything online saying the Openh264 decoder would affect the colors so severely. I'm no expert in computer graphics so I'm curious about what could possibly be the issue and if there is anything that could be modified in this library's code to fix this color discrepancy. Thanks.

Hardware Encoder: Ubuntu 23.10, ARM aarch 64 Decoder: M1 Macbook Air

Original:

Screenshot 2023-11-22 at 9 45 37 PM

Openh264 Decoder:

Screenshot 2023-11-22 at 9 50 59 PM

Openh264 Decoder + Gamma Shift (this looks better, but it still doesn't beat El media or VLC in terms of color range):

Screenshot 2023-11-22 at 9 46 25 PM

El media Player:

Screenshot 2023-11-22 at 10 01 17 PM
ralfbiedert commented 8 months ago

Good question. From the top of my head it's either some decoder(?) setting we're not using correctly, or the YUV -> RGB conversion.

I'd try to export the YUV buffers from our (OpenH264's) decoder, and import them in a graphics editor, or any "pro tool" that can deal with YUV. There you could see how it does the conversion, and / or what setting might be needed. If you can get it to look good that way it's our RGB conversion logic.

torokati44 commented 6 months ago

It could be that the encoded limited "TV" range (16..235) is not being remapped to full "PC" range (0..255).