- Posts: 2
- Joined: Mon Aug 09, 2021 2:14 pm
- Real Name: Andrei Nicolaescu
Hello,
I've been trying to create a WPF project (.NET Framework 4.7.2) to grab the stream (and render it frame by frame in an Image WPF Control) from a SDI camera connected to a Decklink Duo capture card. I've been unable to do so as of yet, encountering some difficulties.
For a start, I have so far tried two codebases (API implementations, straight from official Blackmagic examples/samples). Firstly, from the "Blackmagic Video Capture and Playback", I used the "DeckLinkCapture" example. More exactly, the "DeckLinkInput.cs" implementation of an input device. Next, I took a look at the "CapturePreviewCSharp" example, and I used the "DeckLinkDevice.cs" implementation of a DeckLink device. The code is similar when comparing the two, but there are small differences. Unfortunately, both these options resulted in the same problems.
For the video parameters, I've been tinkering with the Blackmagic Media Express desktop application and have used some settings that I know for sure work.
I set the display mode for 720p59.94, and the pixel format to 10bitRGB.
Now, the problems are as follows:
1. When setting the "flags" of the EnableVideoInput method to 1 (_BMDVideoInputFlags.bmdVideoInputEnableFormatDetection), telling it to watch for format changes, at some point (after receiving several frames - all of them invalid for some reason) the
"VideoInputFormatChanged" callback is triggered and the API tries to reinitialize the stream with the new detected settings. However, the first line (inside the callback) involving my m_deckLinkInput object crashed with the dreaded m_deckLinkInput error.
It tell me that it was Unable to cast COM object of type 'System.__ComObject' to interface type 'DeckLinkAPI.IDeckLinkInput'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C21CDB6E-F414-46E4-A636-80A566E0ED37}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
This is pretty weird, as all the calls to my "DeckLinkInput" object (before this callback is triggered) work perfectly fine.
I have read another forum post and have seen that some people managed to make this work by launching MTA threads for the instructions that trigger this error. However, after several attempts and different methods of implementing this workaround, I have not been able to make it work. Still, the error persisted.
2. If I use the default flags (which means an eventual format change is not detected), I receive frames without error, but here's the catch: even though I am grabbing frames from the correct port (the one on which the SDI camera is connected), all of them come back with the "invalid - has no input source" flag. Basically, it tells me that there is no input signal coming from the port. This instruction returns true:
What can possibly be wrong here?
---------------------------------
I don't think I need to detect the format changes of the stream while it is running, but I still do not understand how all these frames come up as invalid. I am using an iterator to detect the 4 ports available and then I select one of the 4 to grab frames from. I am pretty sure I'm trying to grab frames
from the SDI camera (and not from an empty port). In any way, all 4 ports, camera connected or not, return invalid frames. In the Blackmagic Media Express application, the correct port works just fine.
Any suggestion is highly appreciated.
Thank you in advance,
Andrei Nicolaescu
I've been trying to create a WPF project (.NET Framework 4.7.2) to grab the stream (and render it frame by frame in an Image WPF Control) from a SDI camera connected to a Decklink Duo capture card. I've been unable to do so as of yet, encountering some difficulties.
For a start, I have so far tried two codebases (API implementations, straight from official Blackmagic examples/samples). Firstly, from the "Blackmagic Video Capture and Playback", I used the "DeckLinkCapture" example. More exactly, the "DeckLinkInput.cs" implementation of an input device. Next, I took a look at the "CapturePreviewCSharp" example, and I used the "DeckLinkDevice.cs" implementation of a DeckLink device. The code is similar when comparing the two, but there are small differences. Unfortunately, both these options resulted in the same problems.
For the video parameters, I've been tinkering with the Blackmagic Media Express desktop application and have used some settings that I know for sure work.
I set the display mode for 720p59.94, and the pixel format to 10bitRGB.
Now, the problems are as follows:
1. When setting the "flags" of the EnableVideoInput method to 1 (_BMDVideoInputFlags.bmdVideoInputEnableFormatDetection), telling it to watch for format changes, at some point (after receiving several frames - all of them invalid for some reason) the
"VideoInputFormatChanged" callback is triggered and the API tries to reinitialize the stream with the new detected settings. However, the first line (inside the callback) involving my m_deckLinkInput object crashed with the dreaded m_deckLinkInput error.
It tell me that it was Unable to cast COM object of type 'System.__ComObject' to interface type 'DeckLinkAPI.IDeckLinkInput'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C21CDB6E-F414-46E4-A636-80A566E0ED37}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
- Code: Select all
void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
{
if (videoFrame != null)
{
bool inputSignalAbsent = videoFrame.GetFlags().HasFlag(_BMDFrameFlags.bmdFrameHasNoInputSource);
// Detect change in input signal, restart stream when valid stream detected
bool restartStream = !inputSignalAbsent && m_prevInputSignalAbsent;
if (restartStream)
{
m_deckLinkInput.StopStreams();
m_deckLinkInput.FlushStreams();
m_deckLinkInput.StartStreams();
}
m_prevInputSignalAbsent = inputSignalAbsent;
var frameWidth = videoFrame.GetWidth();
var frameHeight = videoFrame.GetHeight();
long frameTime, frameDuration;
videoFrame.GetStreamTime(out frameTime, out frameDuration, timeScale);
Debug.WriteLine(value: "Frame received #" + frameCount++ + "; Frame time = " + frameTime +
"; Frame size = " + frameWidth + "x" + frameHeight + "; " + (inputSignalAbsent ? "Invalid" : "Valid")
+ (restartStream ? " - restarting" : ""));
// Register video frame received event
var handler = VideoFrameArrivedHandler;
if (handler != null)
{
handler.Invoke(this, new DeckLinkVideoFrameArrivedEventArgs(videoFrame, inputSignalAbsent));
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(videoFrame);
}
This is pretty weird, as all the calls to my "DeckLinkInput" object (before this callback is triggered) work perfectly fine.
I have read another forum post and have seen that some people managed to make this work by launching MTA threads for the instructions that trigger this error. However, after several attempts and different methods of implementing this workaround, I have not been able to make it work. Still, the error persisted.
2. If I use the default flags (which means an eventual format change is not detected), I receive frames without error, but here's the catch: even though I am grabbing frames from the correct port (the one on which the SDI camera is connected), all of them come back with the "invalid - has no input source" flag. Basically, it tells me that there is no input signal coming from the port. This instruction returns true:
- Code: Select all
bool inputSignalAbsent = videoFrame.GetFlags().HasFlag(_BMDFrameFlags.bmdFrameHasNoInputSource);
What can possibly be wrong here?
---------------------------------
I don't think I need to detect the format changes of the stream while it is running, but I still do not understand how all these frames come up as invalid. I am using an iterator to detect the 4 ports available and then I select one of the 4 to grab frames from. I am pretty sure I'm trying to grab frames
from the SDI camera (and not from an empty port). In any way, all 4 ports, camera connected or not, return invalid frames. In the Blackmagic Media Express application, the correct port works just fine.
Any suggestion is highly appreciated.
Thank you in advance,
Andrei Nicolaescu