public void Start() { uint audioChannelCount = 2; _BMDAudioSampleType audioSampleDepth = _BMDAudioSampleType.bmdAudioSampleType16bitInteger; _BMDAudioSampleRate audioSampleRate = _BMDAudioSampleRate.bmdAudioSampleRate48kHz; deckLinkOutput.EnableVideoOutput(displayMode.GetDisplayMode(), _BMDVideoOutputFlags.bmdVideoOutputFlagDefault); deckLinkOutput.EnableAudioOutput(audioSampleRate, audioSampleDepth, audioChannelCount, _BMDAudioOutputStreamType.bmdAudioOutputStreamContinuous); deckLinkOutput.CreateVideoFrame(frameWidth, frameHeight, frameWidth * 2, _BMDPixelFormat.bmdFormat8BitYUV, _BMDFrameFlags.bmdFrameFlagDefault, out videoFrameBlack); FillBlack(videoFrameBlack); deckLinkOutput.CreateVideoFrame(frameWidth, frameHeight, frameWidth * 2, _BMDPixelFormat.bmdFormat8BitYUV, _BMDFrameFlags.bmdFrameFlagDefault, out videoFrameBars); FillColourBars(videoFrameBars); totalFramesScheduled = 0; for (uint i = 0; i < framesPerSecond; i++) { ScheduleNextFrame(true); } deckLinkOutput.BeginAudioPreroll(); running = true; }
public DLDirect(IDeckLink deckLink, IDeckLinkDisplayMode displayMode) { PreRollFrameCount = 4; this.displayMode = displayMode; this.m_deckLink = deckLink; DisplayWidth = displayMode.GetWidth(); DisplayHeight = displayMode.GetHeight(); m_running = false; // Get the IDeckLinkOutput interface m_deckLinkOutput = (IDeckLinkOutput)m_deckLink; // Provide this class as a delegate to the audio and video output interfaces m_deckLinkOutput.SetScheduledFrameCompletionCallback(this); m_frameWidth = displayMode.GetWidth(); m_frameHeight = displayMode.GetHeight(); displayMode.GetFrameRate(out m_frameDuration, out m_frameTimescale); // Calculate the number of frames per second, rounded up to the nearest integer. For example, for NTSC (29.97 FPS), framesPerSecond == 30. m_framesPerSecond = (uint)((m_frameTimescale + (m_frameDuration - 1)) / m_frameDuration); FPS = (int)m_framesPerSecond; // Set the video output mode m_deckLinkOutput.EnableVideoOutput(displayMode.GetDisplayMode(), _BMDVideoOutputFlags.bmdVideoOutputFlagDefault); // Generate the frame used for playback m_deckLinkOutput.CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth * 4, _BMDPixelFormat.bmdFormat8BitBGRA, _BMDFrameFlags.bmdFrameFlagDefault, out m_videoFramePlayback); m_totalFramesScheduled = 0; }
private void DisplayModeChanged(IDeckLinkDisplayMode newDisplayMode) { foreach (DisplayModeEntry item in comboBoxVideoFormat.Items) { if (item.displayMode.GetDisplayMode() == newDisplayMode.GetDisplayMode()) { comboBoxVideoFormat.SelectedItem = item; } } }
private void DisplayModeChanged(IDeckLinkDisplayMode newDisplayMode) { foreach (DisplayModeEntry item in comboBoxVideoFormat.Items) { if (item.displayMode.GetDisplayMode() == newDisplayMode.GetDisplayMode()) { comboBoxVideoFormat.SelectedItem = item; } if (m_selectedDevice != null) { labelPixelFormat.Text = m_selectedDevice.pxFormat; } } }
public static string LogDisplayMode(IDeckLinkDisplayMode deckLinkDisplayMode) { string log = ""; if (deckLinkDisplayMode != null) { var displayMode = deckLinkDisplayMode.GetDisplayMode(); int width = deckLinkDisplayMode.GetWidth(); int height = deckLinkDisplayMode.GetHeight(); deckLinkDisplayMode.GetName(out string name); var fieldDominance = deckLinkDisplayMode.GetFieldDominance(); deckLinkDisplayMode.GetFrameRate(out long frameDuration, out long timeScale); var fps = ((double)timeScale / frameDuration); log = displayMode + " " + width + "x" + height + " " + fps.ToString("0.00") + "fps " + fieldDominance; } return(log); }
public static List <DeckLinkDisplayModeDescription> GetDisplayDescriptions(IDeckLinkInput deckLinkInput, List <_BMDPixelFormat> pixelFormats, _BMDVideoConnection connection = _BMDVideoConnection.bmdVideoConnectionHDMI, _BMDSupportedVideoModeFlags videoModeFlags = _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault) { List <DeckLinkDisplayModeDescription> displayDescriptions = new List <DeckLinkDisplayModeDescription>(); IDeckLinkDisplayModeIterator iterator = null; try { deckLinkInput.GetDisplayModeIterator(out iterator); while (true) { IDeckLinkDisplayMode displayMode = null; try { iterator.Next(out displayMode); if (displayMode == null) { break; } var displayModeId = displayMode.GetDisplayMode(); displayMode.GetName(out string displayName); displayMode.GetFrameRate(out long frameDuration, out long timeScale); var fps = (double)timeScale / frameDuration; int width = displayMode.GetWidth(); int height = displayMode.GetHeight(); var resolution = width + "x" + height; var displayModeFlags = displayMode.GetFlags(); var fieldDominance = displayMode.GetFieldDominance(); foreach (var pixFmt in pixelFormats) { deckLinkInput.DoesSupportVideoMode(connection, displayModeId, pixFmt, videoModeFlags, out int supported); if (supported != 0) { displayDescriptions.Add(new DeckLinkDisplayModeDescription { ModeId = (long)displayModeId, Width = width, Height = height, Fps = fps, PixFmt = (long)pixFmt, Description = displayName + " (" + resolution + " " + fps.ToString("0.##") + " fps " + GetFourCCStr(pixFmt) + ")", }); } else { //Console.WriteLine("Display mode not supported: "+ displayModeId + " " + pixFmt); } } } finally { if (displayMode != null) { Marshal.ReleaseComObject(displayMode); displayMode = null; } } } } finally { if (iterator != null) { Marshal.ReleaseComObject(iterator); iterator = null; } } return(displayDescriptions); }
/// <summary> /// SetCallback /// </summary> public void VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newDisplayMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags) { if (newDisplayMode == null) { return; } Run(() => notifications.Text = string.Format("Video format changed: mode={0}", newDisplayMode.GetDisplayMode())); Marshal.ReleaseComObject(newDisplayMode); }