c# - Windows IOT 广播网络摄像头

标签 c# .net windows uwp iot

我想在运行 Windows IOT 的 Raspberry pi 2 上制作一个网络摄像头广播应用。

正如我们在 Windows 中看到的那样 IOT samples , 你可以录制视频但你不能

在网络上播放视频(作为 wifi)。 在此代码中,我使用 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;

问题是我们必须调用 StopRecordAsync 方法来访问流。 使用计时器,我们可以录制 5 秒(例如)的视频,调用 StopRecordAsync 方法,刷新流并在循环中执行此操作。

最佳答案

我没有详细的解决方案,只有一个提示。我认为录音不是你想要的。您只想从 veiwfinder 抓取并上传预览流。为此,您需要将预览流发送到自定义接收器。在您的情况下,这将是一个循环缓冲区,从媒体捕获中接收并将它们发送到服务器。

你应该检查方法:

MediaCapture.StartPreviewToCustomSinkAsync()

关于c# - Windows IOT 广播网络摄像头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33697735/

相关文章:

c# - 将包含非英文字符的C# POCO序列化为JSON

c# - 如何写入 .NET Core 中的文件?

c# - .NET Dictionary<T,T> 使用什么来散列引用?

c# - 代码合约运行时错误消息

java - 文件路径中斜杠和反斜杠的奇怪行为

python - 将编译代码 (distutils) 从 Windows 7 移植到 Windows Server

c# - 使用 Microsoft.Identity.Client 向 Microsoft Graph 进行身份验证

c# - 如何防止 ToString ("0,0") 返回 00

c# - 发送或监听时出错,Azure ServiceBus

python - 将文件夹从服务器(Linux)复制到python中的本地机器(windows)