private static async Task StartStreamProcessingAsync(InputSource inputSource, CancellationToken cancellationToken = default) { Console.WriteLine("Start Stream Processing"); var client = new VideoStreamClient(); client.NewImageReceived += NewImageReceived; await client.StartFrameReaderAsync(inputSource, OutputImageFormat.Bmp, cancellationToken); client.NewImageReceived -= NewImageReceived; Console.WriteLine("End Stream Processing"); }
static void Main(string[] args) { if (!Directory.Exists("frames")) { Directory.CreateDirectory("frames"); } //var inputSource = new WebcamInputSource("Microsoft® LifeCam HD-3000"); var inputSource = new StreamInputSource("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"); var cancellationTokenSource = new CancellationTokenSource(); var client = new VideoStreamClient(); client.NewImageReceived += NewImageReceived; var task = client.StartFrameReaderAsync(inputSource, OutputImageFormat.Bmp, cancellationTokenSource.Token); Console.WriteLine("Video Stream Frame handling started"); Task.WaitAll(task); client.NewImageReceived -= NewImageReceived; cancellationTokenSource.Cancel(); Console.WriteLine("Video Stream Frame handling stopped"); Console.ReadLine(); }