Skip to content

Conversation

@BitRate27
Copy link
Contributor

@BitRate27 BitRate27 commented Nov 18, 2024

When the user selects a color format of P010, I010, P216 or P416, the output will not be started because the NDI SDK does not support HDR color formats. The only indication this is a problem is by looking for "unsupported pixel format" in the log file. To make it easier for the user to identify the problem, we will now report the last error in the DistroAV NDI Settings dialog for the main output.

image

This message will be seen when the user goes back to the settings dialog after noticing there is no NDI output.

This does not happen for preview or dedicated NDI output from a filter, so no changes were needed for those outputs.

In order to test and utilize this new message, this PR also fixes #1147 where OBS crashes after you have tried to output an unsupported format.

The problem existed because an output would be created even when no main output was selected. When the user went to change the color format, in the OBS Settings->Advanced dialog, this would invalidate the video output in DistroAV NDI Settings. Then when main output was turned back on, OBS would crash because output->video is corrupted.

This makes the changes to main-output look big but it was mainly removing an indented if condition. In summary we always call main_output_deinit in main_output_init, and then if it is not enabled, we return, otherwise we create the output and start it every time it is enabled.

Tested on Windows by testing that all formats gave the correct message if unsupported, or blank if supported.

@RayneYoruka
Copy link
Member

I like the idea of this being added, please @paulpv or @Trouffman check it

@Trouffman
Copy link
Collaborator

Thanks for the extensive PR.
Is there a way that it could be displayed without being set in the config file?

I see we could re-use the pixel format detection as well if one day we can use the advanced SDK.

@BitRate27
Copy link
Contributor Author

I think it is possible to add a method to set the last error to the OutputSetting dialog and display that string instead when the dialog is displayed. I can redo that part.

@BitRate27
Copy link
Contributor Author

BitRate27 commented Dec 6, 2024

Added bb765a9 to the branch and the PR.

I removed the LastError from the config. Ended up adding last_error to the main-output context and making the last error message accessible from output-settings.

Also added translations for all the locales we support. I keyed off the phrase "Color Format" which is the name of the field the user changes. So the error message should point the user to what caused the error.

@BitRate27
Copy link
Contributor Author

I am looking into a way to keep the user from turning on main output if the color format not supported.

@BitRate27
Copy link
Contributor Author

After this latest commit ef7e0ec , the main output box is only enabled if the pixel format of the main output is supported by the NDI SDK. If it is not supported, the main output box is disabled and an error message appears showing why main output cannot be chosen.

@Trouffman
Copy link
Collaborator

Thank you for updating the behavior on this.

Next : testing & QC.

@Trouffman Trouffman added Seeking Testers PRs with this label will package the plugin so that others can test Output (Program/Preview) relate to NDI Output Progam or Preview HDR & Pixel Format labels Dec 30, 2024
@Trouffman
Copy link
Collaborator

I just found a bug while investigating another behavior.

Documented bug at : #1180

@Trouffman
Copy link
Collaborator

@BitRate27 I merged from the latest master, please review to confirm that this still has the intended purpose.

Copy link
Collaborator

@Trouffman Trouffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue found : This is "Stopping" the Main Output when opening the DistroAV Settings and is not re-created if "cancelled".

Expected Behavior : The stream should NOT stop until there is a need for:

  • Stopping (aka not enabled)
  • Name or group name changed
    All above only after the form has been submitted.

Error log shows : info: Output 'NDI Main Output': stopping

@Trouffman
Copy link
Collaborator

Trouffman commented Apr 24, 2025

This is what happen when opening the NDI Settings dialog box :

08:28:52.056: [distroav] +main_output_init()
08:28:52.057: [distroav] +main_output_deinit()
08:28:52.057: [distroav] main_output_deinit: NDI Main Output is not initialized
08:28:52.057: [distroav] -main_output_deinit()
08:28:52.057: [distroav] main_output_init: creating NDI Main Output 'OBS-PGM'
08:28:52.057: [distroav] Creating NDI Main Output : 'OBS-PGM'
08:28:52.057: [distroav] +ndi_output_getdefaults()
08:28:52.057: [distroav] -ndi_output_getdefaults()
08:28:52.057: [distroav] +ndi_output_create(name='OBS-PGM', groups='', ...)
08:28:52.057: [distroav] ndi_output_update(name='OBS-PGM', groups='', ...)
08:28:52.057: [distroav] NDI Output Updated. 'OBS-PGM'
08:28:52.057: [distroav] ndi_output_update(name='OBS-PGM', groups='', uses_video='true', uses_audio='true')
08:28:52.057: [distroav] -ndi_output_create(name='OBS-PGM', groups='', ...)
08:28:52.057: [distroav] main_output_init: created NDI Main Output 'OBS-PGM'
08:28:52.057: [distroav] +main_output_start()
08:28:52.057: [distroav] main_output_start: starting NDI Main Output 'OBS-PGM'
08:28:52.057: [distroav] +ndi_output_start(name='OBS-PGM', groups='', ...)
08:28:52.058: [distroav] +on_main_output_started()
08:28:52.058: [distroav] -on_main_output_started()
08:28:52.058: [distroav] NDI Main Output started
08:28:52.058: [distroav] 'OBS-PGM' ndi_output_start: ndi output started
08:28:52.058: [distroav] -ndi_output_start(name='OBS-PGM', groups=''...)
08:28:52.058: [distroav] main_output_start: successfully started NDI Main Output 'OBS-PGM'
08:28:52.058: [distroav] -main_output_start()
08:28:52.058: [distroav] -main_output_init()
08:28:52.058: [distroav] +main_output_deinit()
08:28:52.058: [distroav] +main_output_stop()
08:28:52.058: [distroav] main_output_stop: stopping NDI Main Output 'OBS-PGM'
08:28:52.058: [distroav] +ndi_output_stop(name='OBS-PGM', groups='', ...)
08:28:52.058: Output 'NDI Main Output': stopping
08:28:52.058: Output 'NDI Main Output': Total frames output: 0
08:28:52.058: Output 'NDI Main Output': Total drawn frames: 0
08:28:52.059: [distroav] +on_main_output_stopped()
08:28:52.059: [distroav] -on_main_output_stopped()
08:28:52.059: [distroav] NDI Main Output stopped
08:28:52.059: [distroav] ndi_output_stop: +ndiLib->send_destroy(o->ndi_sender)
08:28:52.063: [distroav] ndi_output_stop: -ndiLib->send_destroy(o->ndi_sender)
08:28:52.063: [distroav] NDI Output Stopped. 'OBS-PGM'
08:28:52.063: [distroav] -ndi_output_stop(name='OBS-PGM', groups='', ...)
08:28:52.063: [distroav] main_output_stop: successfully stopped NDI Main Output 'OBS-PGM'
08:28:52.063: [distroav] -main_output_stop()
08:28:52.063: [distroav] main_output_deinit: releasing NDI Main Output 'OBS-PGM'
08:28:52.063: [distroav] +ndi_output_destroy(name='OBS-PGM', groups='', ...)
08:28:52.063: [distroav] -ndi_output_destroy(name='OBS-PGM', groups='', ...)
08:28:52.063: [distroav] main_output_deinit: successfully released NDI Main Output ''
08:28:52.063: [distroav] -main_output_deinit()

This is because of the logic for main_output_is_supported() that will "test" by creating the output. But this conflict with the "on-going" output.

This should be triggered only when loading a new profile / starting OBS and not everytime the NDI Settings are opened.

Other after testing :

  1. The box should be greyed ONLY if not supported (and that we update this based on "any" type of change that could have a different color format/resolution etc :
  • Change of color format
  • Change of Profile
  • Selecting a valid format after an invalid format was used.
  1. When the box is greyed out, this is the only time when we should display the error message.

  2. The error message space in UI should only be present if there is an error (not sure if this could be set back to height = 0)
    image

@BitRate27
Copy link
Contributor Author

Thanks for looking at this. You brought up some good issues with this implementation. Clearly I need to rethink the logic here. I think we need to initialize a test output instead of using the main output. Not sure how to only show the "last error" row in the dialog if no error. Suggestions welcome.

Here are the scenarios:

  1. New profile loaded with main output OFF and format NOT supported
    • Turn off main output
    • Main output: not started
    • Dialog: Main output group disabled, not checked and error shown
  2. New profile loaded with main output OFF and format supported
    • Turn off main output
    • Main output: not started
    • Dialog: Main output group enabled, not checked and no error shown
      • OK and main output checked -> Main output started
      • OK and main output not checked -> Main output not started
      • Cancel -> Main output not started
  3. New profile loaded with main output ON and format supported
    • Turn off main output
    • Main output: started
    • Dialog: Main output group enabled, checked and no error shown
  4. User changes to a format NOT supported
    • Dialog: Main output group disabled, not checked and error shown
    • OK/Cancel: Main output not started
  5. User changes to a format supported
    • Dialog: Main output group enabled, not checked and no error shown
      • OK and main output checked -> Main output started
      • OK and main output not checked -> Main output not started
      • Cancel -> Main output not started

@BitRate27
Copy link
Contributor Author

BitRate27 commented Apr 25, 2025

Update: was able to alter the main_output_is_supported to check without using main output. Also, figured out how to set the message height to zero if no error message. Only thing left is to work on the LOG_INFO and LOG_DEBUG messages. All tests in the scenarios above passed. Will also squash the branch to one commit as this went through a lot of changes.

@Trouffman
Copy link
Collaborator

Trouffman commented May 5, 2025

Tested on Windows 11+ OBS 31 after the latest merge :

  • The default output does not work once a non compatible profile is used, same when going back to an expected to work profile.

Seem our logic here is not polished enough.

EDIT : Seems my test system was not behaving properly.

Will need to re-do test fully.

When wiping out my test OBS and re-using the one from this PR built. it did work as expected

@Trouffman Trouffman marked this pull request as draft May 5, 2025 00:53
@BitRate27
Copy link
Contributor Author

Looks like the one scenario I didnt list above. Will check it out. Thanks!

@Trouffman Trouffman self-assigned this May 5, 2025
@Trouffman Trouffman marked this pull request as ready for review May 5, 2025 03:16
@Trouffman
Copy link
Collaborator

Trouffman commented May 5, 2025

Tests results on MacOS 15.4

Scenarios :

New profile loaded with main output OFF and format NOT supported
    Turn off main output
    Main output: not started
    Dialog: Main output group disabled, not checked and error shown

-> OK

New profile loaded with main output OFF and format supported
    Turn off main output
    Main output: not started
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

-> OK

New profile loaded with main output ON and format supported
    Turn off main output
    Main output: started
    Dialog: Main output group enabled, checked and no error shown

-> OK

User changes to a format NOT supported
    Dialog: Main output group disabled, not checked and error shown
    OK/Cancel: Main output not started

-> OK

User changes to a format supported
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

->ok but UI space for error not reverted

@Trouffman
Copy link
Collaborator

Tests results on Windows 11

Scenarios :

New profile loaded with main output OFF and format NOT supported
    Turn off main output
    Main output: not started
    Dialog: Main output group disabled, not checked and error shown

-> OK

New profile loaded with main output OFF and format supported
    Turn off main output
    Main output: not started
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

-> OK

New profile loaded with main output ON and format supported
    Turn off main output
    Main output: started
    Dialog: Main output group enabled, checked and no error shown

-> OK

User changes to a format NOT supported
    Dialog: Main output group disabled, not checked and error shown
    OK/Cancel: Main output not started

-> OK

User changes to a format supported
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

->ok

@Trouffman
Copy link
Collaborator

Tests results on Ubuntu 24.04

Scenarios :

New profile loaded with main output OFF and format NOT supported
    Turn off main output
    Main output: not started
    Dialog: Main output group disabled, not checked and error shown

-> OK

New profile loaded with main output OFF and format supported
    Turn off main output
    Main output: not started
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

-> OK

New profile loaded with main output ON and format supported
    Turn off main output
    Main output: started
    Dialog: Main output group enabled, checked and no error shown

-> OK

User changes to a format NOT supported
    Dialog: Main output group disabled, not checked and error shown
    OK/Cancel: Main output not started

-> OK

User changes to a format supported
    Dialog: Main output group enabled, not checked and no error shown
        OK and main output checked -> Main output started
        OK and main output not checked -> Main output not started
        Cancel -> Main output not started

->ok

Where I have found an issue :

New profile loaded with main output ON and format NOT-supported
    Turn off main output
    Main output is still checked (as it was loaded as "active") BUT this is not running.
    User change Settings to a Supported pixel format
    The Main Output should restart, if the format is supported 

Not sure when/where this is overlooked.

@BitRate27
Copy link
Contributor Author

BitRate27 commented May 6, 2025

New profile loaded with main output ON and format NOT-supported
    Turn off main output (?)
    Main output is still checked (as it was loaded as "active") BUT this is not running.
    User change Settings to a Supported pixel format
    The Main Output should restart, if the format is supported 

(?) How do you turn off main output with this new code if the format is not supported? The checkbox should not be sensitive.

Note: I could do this with this sequence:
Select a supported profile
Turn on main output
OK Output settings dialog
Bring up Output settings dialog
Change to an unsupported profile
Turn off main output
OK Output settings dialog

Operates properly (main output terminated)

@Trouffman
Copy link
Collaborator

Trouffman commented May 7, 2025

I could reproduce on Mac with this :

  • Open OBS with supported profile & Main Output ON
  • Load non-compliant profile
  • Behavior (expected) : Main output OFF, greyed out option, box is still ticked.
  • Go to Settings : change to a valid pixel format, save
    Behavior : Main output OFF, option available, box is still ticked.

To re-enable the NDI output, the Main Output option must be disabled, saved, then re-enabled in the DistroAV setings

I think this need to be clear-er on the approach we take:

  1. Should the option be "disabled" if a Pixel format is not supported
    or
  2. Should we build a (more complex) logic to re-enable the Main Output when the pixel format is changed AND the box ticked.

Option 1. would touch the configuration file
Option 2. would need to have a check for specifically this change as we do NOT want to stop the main output everytime we go in the OBS settings.

@Trouffman
Copy link
Collaborator

@BitRate27 This PR is proving to be more complex than expected.

While doing the review I found a couple extra comment (not blocking but would be good to have at some point)

  1. Should we call main_output_is_supported() everytime we plan to use main_output_init ?

ie. : in plugin-main.cpp line 299

  1. main_output_is_supported() is calling the obs_output_create with an "empty" ndi_name.

This did not create issues when testing, hopefully this would stay this way but having a clear "testing name" might help to identify in error log as well.

We could put it in a group called "DistroAV Config" so this does not even show up anywhere when testing.

  1. Following on point 2. above : Giving the output a unique name might avoid weird issues too (even tho the OBS documentation says that it will make it unique).

This PR brings a lot of value as it will help for the support and anyone using HDR pixel format.

@BitRate27
Copy link
Contributor Author

Disabling main output in the config if the format is not supported, keeps the toggle in sync with the main output status in OBS.

Also, moving the check for support into the main_output_init allows us to turn it off if not supported and enabled.

Finally, with the output enabled in sync with the OBS main output state, main_output_init is only called when settings of main output are changed.

I verified the original scenarios still work, and the new scenario performs as it should. Also added a LOG_INFO message to let the user know the output was disabled because the format is not supported.

@Trouffman
Copy link
Collaborator

Great! Thank you.

I updated the INFO to a WARNING and attributed ID 426 to easily flag it too.

@Trouffman Trouffman merged commit 3b87beb into DistroAV:master May 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HDR & Pixel Format Output (Program/Preview) relate to NDI Output Progam or Preview Seeking Testers PRs with this label will package the plugin so that others can test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OBS crash when turning on main output after choosing an unsupported color format

3 participants