# OBS Redux - Changing color space



## acappiello (Dec 2, 2014)

I started playing around with the OBS redux code recently to allow output with a lossless codec (via ffmpeg). I managed to do so, but the video quality still seemed lossy. As far as I can tell (maybe I'm wrong) the cause is the color space being VIDEO_FORMAT_NV12.

I attempted to change this by changing obs/window-basic-main.cpp:1354 to ovi.output_format = VIDEO_FORMAT_BGRA. The output/encoding itself uses AV_PIX_FMT_RGB32 to make the codec happy. However, all this seems to accomplish is that YUV data is treated as though it's RGB data. This is just in the video output, not the preview.
Example: http://i.imgur.com/SCp3Vft.png

Until now, I've been able to find my way through the code pretty effectively with a debugger and grep, but I've been unable to figure this out. I would appreciate it if someone could give me an idea of what else I need to change to get this working.
Thanks.


----------



## Jim (Dec 2, 2014)

Ah.  I believe we have it currently hardcoded (unintentionally, I was planning on replacing it with programmable code later), in:

The color matrix conversion should be at libobs/obs-video.c:135.  Just replace it with an identity matrix and it should come out as RGB.

Apologies about that.


----------



## acappiello (Dec 2, 2014)

Thanks. That did it.

I've noticed a few posts on this forum where people have mentioned alternate codec support. Assuming someone isn't already putting time into this, I'll try to work on it to the point of being able to contribute.

EDIT: Just in case anyone finds this relevant in the future: in addition to changing the matrix, I used VIDEO_FORMAT_RGBA instead.


----------



## dodgepong (Dec 2, 2014)

I believe FFmpeg output may be done already? It's just not in the UI, so that would be the first place to add support for alternate codecs.


----------



## acappiello (Dec 2, 2014)

Yeah, fortunately that makes it very straightforward. Adding it to the UI in a sensible manner will require some thought. Once I've had some more time to familiarize myself with the code, I'll probably stop by the IRC with some questions.


----------



## dodgepong (Dec 2, 2014)

Yeah, definitely come by IRC, Jim may already have some thoughts on how multiple codecs might work in the UI.


----------



## ubuntuaddicted (Dec 3, 2014)

this is AWESOME news!


----------



## Jim (Dec 5, 2014)

By the way acappiello, what codec in FFmpeg did you program it to use, out of curiosity?


----------



## acappiello (Dec 5, 2014)

I've tried a bunch.

I started with FFV1, but had intermittent issues with it only capturing a few frames. I tried a few others that have the same issue, but I haven't been able to figure out why yet. HuffyUV (ffvhuff) works fine, but obviously isn't ideal.


----------



## Jim (Dec 5, 2014)

Check the log or terminal output to see if you're getting skipped frames.  If you are, it means the encoder is lagging and using up too much CPU.  I don't know about many of those encoders though.


----------



## acappiello (Dec 7, 2014)

Yeah, that's what's happening. I guess I was surprised the impact was that significant. After lowering the resolution to the point that it can keep up, profiling in Visual Studio shows it spending about 80% of its time in the encoder.


----------

