FORUMS: list search recent posts

Decklink and Stream Buffer Engine

COW Forums : Blackmagic Design

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Ryan Spitz
Decklink and Stream Buffer Engine
on Jun 2, 2010 at 6:21:54 pm

Hi all,

I've brought this issue to the MSDN forums, and the conclusion there is that it may have something to do with the BMDCodecLib.

I'm developing an app in wich I'm using the Directshow Stream Buffer Engine. The objective is to record live input, and being able to playback it while it's being recorded, with normal player controls (play, pause, stop).

My problem is that though the recording seems to be working normally, the playback, in wich a BMD decoder is used on the recorded video stream, crashes, and the callstack points to the BMDCodecLib. I also think it may have something to do with that codec because if no reference is made to decklink (ie. using a file as source and playback to a normal render) everything works fine.

Here is some of the code:

The Capture Graph:

hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, reinterpret_cast<void**>(&_pSinkGraph));

CComPtr<IBaseFilter> pSrcFilter;
hr = FindCaptureDevice("Decklink Video Capture", &pSrcFilter);
hr = _pSinkGraph->AddFilter(pSrcFilter, L"Decklink Video Capture");
// InfTee for preview
hr = AddFilterByCLSID(_pSinkGraph, CLSID_InfTee, L"Infinite Tee", &_pSourceInfTee);
// Create the StreamBufferConfig object.
CComPtr<IStreamBufferConfigure> pConfig;
hr = pConfig.CoCreateInstance(CLSID_StreamBufferConfig);

// Create a new registry key to hold our settings.
HKEY hkey = 0;
long lRes = RegCreateKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\CompanyName\\SoftwareName\\SBEConfigs"), &hkey);

// Set the registry key.
CComPtr<IStreamBufferInitialize> pInit;
hr = pConfig.QueryInterface(&pInit);
hr = pInit->SetHKEY(hkey);

// Set the backing file directory.
hr = pConfig->SetDirectory(ProgramDir);
hr = pConfig->SetBackingFileCount(4, 12);
hr = pConfig->SetBackingFileDuration(60);

// Add the Stream Buffer Sink filter to the graph.
hr = _pStreamBufferSink.CoCreateInstance(CLSID_SBE2Sink);
hr = _pStreamBufferSink.QueryInterface(&pInit);
hr = pInit->SetHKEY(hkey);
CComQIPtr<IBaseFilter> pSinkF(_pStreamBufferSink);
hr = _pSinkGraph->AddFilter(pSinkF, L"Stream Buffer Sink 2");

hr = ConnectFilters(_pSinkGraph, pSrcFilter, _pSourceInfTee);
hr = ConnectFilters(_pSinkGraph, _pSourceInfTee, pSinkF);
//Define stub file
hr = _pStreamBufferSink->LockProfile(ProgramDir\stubname);

The Playback Graph:

//Create the graph
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, reinterpret_cast<void**>(&_pSourceGraph));

// Add the Stream Buffer Source filter to the graph.
hr = _pStreamBufferSource.CoCreateInstance(CLSID_StreamBufferSource);

CComQIPtr<IBaseFilter> pSrcFilter(_pStreamBufferSource);
hr = _pSourceGraph->AddFilter(pSrcFilter, L"Stream Buffer Source");

// load the stub file
CComQIPtr<IFileSourceFilter> pFileSrc(pSrcFilter);
hr = pFileSrc->Load(ProgramDir\stubname, 0);

CComPtr<IBaseFilter> pRender;
hr = AddFilterByCLSID(_pSourceGraph, CLSID_VideoMixingRenderer9, L"Video Mixing Renderer 9", &pRender);

hr = ConnectFilters(_pSourceGraph, pSrcFilter, pRender);

Here is how the graphs look like in the end:

Decklink Capture ---> InfTee ---> Stream Buffer Sink 2


Stream Buffer Source ---> AVI Decompressor ---> Video Mixing Renderer 9

And here is some info about the video stream on these filters' input:

Stream Buffer Sink 2 : subtype = {43594448-0000-0010-8000-00AA00389B71} biCompression = [HDYC]

AVI Decompressor : subtype = {43594448-0000-0010-8000-00AA00389B71} biCompression = [HDYC]

I think the recording is working because the files are there and the stream format on the Decompressor is the same as in the Sink. This AVI Decompressor is placed by the Directshow Intelligent Connect. It appears also in the Capture Graph, after the InfTee, before a preview window, but there it does it's work, and I see the preview. In the Playback graph, it crashes.

Here is the call stack:

> msvcr90.dll!fastcopy_I(void * dst=0x00000000, void * src=0x003f4800, int len=111637760) + 0x20 bytes C
msvcr90.dll!_VEC_memcpy(void * dst=0x00000000, void * src=0x003f4800, int len=111684258) + 0x52 bytes C
[Frames below may be incorrect and/or missing, no symbols loaded for BMDCodecLib.dll]
msvfw32.dll!_ICSendMessage@16() + 0x31 bytes
quartz.dll!CVFWDynLink::ICDecompress() + 0x3e bytes
quartz.dll!CAVIDec::Transform() + 0x2b0 bytes
quartz.dll!CVideoTransformFilter::Receive() + 0x120 bytes
quartz.dll!CTransformInputPin::Receive() + 0x33 bytes
quartz.dll!CBaseInputPin::ReceiveMultiple() + 0x33 bytes
qcap.dll!COutputQueue::ThreadProc() + 0x103 bytes
qcap.dll!COutputQueue::InitialThreadProc() + 0x16 bytes
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes

I hope I was clear enough. I can provide more info if needed.

Any help would be much appreciated.


Return to posts index

Ryan Spitz
Re: Decklink and Stream Buffer Engine
on Jun 2, 2010 at 8:31:32 pm

Adding some more info:

The same configuration, but with SD input instead of HD, gave me the following stream inputs:

Stream Buffer Sink 2 : subtype = {59565955-0000-0010-8000-00AA00389B71} biCompression = [UYVY]

AVI Decompressor : subtype = {59565955-0000-0010-8000-00AA00389B71} biCompression = [UYVY]

And the following call stack:

> BMDCodecLib.dll!06c28206()
[Frames below may be incorrect and/or missing, no symbols loaded for BMDCodecLib.dll]

Is there a way to know what is the faulting function inside the lib?

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved