C#读取RTSP流并切录制视频
作者:互联网
下载Nuget包:EMGU.CV(测试用版本:4.0.1.3373) ;
public void InitVideo()
{
VideoCapture _capture = new VideoCapture("rtsp://admin:123456@192.168.1.237:554");
Thread.Sleep(100);
VideoWriter videoWriter = null;
Mat fram = new Mat();
Task.Run(() => {
while (true)
{
try
{
_capture.Read(fram);
var item=_capture.QueryFrame();
if (videoWriter == null)
{
videoWriter = new VideoWriter("out.mp4", 0, 24, fram.Size, false);
videoWriter.Set(WriterProperty.Framebytes, 10);
}
videoWriter.Write(fram);
}
catch (Exception ex)
{
break;
}
Thread.Sleep(10);
}
});
}
标签:capture,Thread,C#,fram,RTSP,VideoCapture,new,流并切,videoWriter 来源: https://www.cnblogs.com/LCLBook/p/16649870.html