Okay - the final problem with this app is the case when the input video stream is not bmdFormat8BitYUV.
In that instance - the "Capture::VideoInputFormatChanged" callback is executed - and this blindly stops the streams , changes the format and restarts the streams. BUT because the input format still won't match ( because the code forces the format to be bmdFormat8BitYUV ) - this will get called endlessly.
Solution is to check that if the format change is JUST a colour space change - then ignore it.
- Code: Select all
HRESULT Capture::VideoInputFormatChanged(BMDVideoInputFormatChangedEvents e, IDeckLinkDisplayMode* newDisplayMode, BMDDetectedVideoInputFormatFlags f)
{
const BMDDisplayMode newBMDDisplayMode = newDisplayMode->GetDisplayMode();
const BMDPixelFormat pixelFormat = bmdFormat8BitYUV; // convert input format to bmdFormat8BitYUV
if (e!=bmdVideoInputColorspaceChanged) // ignore changes in colorspace - because we *want* to change the colorspace to bmdFormat8BitYUV
// if the input is not bmdFormat8BitYUV we'll keep getting change notifications and thus we'll keep stopping/restarting
// the streams
{
printf("Format changed\n");
std::lock_guard<std::mutex> lock(m_deckLinkInputMutex);
CHECK_API(m_deckLinkInput->StopStreams());
CHECK_API(m_deckLinkInput->EnableVideoInput(newBMDDisplayMode, pixelFormat, bmdVideoInputEnableFormatDetection));
CHECK_API(m_deckLinkInput->StartStreams());
}
return S_OK;
}
Also - I removed the
- Code: Select all
completedFrame->Release();
And because I'm using HD video rather than 4K - I needed to change the size of some on screen fonts.
I would suggest the code needs some more fixes , auto scaling/positioning of the font size and helpful error messages / checks. I'd even suggest getting rid of the whole cmake junk as it just confuses issues.
Anyway - for me I now have a good working example as I suspect it was intended.