private void StopPlayBack() { //关闭当前回放视频 if (m_lPlayBackHandle != -1) { TimerPlayBack.Enabled = false; SetStopState(); bool IsStop = CHCNetSDK.NET_DVR_StopPlayBack(m_lPlayBackHandle); m_lPlayBackHandle = -1; } if (m_PlayBackPort >= 0) { bool isstop = PlayCtrl.PlayM4_Stop(m_PlayBackPort); //关闭回放流 if (PlayCtrl.PlayM4_CloseStream(m_PlayBackPort)) { PlayCtrl.PlayM4_FreePort(m_PlayBackPort); m_PlayBackPort = -1; } else { m_PlayBackPort = -1; } } }
private void button1_Click(object sender, EventArgs e) { if (!play && PlayCtrl.PlayM4_Play(0, pictureBox1.Handle)) { button1.Text = "暂停"; play = true; Console.WriteLine("播放成功"); } else { if (!m_bPause) { PlayCtrl.PlayM4_Pause(0, 1); button1.Text = "继续播放"; m_bPause = true; Console.WriteLine("暂停成功"); } else { PlayCtrl.PlayM4_Pause(0, 0); button1.Text = "暂停"; m_bPause = false; Console.WriteLine("恢复播放成功"); } } }
private void PlayBackVideo(object sender, System.Timers.ElapsedEventArgs e) { try { if (IsPlayBack == false) { IsPlayBack = true; uint playtime = PlayCtrl.PlayM4_GetPlayedTime(m_PlayBackPort); if (playtime == 0xffffffff) {//获取时间失败 return; } cursecond += playtime; double dprogress = Math.Round((1.0 * cursecond / PlayBackTotalSecond), 2); int iprogress = (int)(dprogress * 100); if (iprogress > 100) { //StopPlay(); StopPlayBack(); } else { trackBarPlaybackProgress.Value = iprogress; } } } catch (Exception ex) { } finally { IsPlayBack = false; } }
private void StartPlayVideo(string filename) { if (filename != "") { StopVideo(); if (PlayCtrl.PlayM4_GetPort(ref m_lPort)) { m_ptrRealHandle = picPlayBack.Handle; m_FileRefDone = new PlayCtrl.PFILEREFDONE(PlayCallBack); if (PlayCtrl.PlayM4_SetFileRefCallBack(m_lPort, m_FileRefDone, 0)) { } if (PlayCtrl.PlayM4_OpenFile(m_lPort, filename)) { if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle)) { m_CurPlayState = PlayState.PlayNormal; SetCtrlEnable(); } else { uint error = PlayCtrl.PlayM4_GetLastError(m_lPort); } } } else { uint error = PlayCtrl.PlayM4_GetLastError(m_lPort); } } }
public void RemoteDisplayCBFun(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReserved) { //MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo); if (!m_bJpegCapture) { return; } else { uint nLastErr = 100; // save picture as you want if (!PlayCtrl.PlayM4_ConvertToJpegFile(pBuf, nSize, nWidth, nHeight, nType, "C:/Capture.jpg")) { //Debug.WriteLine("PlayM4_ConvertToJpegFile fail"); nLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort); //this.BeginInvoke(AlarmInfo, "Jpeg Capture fail"); } else { // this.BeginInvoke(AlarmInfo, "Jpeg Capture Succ"); //Debug.WriteLine("PlayM4_ConvertToJpegFile Succ"); } } m_bJpegCapture = false; }
private void btnJpegCapture_Click(object sender, EventArgs e) { m_bJpegCapture = true; IntPtr ptrJpeg = new IntPtr(); uint nBuffersize = 2 * 1024 * 1024; ptrJpeg = Marshal.AllocHGlobal((int)nBuffersize); uint dwJpegSize = 0; if (PlayCtrl.PlayM4_GetJPEG(m_lPort, ptrJpeg, nBuffersize, ref dwJpegSize)) { DebugInfo("PlayM4_GetJPEG succ"); } else { uint dwErrorNo = PlayCtrl.PlayM4_GetLastError(m_lPort); DebugInfo("PlayM4_GetJPEG fail"); } FileStream fs = new FileStream("C:/GetJpegSave.jpg", FileMode.Create); byte[] by = new byte[dwJpegSize]; Marshal.Copy(ptrJpeg, by, 0, (int)dwJpegSize); fs.Write(by, 0, (int)dwJpegSize); fs.Close(); Marshal.FreeHGlobal(ptrJpeg); //public static extern bool PlayM4_GetJPEG(int nPort, ref byte pJpeg, uint nBufSize, ref uint pJpegSize); }
private void MouseMove(object sender, MouseEventArgs e) { if (!m_bMoved) { return; } int tag = Convert.ToInt32(EagleVideo.Tag); float fpi = 3.1415926f; int iWndWidth = EagleVideo.PicWidth; //当前窗口宽度 int iWndHeight = EagleVideo.PicHeight; //当前窗口高度 PlayCtrl.DRAWPOINT strPoint = new PlayCtrl.DRAWPOINT(); strPoint.x = e.X * 1.0f / iWndWidth; strPoint.y = e.Y * 1.0f / iWndHeight; strPoint.x = ((e.X - m_strPrePoint.x) * 1.0f) / iWndWidth; strPoint.y = ((e.Y - m_strPrePoint.y) * 1.0f) / iWndHeight; PlayCtrl.PLAYM4SRTRANSFERPARAM stParam = new PlayCtrl.PLAYM4SRTRANSFERPARAM(); PlayCtrl.PLAYM4SRTRANSFERELEMENT stSubParam = new PlayCtrl.PLAYM4SRTRANSFERELEMENT(); stSubParam.fAxisX = strPoint.x * 8 * fpi; stSubParam.fAxisY = strPoint.y * 4 * fpi; stSubParam.fAxisZ = 0.0f; stSubParam.fValue = 0.0f; IntPtr ptrSRTransformElement = Marshal.AllocHGlobal(Marshal.SizeOf(stSubParam)); Marshal.StructureToPtr(stSubParam, ptrSRTransformElement, false); stParam.pTransformElement = ptrSRTransformElement; PlayCtrl.PlayM4_SR_Rotate(m_Channel[tag], ref stParam); m_strPrePoint.x = e.X; m_strPrePoint.y = e.Y; Marshal.FreeHGlobal(ptrSRTransformElement); }
private void RemoteDisplayCBFun(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReserved) { try { if (!m_bJpegCapture) { return; } else { uint nLastErr = 100; // save picture as you want if (!PlayCtrl.PlayM4_ConvertToJpegFile(pBuf, nSize, nWidth, nHeight, nType, "C:/Capture.jpg")) { nLastErr = PlayCtrl.PlayM4_GetLastError(nPort); //m_Channel } else { } } m_bJpegCapture = false; } catch (Exception ex) { } }
private void StopVideo() { if (m_CurPlayState != PlayState.PlayStop && m_CurPlayState != PlayState.None) { if (PlayCtrl.PlayM4_Stop(m_lPort)) { if (PlayCtrl.PlayM4_CloseFile(m_lPort)) { if (PlayCtrl.PlayM4_FreePort(m_lPort)) { m_CurPlayState = PlayState.PlayStop; SetCtrlEnable(); } } else { uint error = PlayCtrl.PlayM4_GetLastError(m_lPort); } } else { uint error = PlayCtrl.PlayM4_GetLastError(m_lPort); } } }
private void btnPrivate_Click(object sender, EventArgs e) { int iPort = CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle); if (iPort > -1) { if (!PlayCtrl.PlayM4_RenderPrivateData(iPort, 0x20, true)) { iLastErr = PlayCtrl.PlayM4_GetLastError(iPort); str = "PlayM4_RenderPrivateData failed, error code= " + iLastErr; DebugInfo(str); } if (!PlayCtrl.PlayM4_RenderPrivateDataEx(iPort, 0x00000020, 0x00000001 + 0x00000002 + 0x00000004, true)) { iLastErr = PlayCtrl.PlayM4_GetLastError(iPort); str = "PlayM4_RenderPrivateDataEx failed, error code= " + iLastErr; DebugInfo(str); } if (!PlayCtrl.PlayM4_SetOverlayPriInfoFlag(iPort, 0x20, true)) { iLastErr = PlayCtrl.PlayM4_GetLastError(iPort); str = "PlayM4_SetOverlayPriInfoFlag failed, error code= " + iLastErr; DebugInfo(str); } } }
public bool stopPreview(int RealHandle) { //停止预览 Stop live view if (!CHCNetSDK.NET_DVR_StopRealPlay(RealHandle)) { return(false); } if ((previewMode == 1) && (m_lPort >= 0)) { if (!PlayCtrl.PlayM4_Stop(m_lPort)) { return(false); } if (!PlayCtrl.PlayM4_CloseStream(m_lPort)) { return(false); } if (!PlayCtrl.PlayM4_FreePort(m_lPort)) { return(false); } m_lPort = -1; } return(true); }
private void PlayBackMouseMove(object sender, MouseEventArgs e) { if (CurVideo.CameraType == 4) { if (!m_bEagleMoved) { return; } //int tag = Convert.ToInt32(EaglePalyBackVideo.Tag); float fpi = 3.1415926f; int iWndWidth = EaglePalyBackVideo.PicWidth; //当前窗口宽度 int iWndHeight = EaglePalyBackVideo.PicHeight; //当前窗口高度 PlayCtrl.DRAWPOINT strPoint = new PlayCtrl.DRAWPOINT(); strPoint.x = e.X * 1.0f / iWndWidth; strPoint.y = e.Y * 1.0f / iWndHeight; strPoint.x = ((e.X - m_strPlayBackPoint.x) * 1.0f) / iWndWidth; strPoint.y = ((e.Y - m_strPlayBackPoint.y) * 1.0f) / iWndHeight; PlayCtrl.PLAYM4SRTRANSFERPARAM stParam = new PlayCtrl.PLAYM4SRTRANSFERPARAM(); PlayCtrl.PLAYM4SRTRANSFERELEMENT stSubParam = new PlayCtrl.PLAYM4SRTRANSFERELEMENT(); stSubParam.fAxisX = strPoint.x * 8 * fpi; stSubParam.fAxisY = strPoint.y * 4 * fpi; stSubParam.fAxisZ = 0.0f; stSubParam.fValue = 0.0f; IntPtr ptrSRTransformElement = Marshal.AllocHGlobal(Marshal.SizeOf(stSubParam)); Marshal.StructureToPtr(stSubParam, ptrSRTransformElement, false); stParam.pTransformElement = ptrSRTransformElement; bool isRotate = PlayCtrl.PlayM4_SR_Rotate(m_PlayBackPort, ref stParam); //uint errorcode= PlayCtrl.PlayM4_GetLastError(m_PlayBackPort); m_strPlayBackPoint.x = e.X; m_strPlayBackPoint.y = e.Y; Marshal.FreeHGlobal(ptrSRTransformElement); } }
private void sbtnNormal_Click(object sender, EventArgs e) { if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle)) { m_CurPlayState = PlayState.PlayNormal; SetCtrlEnable(); } }
private void ResumePalyBack() { //先暂停网络库 uint temp = 0; bool IsNetPause = CHCNetSDK.NET_DVR_PlayBackControl(m_lPlayBackHandle, CHCNetSDK.NET_DVR_PLAYRESTART, 0, ref temp); //再暂停播放库 bool IsPlayCtrlPause = PlayCtrl.PlayM4_Pause(m_PlayBackPort, 0); }
private void PausePlayBack() { //先暂停网络库 uint temp = 0; bool IsNetPause = CHCNetSDK.NET_DVR_PlayBackControl(m_lPlayBackHandle, CHCNetSDK.NET_DVR_PLAYPAUSE, 0, ref temp); //再暂停播放库 bool IsPlayCtrlPause = PlayCtrl.PlayM4_Pause(m_PlayBackPort, 1); }
private void btnOpenSound_Click(object sender, EventArgs e) { // private Int32 m_iPreviewType = 0; if (m_lRealHandle < 0) { MessageBox.Show("Please preview first"); } else { if (m_iPreviewType == 0) // callback { if (!m_bOpenSound) { if (PlayCtrl.PlayM4_PlaySound(m_lPort)) { m_bOpenSound = true; btnOpenSound.Text = "Stop sound"; } else { Debug.Print("Fail to open sound"); } } else { if (PlayCtrl.PlayM4_StopSound()) { m_bOpenSound = false; btnOpenSound.Text = "Open sound"; } } } else // Sdk decode { if (!m_bOpenSound) { if (CHCNetSDK.NET_DVR_OpenSound(m_lRealHandle)) { m_bOpenSound = true; btnOpenSound.Text = "Stop sound"; } else { Debug.Print("Fail to open sound"); } } else { if (CHCNetSDK.NET_DVR_CloseSound()) { m_bOpenSound = false; btnOpenSound.Text = "Open sound"; } } } } }
private void GetFilePlayPos() { float pos = PlayCtrl.PlayM4_GetPlayPos(m_lPort); this.pgbPlayPos.Value = Convert.ToInt32(pos * 100); if (pos == 1) {//播放结束 StopVideo(); } }
/// <summary> /// Start Preview in realtime. /// <para><paramref name="playWndHandle"/> - window handle, on fitch will be drawing.</para> /// <para><paramref name="previewSettings"/> - preview settings.</para> /// </summary> public void StartPreview(IntPtr playWndHandle, NvrPreviewSettings previewSettings) { if (livePlayer_.RealPlayHandle != -1) { throw new NvrBadLogicException("Call StopPreview before calling StartPreview"); } if (!NvrUserSession.IsSessionValid()) { throw new NvrBadLogicException("Call StartPreview when NvrUserSession is invalid"); } livePlayer_ = new LivePlayer(playWndHandle, previewSettings); CHCNetSDK.NET_DVR_PREVIEWINFO previewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO() { lChannel = NvrUserSession.UserSessionState.SelectedChannelNum, dwStreamType = livePlayer_.PreviewSettings.StreamType, dwLinkMode = (uint)livePlayer_.PreviewSettings.LinkMode, bBlocked = livePlayer_.PreviewSettings.IsBlocked, dwDisplayBufNum = livePlayer_.PreviewSettings.DisplayBufNum, byPreviewMode = (byte)livePlayer_.PreviewSettings.PreviewMode }; switch (previewSettings.PreviewHandleMode) { case PreviewHandleType.Direct: livePlayer_.RealDataCallBackFunc = null; previewInfo.hPlayWnd = livePlayer_.PlayWndHandlePtr; break; case PreviewHandleType.CallBack: livePlayer_.RealDataCallBackFunc = new CHCNetSDK.REALDATACALLBACK(realDataCallBack); // Real-time stream callback function previewInfo.hPlayWnd = IntPtr.Zero; break; } livePlayer_.RealPlayHandle = CHCNetSDK.NET_DVR_RealPlay_V40(NvrUserSession.UserSessionState.UserId, ref previewInfo, livePlayer_.RealDataCallBackFunc, IntPtr.Zero); if (livePlayer_.RealPlayHandle == -1) { throw new NvrSdkException(CHCNetSDK.NET_DVR_GetLastError(), "NET_DVR_RealPlay_V40 failed: " + livePlayer_.RealPlayHandle); } if (previewSettings.PreviewHandleMode == PreviewHandleType.Direct) { livePlayer_.DrawCallBackFunc = new CHCNetSDK.DRAWFUN(drawCallBack); if (!CHCNetSDK.NET_DVR_RigisterDrawFun(livePlayer_.RealPlayHandle, livePlayer_.DrawCallBackFunc, 0)) { invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "NET_DVR_RigisterDrawFun failed"); } } debugInfo("NET_DVR_RealPlay_V40 succ!"); }
private void sbtnSlow_Click(object sender, EventArgs e) { if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle)) {//先恢复正常播放 if (PlayCtrl.PlayM4_Slow(m_lPort)) { m_CurPlayState = PlayState.PlaySlow; SetCtrlEnable(); } } }
private void m_btnFast_Click(object sender, EventArgs e) { bool IsFast = PlayCtrl.PlayM4_Fast(m_PlayBackPort); //uint dwTemp = 0; //if (CHCNetSDK.NET_DVR_PlayBackControl(m_lPlayHandle, CHCNetSDK.NET_DVR_PLAYFAST, 0, ref dwTemp)) //{ //} //else //{ //} }
private void m_btnSlow_Click(object sender, EventArgs e) { //uint dwTemp = 0; //if (CHCNetSDK.NET_DVR_PlayBackControl(m_lPlayHandle, CHCNetSDK.NET_DVR_PLAYSLOW, 0, ref dwTemp)) //{ //} //else //{ //} bool IsSlow = PlayCtrl.PlayM4_Slow(m_PlayBackPort); }
private void button2_Click(object sender, EventArgs e) { if (PlayCtrl.PlayM4_Stop(0)) { play = false; m_bPause = false; button1.Text = "播放"; //pictureBox1.Image = null ; progressBar1.Value = 0; label4.Text = "00:00:00"; Console.WriteLine("停止播放成功"); } }
// Update is called once per frame void Update() { if (player == null) { GameObject obj = GameObject.FindGameObjectWithTag("Player"); if (obj != null) { player = obj.GetComponent <PlayCtrl>(); } } UpdateTimer(); DisplayHudData(); }
/// <summary> /// Stop Preview. /// </summary> public void StopPreview() { if (livePlayer_.RealPlayHandle == -1) { debugInfo("Preview not started!"); return; } { // Set to null Draw CallBack Function CHCNetSDK.NET_DVR_RigisterDrawFun(livePlayer_.RealPlayHandle, null, 0); } bool isStopRealPlayOk; { // Stop live view isStopRealPlayOk = CHCNetSDK.NET_DVR_StopRealPlay(livePlayer_.RealPlayHandle); if (livePlayer_.RealPlayPort >= 0) { if (!PlayCtrl.PlayM4_Stop(livePlayer_.RealPlayPort)) { invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_Stop failed"); } if (!PlayCtrl.PlayM4_CloseStream(livePlayer_.RealPlayPort)) { invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_CloseStream failed"); } if (!PlayCtrl.PlayM4_FreePort(livePlayer_.RealPlayPort)) { invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_FreePort failed"); } } } livePlayer_ = LivePlayer.Default(); if (isStopRealPlayOk) { debugInfo("NET_DVR_StopRealPlay succ!"); } else { throw new NvrSdkException(CHCNetSDK.NET_DVR_GetLastError(), "NET_DVR_StopRealPlay failed"); } }
private void replay_Load(object sender, EventArgs e) { if (path == null) { Close(); MessageBox.Show("未选择有效文件"); return; } Boolean flag = PlayCtrl.PlayM4_OpenFile(0, path); Console.WriteLine(flag ? "文件打开成功" : "文件打开失败"); PlayCtrl.PlayM4_SetPicQuality(0, 1); PlayCtrl.PlayM4_SetPlayPos(0, 0); label3.Text = GetTime(PlayCtrl.PlayM4_GetFileTime(0)); }
private void dgvPlayCtrl_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { PlayCtrl pro = (TotalConfig_List[dgvTotal.SelectedRows[0].Index] as PlayCtrl); if (e.ColumnIndex == ColumnPlayCtrlTerminalAddress.Index) { DailyBroadcastTerAddressInfo detail = new DailyBroadcastTerAddressInfo(pro.Program.list_Terminal_Address, (MdiParent as EBMMain).AdminAccount); DialogResult result = detail.ShowDialog(); if (result == DialogResult.OK && (MdiParent as EBMMain).AdminAccount) { pro.Program.list_Terminal_Address = detail.GetData() as List <string>; } detail.Dispose(); dgvPlayCtrl.Invalidate(); } } }
private void SR_ZOOM(float fStep, int tag) { if (m_Channel[tag] < 0) { return; } PlayCtrl.PLAYM4SRTRANSFERPARAM stParam = new PlayCtrl.PLAYM4SRTRANSFERPARAM(); PlayCtrl.PLAYM4SRTRANSFERELEMENT stSubParam = new PlayCtrl.PLAYM4SRTRANSFERELEMENT(); stSubParam.fAxisX = 0.0f; stSubParam.fAxisY = 0.0f; stSubParam.fAxisZ = 0.0f; stSubParam.fValue = fStep; IntPtr ptrSRTransformElement = Marshal.AllocHGlobal(Marshal.SizeOf(stSubParam)); Marshal.StructureToPtr(stSubParam, ptrSRTransformElement, false); stParam.pTransformElement = ptrSRTransformElement; PlayCtrl.PlayM4_SR_Rotate(m_Channel[tag], ref stParam); Marshal.FreeHGlobal(ptrSRTransformElement); }
private void timer1_Tick(object sender, EventArgs e) { if (!play || m_bPause) { return; } progressBar1.Value = (int)(PlayCtrl.PlayM4_GetPlayPos(0) * 100); label4.Text = GetTime(PlayCtrl.PlayM4_GetPlayedTime(0)); Console.WriteLine(PlayCtrl.PlayM4_GetPlayedTime(0)); Console.WriteLine(PlayCtrl.PlayM4_GetPlayedTimeEx(0)); Console.WriteLine(PlayCtrl.PlayM4_GetFileTime(0)); if (PlayCtrl.PlayM4_GetPlayedTimeEx(0) >= PlayCtrl.PlayM4_GetFileTime(0) * 1000) { progressBar1.Value = 100; play = false; m_bPause = false; button2_Click(null, null); } }
private void PlayBack_e_EagleModeChange(UCVideo video) { int tag = Convert.ToInt32(video.Tag); if (m_PlayBackPort >= 0) { PlayCtrl.PLAYM4SRMODELMODE struParam = new PlayCtrl.PLAYM4SRMODELMODE(); struParam.emTextureMode = (uint)PlayCtrl.PLAYM4SRTEXTUREMODE.PLAYM4_TEXTURE_DOUBLE; struParam.ulDisplayType = PlayCtrl.PLAYM4_MODEL_SOLID; struParam.nTransformMode = 0; struParam.emModelType = (uint)PlayCtrl.PLAYM4SRMODELTYPE.PLAYM4_MODELTYPE_EAGLE_EYE; struParam.bModelMode = video.IsQJVideo; // true是碗装,false是块状 int dwSize = Marshal.SizeOf(struParam); IntPtr ptrDeviceCfg = Marshal.AllocHGlobal(dwSize); Marshal.StructureToPtr(struParam, ptrDeviceCfg, false); if (!PlayCtrl.PlayM4_SR_SetConfig(m_PlayBackPort, PlayCtrl.CFG_DISPLAY_MODEL_MODE, ptrDeviceCfg)) { Marshal.FreeHGlobal(ptrDeviceCfg); } } }
private void sbtnPause_Click(object sender, EventArgs e) { if (sbtnPause.Text == "暂停") { sbtnPause.Text = "恢复"; //this.btnPause.Image = global::HikHelp.Properties.Resources.恢复; if (PlayCtrl.PlayM4_Pause(m_lPort, 1)) { m_CurPlayState = PlayState.PlayPause; SetCtrlEnable(); } } else if (sbtnPause.Text == "恢复") { sbtnPause.Text = "暂停"; //this.btnPause.Image = global::HikHelp.Properties.Resources.暂停; if (PlayCtrl.PlayM4_Pause(m_lPort, 0)) { m_CurPlayState = PlayState.PlayRestore; SetCtrlEnable(); } } }
private void Button_Click(object sender, RoutedEventArgs e) { PlayCtrl t = new PlayCtrl(); MessageBox.Show(t.version()); }
//解码回调函数 private void DecCallbackFUN(int nPort, IntPtr pBuf, int nSize, ref PlayCtrl.FRAME_INFO pFrameInfo, int nUser) { // 将pBuf解码后视频输入写入文件中(解码后YUV数据量极大,尤其是高清码流,不建议在回调函数中处理) if (pFrameInfo.nType == 3) //#define T_YV12 3 { MODSDK.JTMOD_FRAME_INFO frameInfo = new MODSDK.JTMOD_FRAME_INFO(); frameInfo.size = (ushort)Marshal.SizeOf(frameInfo); frameInfo.nWidth = (ushort)picCapture.Width; frameInfo.nHeight = (ushort)picCapture.Height; frameInfo.datatype = 1; frameInfo.lDataLen = (uint)nSize; frameInfo.iFrameIndex = pFrameInfo.dwFrameNum; frameInfo.timestamp = (uint)pFrameInfo.nStamp; frameInfo.pData = pBuf; frameInfo.importGrade = 1; MODSDK.JtModProcess(glopara, ref frameInfo); // FileStream fs = null; // BinaryWriter bw = null; // try // { // fs = new FileStream("DecodedVideo.yuv", FileMode.Append); // bw = new BinaryWriter(fs); // byte[] byteBuf = new byte[nSize]; // Marshal.Copy(pBuf, byteBuf, 0, nSize); // bw.Write(byteBuf); // bw.Flush(); // } // catch (System.Exception ex) // { // MessageBox.Show(ex.ToString()); // } // finally // { // bw.Close(); // fs.Close(); // } } }
//解码回调函数 private void DecCallbackFUN(int nPort, IntPtr pBuf, int nSize, ref PlayCtrl.FRAME_INFO pFrameInfo, int nReserved1, int nReserved2) { // 将pBuf解码后视频输入写入文件中(解码后YUV数据量极大,尤其是高清码流,不建议在回调函数中处理) if (pFrameInfo.nType == 3) //#define T_YV12 3 { // FileStream fs = null; // BinaryWriter bw = null; // try // { // fs = new FileStream("DecodedVideo.yuv", FileMode.Append); // bw = new BinaryWriter(fs); // byte[] byteBuf = new byte[nSize]; // Marshal.Copy(pBuf, byteBuf, 0, nSize); // bw.Write(byteBuf); // bw.Flush(); // } // catch (System.Exception ex) // { // MessageBox.Show(ex.ToString()); // } // finally // { // bw.Close(); // fs.Close(); // } } }