I am trying to display live video Using UltraStudio SDI Connected Via USB3 to my computer and connected via SDI IN to My Camera.
but when I wrote the following Code Only Black Image displays always
I want live video not black image
the Code As Follow:
<pre lang="c#">
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeckLinkAPI;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Runtime.InteropServices;
namespace VideoGrapperUltraStudioSDI
{
public partial class Form1 : Form, IDeckLinkInputCallback, IDeckLinkScreenPreviewCallback
{
private IDeckLink m_deckLink;
private IDeckLinkInput m_deckLinkInput;
private Device m_device;
public static IDeckLinkDX9ScreenPreviewHelper m_ph;
public unsafe Form1()
{
InitializeComponent();
PresentParameters pp = new PresentParameters();
pp.BackBufferFormat = Format.Unknown;
pp.BackBufferCount = 2;
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
pp.PresentationInterval = PresentInterval.Default;
m_device = new Device(0,
DeviceType.Hardware,
this,
CreateFlags.SoftwareVertexProcessing,
pp);
m_ph = new CDeckLinkDX9ScreenPreviewHelper();
m_ph.Initialize((IntPtr)m_device.UnmanagedComPointer);
IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();
deckLinkIterator.Next(out m_deckLink);
m_deckLinkInput = (IDeckLinkInput)m_deckLink;
m_deckLinkInput.EnableVideoInput(_BMDDisplayMode.bmdModeHD720p50, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault);
m_deckLinkInput.SetCallback(this);
m_deckLinkInput.SetScreenPreviewCallback(this);
m_deckLinkInput.StartStreams();
}
public void VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newDisplayMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags)
{
throw new NotImplementedException();
}
public void VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(videoFrame);
}
public void DrawFrame(IDeckLinkVideoFrame theFrame)
{
m_ph.SetFrame(theFrame);
m_device.Present();
System.Runtime.InteropServices.Marshal.ReleaseComObject(theFrame);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
}
}
}
I wait your response thank you,,,,
What I have tried:
I am trying to use Device.beginSence()
Device.EndSence()
Device.Render();
but that did not solve the problem