J Pollack
J Pollack

Reputation: 2858

How to preview/display video from bytes

How could I display/preview input video using Black Magic Design DecklinkAPI.dll? I could get video frame by frame but I do not know how could I display the frame in the Form/Window. I could implement IDeckLinkInputCallback:

void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame video,
    IDeckLinkAudioInputPacket audio)
{
    IntPtr pData;
    video.GetBytes(out pData);

    // What should I do to get the preview?

    System.Runtime.InteropServices.Marshal.ReleaseComObject(video);
}

Another way I see is to implement IDeckLinkScreenPreviewCallback:

void IDeckLinkScreenPreviewCallback.DrawFrame(IDeckLinkVideoFrame theFrame)
{
    // Constructor: m_ph = new CDeckLinkDX9ScreenPreviewHelper();
    m_ph.SetFrame(theFrame);

    // Should I use this method instead to get the preview?

    System.Runtime.InteropServices.Marshal.ReleaseComObject(theFrame);
}

There more complete code samples but they are still missing the important bit of code: blackmagic SDK in c#. BMD Decklink SDK documentation could be found here.

Thanks.

Upvotes: 0

Views: 2745

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69734

If you are using DeckLink SDK to capture video, then it is your responsibility to convert frames into format, which can be consumed by presentation API (GDI, GDI+, DirectShow, Media Foundation etc) - certain effort is expected here since you typically capture in non-RGB pixel format, and possibly at non-standard stride.

Alternatively, you can use DeckLink DirectShow video capture source which captures video and makes it available as a feed compatible with DirectShow API. You can use standard components to preview and process video. You can build and control DirectShow graphs in C# through DirectShow.NET library.

Upvotes: 2

Related Questions