Wrong colors in rendered video

I have a project consisting of a video and some partially transparent images, which are screenshots from that video edited in Gimp and made transparent everywhere but the places I edited.
There's the usual issue with colorspaces, that is, when images are imported into timeline with Composite transition, their colors become dull as in http://www.kdenlive.org/forum/problem-video-colors. In my particular case, "Full luma range" option on images does nothing. When this option is applied to the video, it similarly distorts video colors, so that colors between images and video (almost) match.
For some reason, when "Full luma range" is unset in video and the image is applied with "Affine" transition instead of "Composite", colors match. This way, everything looks perfect in project monitor. When rendered, however, colors within frame where the image is applied match perfectly, but they are still distorted, so there is a noticeable color mismatch between frames where image is applied and where the oiginal video is unchanged. I tried H.264 and MPEG-4 profiles.
Am I overlooking something, or is it a bug?
Thanks!

Forums:

"I have a project consisting of a video and some partially transparent images, which are screenshots from that video edited in Gimp and made transparent everywhere but the places I edited."

Was the YCC Video to RGB image conversion in the Gimp done correctly, assuming correct luma levels range and color matrix? Because kdenlive / MLT will aim to do it right.

"There's the usual issue with colorspaces, that is, when images are imported into timeline with Composite transition, their colors become dull as in http://www.kdenlive.org/forum/problem-video-colors."

Usual issue with colorspaces? Issue? Dull images compared to what, the Gimp conversion which may be overly contrasty due to incorrect levels conversion by the Gimp? How do you know the Gimp is correct in that case?

"In my particular case, "Full luma range" option on images does nothing."

It has no effect on images as it is not for that purpose.

To clarify what 'Force Full Range Luma' is for. It's for video only and specifically it's for video which has been encoded and quantized with luma over the 'full' 8bit range or even over 16 - 255 like Sony NEX 5n, FS100, Canon mpeg2 camcorders to name a few. So that when the inevitable conversion to RGB is done to apply effects, luma levels below 16 and above 235 are not crushed to 0 and 255 respectively giving the typical overly contrasty image typical of an incorrect YCC to RGB color space conversion on those sources.

Applying 'Force Full Luma' to video sources that are not full luma range will 'distort' colors and gamma. Just like allowing a YCC to RGB conversion to be done incorrectly will result in 'distorted' colors and gamma. Such as doing screengrabs of h264 from a media player rather than a controlled conversion to RGB ensuring correct luma range and color matrix are employed.

"When this option is applied to the video, it similarly distorts video colors, so that colors between images and video (almost) match."

Yes, so MLT / kdenlive is aiming to get it right, that's what should happen. Slightly incorrect, nothing's perfect but using wrong color matrix will shift contrast a little.

What is your video source, do you have a sample? What color matrix and luma range did you use in Gimp for the conversion?

"For some reason, when "Full luma range" is unset in video and the image is applied with "Affine" transition instead of "Composite", colors match. This way, everything looks perfect in project monitor."

So there may be a bug there, maybe not. Need source files to check, can you post some?

"When rendered, however, colors within frame where the image is applied match perfectly, but they are still distorted, so there is a noticeable color mismatch between frames where image is applied and where the oiginal video is unchanged."

Is this in kdenlives monitor or when you use an external media player? Are you sure your external media player is handling the video correctly? Does it have luma levels outside of 16 - 235? If so a typical media player will crush shadows and highlights outside of that range, level's inside that range will be handled differently.

"I tried H.264 and MPEG-4 profiles."

Can you provide source file, simple project and h264 output exhibiting the problem?

"Was the YCC Video to RGB image conversion in the Gimp done correctly, assuming correct luma levels range and color matrix? Because kdenlive / MLT will aim to do it right."
I grabbed the snapshots with kdenlive. Gimp didn't do any conversion. I compared the colors, and colors of my image do match those of snapshot made with kdenlive. They are slightly lighter than snapshot made in mplayer though.
"Is this in kdenlives monitor or when you use an external media player? Are you sure your external media player is handling the video correctly? Does it have luma levels outside of 16 - 235? If so a typical media player will crush shadows and highlights outside of that range, level's inside that range will be handled differently."
When using Affine transition, colors are correct in kdenlive's project monitor and wrong in rendered video when played in mplayer.

Example project with sources: https://www.dropbox.com/s/6ho2fi8oc95iyig/hn_issue.tar.gz

I just found out that if the image is made from snapshot taken by mplayer, not by "Extract frame" in kdenlive, colors match. Maybe there's an issue with "Extract frame"?

I had chance to have a look at this and there appears something odd going on in a couple of places. There's a difference in handling between composite and affine, affine being correct, composite distorts red and blue just a little, this seems to have been discussed on other threads and in a bug report, greenish hue when using alpha with composite.

But also adding any effect to a video source and encoding to h264 and comparing with original there's a definite gamma change. So will look a little further.

**EDIT**

Done a simple controlled test (kdenlive, x264, Avisynth & Gimp) and can confirm it appears that when using 'Affine' transition the assumed color space conversion to or from RGB using a BT601 color matrix is being used on BT709 source so rendered output color shifts, confusingly though the extract from the Project Monitor uses the correct color matrix so outputs between the two differ in color and when using a 'Composite' transition the Project Monitor extract is incorrect as if a BT601 color matrix is used but the rendered output is correct. :-)

I'll file a bug report with some sample files shortly.