简体   繁体   English

Windows IOT广播网络摄像头

[英]Windows IOT Broadcast Webcam

I would like to make a Webcam Broadcast app on my Raspberry pi 2 running Windows IOT. 我想在运行Windows IOT的Raspberry pi 2上制作一个Webcam Broadcast应用程序。

As we see in the Windows IOT samples , you can record video but you can't 正如我们在Windows IOT示例中所看到的,您可以录制视频,但不能

broadcast the video on network (as wifi). 在网络上广播视频(作为wifi)。 In this code, I use the MediaCapture class to get the video stream. 在这段代码中,我使用MediaCapture类获取视频流。

            // this._mediaCapture is a MediaCapture variable, initialized
        // there is a MediaElement item to see the video
        InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
        MediaEncodingProfile profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

        // starting recording to stream
        await this._mediaCapture.StartRecordToStreamAsync(profile,stream);
        // stopping recording to access the stream
        await this._mediaCapture.StopRecordAsync();
        //linking the stream to a MediaElement item to see the video
        await stream.FlushAsync();
        MediaElement.SetSource(stream, "video / mp4");
        MediaElement.Play();
        return stream;

The problem is that we have to call the StopRecordAsync method to access the stream. 问题是我们必须调用StopRecordAsync方法来访问流。 With a timer, we can record a 5s (for example) vidéo, call the StopRecordAsync method, flush the stream and do it in a loop but. 使用计时器,我们可以录制一个5秒(例如)的vidéo,调用StopRecordAsync方法,刷新流并循环执行。

I don't have detailed solution but a hint. 我没有详细的解决方案,但有提示。 I think recording is not what you want. 我认为录制不是您想要的。 You just want to grab and upload the preview stream from veiwfinder. 您只想从veiwfinder抓取并上传预览流。 For that you need to send the preview stream to a customized sink. 为此,您需要将预览流发送到自定义接收器。 In your case that will be a cyclic buffer receiving from media capture and sending them to server. 在您的情况下,这将是一个循环缓冲区,用于从媒体捕获中接收并将其发送到服务器。

You should check the method: 您应该检查方法:

MediaCapture.StartPreviewToCustomSinkAsync()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM