简体   繁体   English

如何在HTML5中流式传输实时视频?

[英]How to stream live video in HTML5?

I'm looking for a way to broadcast a live video taken from a webcam or camera rooted to a PC. 我正在寻找一种方法来播放从网络摄像头拍摄的实时视频或根植于PC的摄像头。 The broadcast should be displayed in a HTML5 page using the tag (which support rtp, and rtsp I think). 广播应该使用标签显示在HTML5页面中(我认为支持rtp和rtsp)。

The user viewing the stream should not have to install any plug-in or video player such as QuickTime. 查看流的用户不必安装任何插件或视频播放器,如QuickTime。

I need the video to be in mp4 format such as: rtsp://www.mywebsite/streaming/video.mp4 我需要视频为mp4格式,例如:rtsp://www.mywebsite/streaming/video.mp4

This would be the link I'd put as the src of the html 5 video tag. 这将是我作为html 5视频标签的src放置的链接。

So I'd like to know if it's possible, what are my options to do such things. 所以我想知道是否可能,我有什么选择做这些事情。

It's possible. 这是可能的。 But you will have major problems if you're looking for cross browser support. 但是如果您正在寻找跨浏览器支持,那么您将遇到重大问题。 What you can do is offer HTML5 video to the browsers supporting it and then offer QuickTime for browsers not supporting it. 您可以做的是向支持它的浏览器提供HTML5视频,然后为不支持它的浏览器提供QuickTime。

<video src="stream.mp4">

    <!-- Don't support <video> -->
    <object>
        <param name="src" value="video.mp4" />
        
    <param name="autoplay" value="true" />
        
    <param name="type" value="video/quicktime" height="256" width="320" />
        
    
    <embed src="video.mp4" height="256" width="320" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" />
    </object>

</video>

Also see: Streaming via RTSP or RTP in HTML5 另请参阅: HTML5中通过RTSP或RTP流式传输

I don't think it is possible now to "cheat" the HTML5 browser to encapsulate the live video stream to a ".mp4" file. 我认为现在不可能“欺骗”HTML5浏览器将实时视频流封装到“.mp4”文件中。 I believe HTML5 will consider live video support in a near future. 我相信HTML5会在不久的将来考虑实时视频支持。 What you can do is just wait. 你能做的就是等待。 :) :)

For maximum compatibility, here's what our video workflow will look like, Make one version that uses H.264 baseline video and AAC “low complexity” audio in an MP4 container & Make another version that uses WebM (VP8 + Vorbis) or Theora video and Vorbis audio in an Ogg container. 为了获得最大的兼容性,这就是我们的视频工作流程的样子,在MP4容器中制作一个使用H.264基线视频和AAC“低复杂度”音频的版本,制作另一个使用WebM(VP8 + Vorbis)或Theora视频的版本Ogg容器中的Vorbis音频。 I think this combination solves your problem & it plays on most of browsers. 我认为这个组合可以解决您的问题并在大多数浏览器上播放。 You should required at least two versions of Video to play in all the browsers. 您应该要求在所有浏览器中至少播放两个版本的视频。

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

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