Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;

           // _BMDDisplayModeSupport displayModeSupport;
           // IDeckLinkDisplayMode displayMode = null;
          //  m_deckLinkInput.DoesSupportVideoMode(_BMDDisplayMode.bmdModeHD720p50, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault, out displayModeSupport, out displayMode);
            //m_deckLinkInput.DoesSupportVideoMode(_BMDDisplayMode.bmdModeHD1080i5994, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault,out displayModeSupport,out displayMode);
            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);

          
           /* IntPtr buffer;
           
            tagRECT rc = new tagRECT();
            theFrame.GetBytes(out buffer);
            m_device.BeginScene();
            m_ph.Render(ref rc);

            m_device.EndScene();
            m_device.Present(buffer);*/
            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)
        {
        }

       

        /*private void Form1_Paint(object sender, PaintEventArgs e)
        {
            timer1.Enabled = true;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            m_device.Present();
        }*/
    }
}


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
Posted
Updated 24-May-16 10:31am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900