Issue 'COMException: HRESULT E_FAIL' in BlackMagic DeckLink

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

DanilNC

  • Posts: 1
  • Joined: Tue Sep 05, 2023 10:38 am
  • Real Name: Danil Orlovskiy

Issue 'COMException: HRESULT E_FAIL' in BlackMagic DeckLink

PostTue Sep 05, 2023 10:51 am

Hello Community,

I am currently facing a problem while working with the BlackMagic DeckLink SDK and I am seeking assistance to resolve it. I am encountering the following error:

Code: Select all
Unhandled Exception: System.Runtime.InteropServices.COMException: An HRESULT E_FAIL error was returned when calling a COM component.
   at DeckLinkAPI.IDeckLinkInput.EnableVideoInput(_BMDDisplayMode displayMode, _BMDPixelFormat pixelFormat, _BMDVideoInputFlags flags)
   at CapturePreviewCSharp.DeckLinkDevice.StartCapture(_BMDDisplayMode displayMode, IDeckLinkScreenPreviewCallback screenPreviewCallback, Boolean applyDetectedInputMode) in C:\Users\$username\Desktop\CapturePreviewCSharp\DeckLinkDevice.cs:Line 266.
   at CapturePreviewCSharp.MainWindow.<>cDisplayClass33_0.<startCapture>b0() in C:\Users\$username\Desktop\CapturePreviewCSharp\MainWindow.xaml.cs:Line 478.
   at CapturePreviewCSharp.MTAAction.MTAActionThreadPoolCallback(Object threadContext) in C:\Users\$username\Desktop\CapturePreviewCSharp\ApartmentHelper.cs:Line 62.
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch())


I'm using Visual Studio 2022 Community edition. Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you in advance for your assistance.
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 443
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Issue 'COMException: HRESULT E_FAIL' in BlackMagic DeckL

PostMon Sep 11, 2023 4:10 am

Hi Danil,

Check that your capture input hasn't already been enabled by another application, this is the common reason for exception on IDeckLinkInput.EnableVideoInput. I recommend adding try/catch block to handle this exception.
Code: Select all
try
{
   deckLinkInput.EnableVideoInput(displayMode, _BMDPixelFormat.bmdFormat8BitYUV, videoInputFlags);
}
catch (Exception)
{
   // Handle/forward exception, update UI, etc
}

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 34 guests