简体   繁体   English

Azure 媒体服务直接从网络摄像头上传文件

[英]Azure Media Service upload file directly from webcam

I have looked at the documentation for Azure Media Services, but I could not find any docs or samples that talk about uploading a video from a browser using the webcam.我查看了 Azure 媒体服务的文档,但我找不到任何有关使用网络摄像头从浏览器上传视频的文档或示例。

I am already using MediaRecorder api in the browser to record the webcam video and then upload... but I was wondering if there was a better alternative than 'MediaRecorder'?我已经在浏览器中使用MediaRecorder api 来录制网络摄像头视频然后上传......但我想知道是否有比“MediaRecorder”更好的选择?

Since Microsoft already provides a media player to play the videos, I was wondering if in a similar way, Microsoft maybe had a js library to do the video recording on the frontend and upload accordingly?由于微软已经提供了一个媒体播放器来播放视频,我想知道是否以类似的方式,微软可能有一个 js 库来在前端进行视频录制并相应地上传?

It's tricky, because Media Services only supports RTMP ingest.这很棘手,因为媒体服务只支持 RTMP 摄取。

Media Recorder API just records to "slices" of webM or MP4 content in the browser.媒体记录器 API 仅记录浏览器中 webM 或 MP4 内容的“切片”。 You have to then push those chunks of media someplace that is capable of sending that content into AMS as RTMP/S.然后,您必须将这些媒体块推送到能够将该内容作为 RTMP/S 发送到 AMS 的地方。 Otherwise, no go.否则,没有 go。

There is a good example project from Mux up here called Wocket that demonstrates how you could go about building a solution that ingests content from the MediaRecorder API and send it to any RTMP server, but it has to go over a WebSocket connection to a middle tier Docker container that is running FFMPEG. There is a good example project from Mux up here called Wocket that demonstrates how you could go about building a solution that ingests content from the MediaRecorder API and send it to any RTMP server, but it has to go over a WebSocket connection to a middle tier Docker 容器正在运行 FFMPEG。 The FFMPEG process receives the webM or MP4 chunks from the Media Recorder and forwards that onto Media Services. FFMPEG 进程从媒体记录器接收 webM 或 MP4 块并将其转发到媒体服务。

https://github.com/MuxLabs/wocket https://github.com/MuxLabs/wocket

I built a demo recently that uses this in Azure, and it surprisingly works... but not really production ready solution - has lots of issues on iOS for example.我最近构建了一个演示,它在 Azure 中使用它,它出奇地有效......但不是真正的生产就绪解决方案 - 例如在 iOS 上有很多问题。 Also, I had to move the Canvas drawing off the requestAnimationFrame timer and use worker-timers (node.js npm packager) to move the canvas drawing to a web worker. Also, I had to move the Canvas drawing off the requestAnimationFrame timer and use worker-timers (node.js npm packager) to move the canvas drawing to a web worker. That way I could at least switch focus from different browser tabs or hide the browser without it stopping the webcam.这样我至少可以在不停止网络摄像头的情况下从不同的浏览器选项卡切换焦点或隐藏浏览器。 Normally timers like setInterval or setTimeout in the browser will sleep or be throttled in modern browsers to save power and CPU.通常,浏览器中的 setInterval 或 setTimeout 等计时器会在现代浏览器中休眠或受到限制,以节省电力和 CPU。

Let me know if you want any more details after looking at the Wocket project.如果您在查看 Wocket 项目后需要更多详细信息,请告诉我。

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

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