简体   繁体   English

在Web浏览器中播放用ffmpeg录制的mkv视频的最佳方法

[英]Best way of playing mkv video that is being recorded with ffmpeg in web browser

I'm looking for a way to play a video that is being recorded with ffmpeg in a web browser preferably using HTML5 video tag. 我正在寻找一种播放视频的方法,最好是使用HTML5视频标签在网络浏览器中播放ffmpeg记录的视频。

I have this code in my page, the URL is pointing to a video file (example.mkv) that is being recorded by ffmpeg. 我的页面中有这段代码,URL指向由ffmpeg录制的视频文件(example.mkv)。

<video class="video-player" controls loop>          
            <source src="{{asset('example.mkv')}}" type="video/mp4">
            <p>Your browser does not support H.264/MP4.</p>
</video>

Google Chrome/Chromium can play mkv video in HTML5, but only plays the part that was loaded when page was loaded. Google Chrome / Chromium可以HTML5格式播放mkv视频,但仅播放页面加载时加载的部分。 Is it possible to continue to load the video while it is being recorded? 可以在录制视频时继续加载视频吗?

First off, drop the type="video/mp4" ... that's not accurate for your MKV. 首先,删除type="video/mp4" ...对于您的MKV不正确。 Next, consider using WebM, which is the same Matroska container but with a subset of features... you will maximize browser compatibility this way. 接下来,考虑使用WebM,它是相同的Matroska容器,但具有部分功能...您将通过这种方式最大程度地提高浏览器的兼容性。

Now, to do what you want, you simply need to send the data to the browser as it is encoded. 现在,要做您想做的事情,只需要将数据编码后发送到浏览器即可。 This means building a server and piping the FFmpeg out directly to the client. 这意味着构建服务器并将FFmpeg直接传送到客户端。 No file on disk. 磁盘上没有文件。 Chrome can then stream it just fine. 然后,Chrome可以对其进行流式传输。

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

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