OBS Redux - Changing color space

acappiello

New Member
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.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
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

New Member
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.
 
Last edited:

dodgepong

Administrator
Community Helper
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

New Member
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

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

Lain

Forum Admin
Lain
Forum Moderator
Developer
By the way acappiello, what codec in FFmpeg did you program it to use, out of curiosity?
 

acappiello

New Member
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.
 
Last edited:

Lain

Forum Admin
Lain
Forum Moderator
Developer
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

New Member
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.
 
Top