Pregunta

I am currently attempting to undergo lossless compression of RGB24 files using H264 on FFMPEG. However, the color space transformation used in the H264 compression (RGB24 -> YUV444) has proven to be lossy (I'm guessing due to quantisation error). Is there anything else I can use (eg a program) to transform my RGB24 files to YUV losslessly, before compressing them with lossless H264?

The ultimate goal is to compress an RGB24 file then decompress it, with the decompressed file exactly matching the original file. eg RGB24 -> YUV444 -> compressed YUV44 -> decompressed YUV444 -> RGB24.

Is this at all possible?

¿Fue útil?

Solución

This is a copy/paste from my answer here: RGB-frame encoding - FFmpeg/libav

lets look at the colorspace conversion.

void YUVfromRGB(double& Y, double& U, double& V, const double R, const double G, const double B)
{
    Y =  0.257 * R + 0.504 * G + 0.098 * B +  16;
    U = -0.148 * R - 0.291 * G + 0.439 * B + 128;
    V =  0.439 * R - 0.368 * G - 0.071 * B + 128;
}

And plug in some dummy values:

R = 255, G = 255, B = 255
Y = 235

R = 0, G = 0, B = 0
Y = 16

As you can see, the range 0 -> 255 is squished to 16 -> 235. Thus we have shown that there are some colors in the RGB colorspace that do not exist in the (digital) YUV color space. Hence the conversion is lossy by definition.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top