当前位置: 首页 > 编程语言 > C#

blackmagicSDKinc#分享

时间:2023-04-11 10:37:13 C#

blackmagicSDKinc#我正在尝试在Windows764x和C#+VS2010expressCapturein720p上使用来自blackmagicstrengthpro卡的最新SDK(2011年6月)。我已经成功编译并运行了一个在YUV中捕获帧的程序,但是在56帧之后捕获停止(回调函数停止被调用)。我想知道我是否在这里遗漏了一些简单的东西?特别是考虑到我快到了——我得到了正确的帧数、正确的大小,但只持续了很短的时间。还有一些可能相关的其他信息:这是代码:publicpartialclassMainWindow:Window,IDeckLinkInputCallback{privateIDeckLinkIterator_deckLinkIterator;私有列表_deckLinkList=newList();私人IDeckLink_currentDevice=null;私人IDeckLinkInput_deckLinkInput=null;私人int_width=1280;私人int_height=720;私有WriteableBitmap_writeableBitmap=null;IntPtr_tempRGBData;字节[]_tempRGBDataBytes;DispatcherTimer_timer=newDispatcherTimer();publicMainWindow(){InitializeComponent();}随机_random=newRandom();void_timer_Tick(objectsender,EventArgse){_random.NextBytes(_tempRGBDataBytes);_writeableBitmap.WritePixels(newInt32Rect(0,0,_width,_height),_tempRGBData,_height*_width*3,_width*3);}privatevoidWindow_Loaded(objectsender,RoutedEventArgse){_writeableBitmap=newWriteableBitmap(_width,_height,72,27,PixelFormats.Bgr24,null);_captureImage.Source=_writeableBitmap;_tempRGBData=Marshal.AllocH全局(3*_width*_height*Marshal.SizeOf(typeof(字节)));_tempRGBDataBytes=新字节[3*_width*_height];_deckLinkIterator=newCDeckLinkIterator();IDeckLinkdl=空;while(true){_deckLinkIterator.Next(outdl);如果(dl==null){中断;}else{_deckLinkList.Add(dl);}}foreach(_deckLinkList中的IDeckLink设备){字符串名称;device.GetModelName(输出名称);Console.WriteLine(""+名称);}_currentDevice=_deckLinkList[1];_deckLinkInput=(IDeckLinkInput)_currentDevice;uint帧数=0;_deckLinkInput.GetAvailableVideoFrameCount(outframeCount);Console.WriteLine("可用帧数:"+frameCount);IDeckLinkDisplayModeIteratordisplayIterator=null;_deckLinkInput.GetDisplayModeIterator(outdisplayIterator);_BMDDisplayModeSupport显示模式支持;IDeckLinkDisplayModedisplayMode=null;_BMDDisplayModesetDisplayMode=_BMDDisplayMode.bmdModeHD720p50;_BMDPixelFormatsetPixelFormat=_BMDPixelFormat.bmdFormat8BitYUV;_BMD视频InputFlagssetInputFlag=_BMDVideoInputFlags.bmdVideoInputFlagDefault;_deckLinkInput.DoesSupportVideoMode(setDisplayMode,setPixelFormat,setInputFlag,outdisplayModeSupport,outdisplayMode);尝试{//_deckLinkInput.DisableAudioInput();_deckLinkInput.EnableVideoInput(setDisplayMode,setPixelFormat,setInputFlag);}catch(Exceptionem){Console.WriteLine("decklinkinitfailed:"+em.Message);}_deckLinkInput.SetCallback(这个);Console.WriteLine("完成!");_timer.Interval=TimeSpan.FromSeconds(1f/30f);_timer.Tick+=newEventHandler(_timer_Tick);_timer.Start();}intframeCount=0;publicvoidVideoInputFrameArrived(IDeckLinkVideoInputFramevideo,IDeckLinkAudioInputPacketaudio){//获取图像数据IntPtrpData;video.GetBytes(输出数据);//保持简单,所以只计算帧-这被调用56次然后停止帧数++;}publicvoidVideoInputFormatChanged(_BMDVideoInputFormatChangedEventsevents,IDeckLinkDisplayModedisplayMode,_BMDDetectedVideoInputFormatFlagsflags){Console.WriteLine("视频格式改变了!!");}//开始流privatevoidbutton1_Click(objectsender,RoutedEventArgse){_deckLinkInput.StartStreams();}//停止流privatevoidbutton2_Click(objectsender,RoutedEventArgse){_deckLinkInput.StopStreams();}privatevoidbutton4_Click(objectsender,RoutedEventArgse){_deckLinkInput.PauseStreams();}privatevoidbutton3_Click(objectsender,RoutedEventArgse){_deckLinkInput.FlushStreams();我在blackmagic技术支持的帮助下设法解决了这个问题解决方案是在回调函数的末尾插入这一行:以上就是C#学习教程:blackmagicSDKinc#分享的全部,如果你like大家有用,需要多了解C#学习教程。希望大家多多关注——System.Runtime.InteropServices.Marshal.ReleaseComObject(video);本文收集自网络,不代表立场。如涉及侵权请点击维权联系管理员删除转载请注明出处:

最新推荐
猜你喜欢