obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.26k stars 7.98k forks source link

Decklink output only works "properly" on NV12/i420 with 601. All other have artefacts or 90%+ encoding lag #2398

Closed qun-media closed 3 years ago

qun-media commented 4 years ago

This is about the Decklink output in OBS, not related to streaming, although I did notice some similar behaviour recording videos.

Expected Behavior

Decklink outputs the "correct" colour format/colour space and colour range that's selected in the advanced tab of the settings. Using XSplit or vMix, you get a "clean" 4:2:2 signal in 601 (XSplit) or 709 (vMix).

Current Behavior

When using anything else than NV12 or i420 with 601 colour space, there are artefacts in the output. There's something like a pixel shift happening on the right part of the image. It makes text very blurry. If you select NV12/i420/i444 with 709 or RGB in general. About 90% of the encoded frames are dropped. My CPU nor GPU is significantly going up in usage.

To confirm OBS ignores the 709 part, I selected i444 with 709 and the other PC confirmed that it's somehow a 709 matrix over a 601 source.

My Decklink card doesn't support keying, only 1 SDI output, but I was recommended by der_rod on Twitter to force "keyer" to 3 in the appdata config. This gave me a very clean 4:4:4 output on 709, but it dropped so many frames that it's not usable. I wouldn't be able to use it anyway since my Decklink card in the stream PC doesn't support 4:4:4 above 1080p30.

I've included screenshots in the Google Drive link and gave them a name. Make sure you check the images on 100% of the size (it's a screenshot of a 1440p monitor). Also included are 2 screenshots, 1 of vMix and 1 of XSplit. The 00 screenshot is the encoding lag and I included a log of that session.

Screenshots: https://drive.google.com/drive/folders/1lSy79ohUh91EZmSq9_dAF61ubhHmGDgE?usp=sharing Log file: https://obsproject.com/logs/T1oGCXsk7IJHla-b

Steps to Reproduce

  1. Change output from NV12 601 to NV12 709
  2. Start Decklink output
  3. Watch encoding lag go up to 90%
  4. Doesn't happen with NV12/i420/i444 on 601, but happens on all formats in combination with 709
  5. Even when 709 is selected, it gets ignored by the output and outputs a 601 signal anyway (other than RGB where it's the other way around).

I reproduced this in Ubuntu too to make sure it wasn't Windows related. I tried it on both PCs since both of my PCs have a Decklink output card and all of them have similar issues.

Additional information

PC 1 has Decklink 4K Mini Monitor, i9-7900X and RTX 2080 PC 2 has Decklink SDI Micro (m.2 card), i7-6950X and GTX 1050

I wrote this at 8am after pulling an all-nighter, so might have made some mistakes. But I'm happy to provide more details and testing if someone reaches out to me. I'm in the OBS Discord under Qun#0001

walterav1984 commented 4 years ago

Please report the Nvidia&Blackmagic driver version (Desktop Video) you used and also the Ubuntu, kernel and OBS-Studio version.

Did OBS-studio in Ubuntu linux show you the options to set "color space" for Decklink output, since OBS-Studio 24.03 only shows "Mode" as in resolution and framerate for me (BMD Desktop video 11.4 Ubuntu 19.04/kernel 5.0.0-37)?

walterav1984 commented 4 years ago

I can indeed confirm this BUG for 1920x1080p50 with increasing "Skipped frames due to encoding lag" in the stats while using Color Format 709 on Ubuntu 19.04 amd64 kernel 5.0.0-37 using a i3-4170 CPU 32GB RAM and Mesa 19.0.8 with iGPU hd4400 as soon as the Decklink output (driver 11.4) gets enabled with OBS-Studio 24.03. However 1280x720p50 is fine (no LAG) in both 709 and 601. I'm using the same resolution for project/scaling/output to simplify report but to summarize:

There are probalby multiple issues/bugs. One is about LAG&SPEED related and the other about incorrectness of Color Space settings at all? I can confirm the first about LAG&SPEED the color needs more research.

Although you use the term encoding, you are not streaming nor recording at the time of screenshots were made, correct?

A confusing part of your report is that you mention the issues about Decklink "Output" but you are also using the Decklink "Input" at the same time, correct?

You are using 2 Decklink cards at the same time "Mini Monitor&Recorder 4k", correct?

Is it correct that it doesn't matter if you use Decklink "Input" in rec601/rec709 colours "except for the look" as long as the OBS-studio settings are 709 it still affects the encoding lag?

You mention alot of possibilities for this issue, but testing OBS-Studio>Settings>Advanced Color Format NV12, Color Space 709 Color Range Partial is enough to show the issue giving encoding lag in the STATS window?

By only changing Color Space 709>601 the encoding lag is fixed, no matter Color Format has been set like NV12/i420/444/RGB correct?

Am I correct you are using 44100Hz audio and not 48000Hz while using the output of the Declink Cards as SDI?

AlexDaniel commented 4 years ago

Oh, THAT is what was causing so much pain for me. Thanks for reporting.

ogmkp commented 4 years ago

I meet same issue, i downgraded to REC 609 and decklink output runs well. But when I start decklink output and start a streaming/recording, i get 84% of picture encoding loss and thats bad.

CPU stills to 32% of loading, NVENC 28% and GPU utilization stills at 34%. OBS 25.0.8 Blackmagic VS 11.5.1 Linux Ubuntu 20.04

ogmkp commented 4 years ago

I meet same issue, i downgraded to REC 609 and decklink output runs well. But when I start decklink output and start a streaming/recording, i get 84% of picture encoding loss and thats bad.

CPU stills to 32% of loading, NVENC 28% and GPU utilization stills at 34%. OBS 25.0.8 Blackmagic VS 11.5.1 Linux Ubuntu 20.04

Additionnal information: I haven't the issue if I don't use video playback in a scene.

walterav1984 commented 4 years ago

Are you using "vlc video source" or "media source" for video playback which codec and does it macth resolution and framerate of your project/stream/recording?

How much is the cpu load, and is 1core atleast 100% could you check with "htop"?

ogmkp commented 4 years ago

Are you using "vlc video source" or "media source" for video playback which codec and does it macth resolution and framerate of your project/stream/recording?

How much is the cpu load, and is 1core atleast 100% could you check with "htop"?

It's happen when I start a video with "media source" or "vlc video source" and Decklink Output and Streaming/Recording and continues if I stop the video. If I stop Streaming/Recoding and keep playing video with "media source" or "vlc video source" and keep Decklink output, I haven't frame losing anymore. If I stop Decklink Output and keep playing video with "media source" or "vlc video source" and keeping Streaming/Recording, I haven't frame losing anymore too. It's happen only when I start Decklink Output and streaming/recording with a video playback. Htop says 160% of 4 cores for OBS for the issue (decklink out + streaming/recording + video playback) and 105% with video playback and decklink output.

The video played is a h264 format 1080p60, same as the video composition in OBS.

No error or warnings in OBS log and system logs.

ogmkp commented 4 years ago

Hi.

With same sources and files, I didn't have the case today. The production chain was in 50 fps progressive, 601/full. I tried to reproduce the problem in 60 fps progressive 601/full, and I was unable to reproduce the issue. No software (system, Blackmagic desktopvideo, obs...) update since my last comment.

Weird...

walterav1984 commented 4 years ago

@maxdrash do you mean the OP "issue" of choosing anything other than 601 will result in low framerates if decklink output is used is not issue anymore for you.

Or do you mean your issue with decklink output + recording which gave low framerates hasn't come by again.

ogmkp commented 4 years ago

@maxdrash do you mean the OP "issue" of choosing anything other than 601 will result in low framerates if decklink output is used is not issue anymore for your.

Or do you mean your issue with decklink output + recording which gave low framerates hasn't come by again.

Like I said here: https://github.com/obsproject/obs-studio/issues/2398#issuecomment-665092258 709 produce loss framerates when I start decklink output only. 601 don't produce framerates loosing when I start decklink output only. And when I started decklink output and streaming/recording in 601 mode, I got 84% of loosing pictures.

But In my last attempt I wasn't enable to reproduce the issue in 601 🤷‍♂️ I observed context switching of IRQs, CPU, GPU, NVENC charges: no irregularity as before. And no logs errors.

qun-media commented 4 years ago

The new OBS (v26) fixed my issue. I think they re-did some colour space logic, now the default state changed from sRGB to 709 and I don't have the issue anymore of the pixel shift. Should be clean 4:2:0 rec709 now.

PatTheMav commented 3 years ago

@maxdrash @walterav1984 can you also confirm that the issues are fixed with OBS v26?

ogmkp commented 3 years ago

@PatTheMav I cant confirm the issue is fixed in v26 for now, I will try soon.

RytoEX commented 3 years ago

@PatTheMav I cant confirm the issue is fixed in v26 for now, I will try soon.

@maxdrfr @walterav1984 Checking in again. Have you re-tested this in OBS Studio 26 or newer?

walterav1984 commented 3 years ago

@PatTheMav May find an oppertunity next week(end) to only test the OT issue about speed and lag when going from old default 601 to 709 with 1080p50 and Decklink Output. However the possible color(space) and or chroma sampling issue which are also in the OT attached through screenshots from Gdrive will first need acces to a test chart...

ogmkp commented 3 years ago

@PatTheMav I cant confirm the issue is fixed in v26 for now, I will try soon.

@maxdrfr @walterav1984 Checking in again. Have you re-tested this in OBS Studio 26 or newer?

@RytoEX Because of quarantine, I haven't opportunity to work at this time but let me some time to make a installation with a SDI monitor at home. I'll reply to you soon.

walterav1984 commented 3 years ago

@PatTheMav did some quick testing on our current but not up to date OBS-STUDIO 26.02 from the obs unstable ppa. If I'm not mistaken the 26.x branch already included fixes and a default for the rec709, but I cannot check yet with newest version of OBSstudio because all plugins/settings have to be migrated and tested again for hours.

I tried using nv12 and i444 in rec601 and rec709 with 1920x1080@50fps project/output/scene/capture with Decklink DUO2 source (decklink 1 camera) and output (decklink 4 monitor) and I can confirm that rec709 is now stable in framerate (stats window won't show any framedrops like in the past it went crazy) and now rec709 is almost even 3 times faster than rec601. This is as soon as the decklink output option gets started(activated) with rec709, the cpu usage will increase from ~4% to ~12%. While using rec601 gives increase from ~4% to ~22% . In the past pre 26.x obsstudio it totally went crazy with framedrops...So this seems fixed. Stopping the Decklink output brings back the earlier cpu usage.

I haven't checked or tested the color issues, but the OT reported it was fixed...

ogmkp commented 3 years ago

Tested today on OBS 26.1.1, Debian 10, same conditions like my comments but Blackmagic VS 11.7. media plugin runing with 1080p60 video.

Decklink output only 1080i50: 709 no framedrops 601 no framedrops

Decklink output 1080i50 + NVENC 1080p50: 709 no framedrops 601 no framedrops

It's ok for me, no issue anymore, thank you !

PatTheMav commented 3 years ago

Considered fixed.