Streampunk / macadam

Async node.js interface to Blackmagic Design capture and playback devices.
Apache License 2.0
107 stars 24 forks source link

Some unsupported video modes do work on certain devices #23

Open florisporro opened 4 years ago

florisporro commented 4 years ago

I'm testing with an UltraStudio HD Mini. The getDeviceInfo output for this device is down below.

Clearly according to the specs, this device does not support output on 1080p50, 1080p59.94 and 1080p60 except in 8 or 10 bit YUV mode. That should rule out any BGRA output.

Here's the thing though: it does. I can use OBS or V-Mix to output the above resolutions and framerates with the external keyer enabled. External keying is only possible when passing a BGRA buffer to the device... so... what the heck? Is this an undocumented supported displayMode?

I spent the day going through the OBS source code to see whether they might be applying any trickery behind the scenes to, perhaps, convert it into YUV before output (even though I can't see how this is possible when using the external keyer). They either don't or I can't find it.

This leads me to hypothesise that certain Decklink devices have unsupported video modes or a different list of supported output modes when the keyer is enabled.

To compensate I think there should be an option to circumvent the supported modes check when starting playback, to attempt to output the selected video mode to the device even if it is not supported according to the device.

I attempted to do this myself by changing playback_promise.cc to the following:

switch (supported) {
    case bmdDisplayModeSupported:
      break;
    case bmdDisplayModeSupportedWithConversion:
      break;
      c->status = MACADAM_NO_CONVERESION; // TODO consider adding conversion support
      c->errorMsg = "Display mode is supported via conversion and not by macadam.";
      return;
    default:
      break;
      c->status = MACADAM_MODE_NOT_SUPPORTED;
      c->errorMsg = "Requested display mode is not supported.";
      return;
  }

But that didn't work, and I can't figure out why. C is not my main language.

Here's the getDeviceInfo output as promised:

[
    {
        "modelName": "UltraStudio HD Mini",
        "displayName": "UltraStudio HD Mini",
        "vendorName": "Blackmagic",
        "deviceHandle": "84:3c1a4096:00000000",
        "hasSerialPort": true,
        "serialPortDeviceName": "/dev/tty.RS422 Deck Control",
        "persistentID": 1008353430,
        "topologicalID": 5523200,
        "numberOfSubDevices": 1,
        "subDeviceIndex": 0,
        "maximumAudioChannels": 16,
        "maximumAnalogAudioInputChannels": 2,
        "supportsInputFormatDetection": true,
        "hasReferenceInput": true,
        "supportsFullDuplex": true,
        "supportsExternalKeying": true,
        "supportsInternalKeying": true,
        "supportsHDKeying": true,
        "hasAnalogVideoOutputGain": false,
        "canOnlyAdjustOverallVideoOutputGain": false,
        "videoInputGainMinimum": -1.8,
        "videoInputGainMaximum": 1.8,
        "hasVideoInputAntiAliasingFilter": false,
        "hasLinkBypass": false,
        "supportsClockTimingAdjustment": false,
        "supportsFullFrameReferenceInputTimingOffset": true,
        "supportsSMPTELevelAOutput": true,
        "supportsDualLinkSDI": true,
        "supportsQuadLinkSDI": false,
        "supportsIdleOutput": true,
        "hasLTCTimecodeInput": false,
        "supportsDuplexModeConfiguration": false,
        "supportsHDRMetadata": false,
        "supportsColorspaceMetadata": false,
        "deviceInterface": "Thunderbolt",
        "deviceSupports": [
            "Capture",
            "Playback"
        ],
        "controlConnections": [
            "ConnectionRS422Remote1"
        ],
        "videoInputConnections": [
            "SDI",
            "Component",
            "Composite"
        ],
        "audioInputConnections": [
            "Embedded",
            "Analog"
        ],
        "audioInputRCAChannelCount": 2,
        "audioInputXLRChannelCount": 2,
        "videoOutputConnections": [
            "SDI",
            "HDMI"
        ],
        "audioOutputConnections": [
            "Embedded"
        ],
        "audioOutputRCAChannelCount": 0,
        "audioOutputXLRChannelCount": 0,
        "inputDisplayModes": [
            {
                "name": "NTSC",
                "width": 720,
                "height": 486,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "PAL",
                "width": 720,
                "height": 576,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080p23.98",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p24",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p25",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p29.97",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p30",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p50",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    50000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080p59.94",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080p60",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080i50",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080i59.94",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080i60",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p50",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1000,
                    50000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p59.94",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1001,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p60",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1000,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p23.98 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1001,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p24 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1000,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p25 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            }
        ],
        "outputDisplayModes": [
            {
                "name": "NTSC",
                "width": 720,
                "height": 486,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "PAL",
                "width": 720,
                "height": 576,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p23.98",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p24",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p25",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p29.97",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p30",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p50",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    50000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080p59.94",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080p60",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV"
                ]
            },
            {
                "name": "1080i50",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080i59.94",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1001,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080i60",
                "width": 1920,
                "height": 1080,
                "frameRate": [
                    1000,
                    30000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p50",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1000,
                    50000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p59.94",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1001,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "720p60",
                "width": 1280,
                "height": 720,
                "frameRate": [
                    1000,
                    60000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p23.98 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1001,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p24 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1000,
                    24000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            },
            {
                "name": "1080p25 DCI 2K",
                "width": 2048,
                "height": 1080,
                "frameRate": [
                    1000,
                    25000
                ],
                "videoModes": [
                    "8-bit YUV",
                    "10-bit YUV",
                    "8-bit ARGB",
                    "8-bit BGRA",
                    "10-bit RGB",
                    "12-bit RGB",
                    "12-bit RGBLE",
                    "10-bit RGBXLE",
                    "10-bit RGBX"
                ]
            }
        ]
    }
]