How to get an IP camera stream into C#?

后端 未结 5 701
心在旅途
心在旅途 2021-01-31 23:07

I\'ve used AForge library to make this little program, that shows live feed from a webcam into a PictureBox.

private FilterInfoCollection VideoCaptureDevices;
pr         


        
5条回答
  •  别那么骄傲
    2021-01-31 23:33

    Nager.VideoStream is based on ffmpeg and can therefore easily be used across platforms. Network cameras and webcams can be accessed via ffmpeg.

    PM> install-package Nager.VideoStream
    
    var inputSource = new StreamInputSource("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
    //var inputSource = new WebcamInputSource("Microsoft® LifeCam HD-3000");
    
    var cancellationTokenSource = new CancellationTokenSource();
    
    var client = new VideoStreamClient();
    client.NewImageReceived += NewImageReceived;
    var task = client.StartFrameReaderAsync(inputSource, OutputImageFormat.Bmp, cancellationTokenSource.Token);
    //Console.ReadLine();
    client.NewImageReceived -= NewImageReceived;
    
    private static void NewImageReceived(byte[] imageData)
    {
        File.WriteAllBytes($@"{DateTime.Now.Ticks}.bmp", imageData);
    }
    

提交回复
热议问题