html5-video - Browser MIME type for playing H.264 video file
问题描述
I have a file produced from an encoding process that is in H.264 Annex B format, not wrapped in any container like MP4. I'm trying to figure out how to make this file playable in browser using <video>
element. No matter what MIME type I try, it fails.
I know the file is good and browser has necessary facilities to decode it, because a) same exact content was previously streamed for WebRTC session that browser was able to decode and play, and b) the saved file is trivially playable with ffplay myfile.h264
.
The HTML attempted for playing that file used the following <source>
elements (ignore non-HTML formating pieces as those are cut from source-code directly):
<source src={this.props.src} type={'video/avc'} />
<source src={this.props.src} type={'video/H264-SVC'} />
<source src={this.props.src} type={'video/H264'} />
<!-- Ones below are more of a desperation attempts :) -->
<source src={this.props.src} type={'video/mp4'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.66.13, mp4a.40.2"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.42e01e, mp4a.40.2"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.42e01e, mp4a.40.2"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.66.30, mp4a.40.5"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.42001e, mp4a.40.5"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.42001f, mp4a.40.5"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.77.30, mp4a.40.5"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.4d001e, mp4a.40.5'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.4d001f, mp4a.40.5"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.640029, mp4a.40.5'} />
<source src={this.props.src} type={'video/mp4; codecs="mp4a.40.2"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.4d002a"'} />
<source src={this.props.src} type={'video/mp4; codecs="avc1.4d001e, mp4a.40.2"'} />
<source src={this.props.src} type={'application/x-mpegurl'} />
<source src={this.props.src} type={'application/vnd.apple.mpegurl'} />
None work.
Since browser can play it via WebRTC channel, and since it's trivially playable using ffplay
(that is, format is self-describing and contains all necessary info for playback), I'd expect <video>
to be able to play it.
Also small note, Android references AVC (aka h264) codec as video/avc
, so that's where I pulled that one from, but that still fails.
What's the proper MIME type for playing straight up H.264 AVC content?
解决方案
推荐阅读
- php - product.tpl 中的图像仅在某些类别中
- windows - 使用批处理脚本回显从第 3 列开始的所有列
- bash - 我想使用代码。WSL 中的命令以远程打开 vs-code-insiders
- javascript - 带有 HTML5 验证和 JS 的 Rails
- swift - 格式化字符串后我需要帮助删除下划线
- reactjs - 从 curl 获取数据,但与 axios 相同,给出一个空对象
- firebase - Firebase firestore,auth,storage 版本错误
- mysql - 获取表中的所有行以及最小值和最大值
- apache-camel - 等待命名空间处理程序
- c# - 解析器错误消息:无法加载类型“PresentationLogic.Global”