- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在玩 MediaSource API。代码直接取自 Mozilla 的示例页面:https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/endOfStream
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<video controls></video>
<script>
var video = document.querySelector('video');
var assetURL = 'frag_bunny.mp4';
// Need to be specific for Blink regarding codecs
// ./mp4info frag_bunny.mp4 | grep Codec
var mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
var mediaSource = new MediaSource;
//console.log(mediaSource.readyState); // closed
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen);
} else {
console.error('Unsupported MIME type or codec: ', mimeCodec);
}
function sourceOpen (_) {
//console.log(this.readyState); // open
var mediaSource = this;
var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
fetchAB(assetURL, function (buf) {
sourceBuffer.addEventListener('updateend', function (_) {
mediaSource.endOfStream();
video.play();
//console.log(mediaSource.readyState); // ended
});
sourceBuffer.appendBuffer(buf);
});
};
function fetchAB (url, cb) {
console.log(url);
var xhr = new XMLHttpRequest;
xhr.open('get', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
cb(xhr.response);
};
xhr.send();
};
</script>
</body>
</html>
mediaSource.endOfStream();
崩溃因为
Uncaught DOMException: Failed to execute 'endOfStream' on 'MediaSource': The MediaSource's readyState is not 'open'.
at SourceBuffer.<anonymous>
File:
major brand: mp42
minor version: 1
compatible brand: mp42
compatible brand: avc1
compatible brand: iso5
Movie:
duration: 60095 ms
time scale: 1000
fragments: yes
Found 4 Tracks
Track 1:
flags: 7 ENABLED IN-MOVIE IN-PREVIEW
id: 1
type: Audio
duration: 60095 ms
language: eng
media:
sample count: 0
timescale: 22050
duration: 0 (media timescale units)
duration: 0 (ms)
bitrate (computed): 65.075 Kbps
Sample Description 0
Coding: mp4a (MPEG-4 Audio)
Stream Type: Audio
Object Type: MPEG-4 Audio
Max Bitrate: 0
Avg Bitrate: 64000
Buffer Size: 6144
Codecs String: mp4a.40.2
MPEG-4 Audio Object Type: 2 (AAC Low Complexity)
MPEG-4 Audio Decoder Config:
Sampling Frequency: 22050
Channels: 2
Sample Rate: 22050
Sample Size: 16
Channels: 2
Track 2:
flags: 7 ENABLED IN-MOVIE IN-PREVIEW
id: 2
type: Video
duration: 60095 ms
language: eng
media:
sample count: 0
timescale: 600
duration: 0 (media timescale units)
duration: 0 (ms)
bitrate (computed): 612.178 Kbps
display width: 640.000000
display height: 360.000000
Sample Description 0
Coding: avc1 (H.264)
Width: 640
Height: 360
Depth: 24
AVC Profile: 66 (Baseline)
AVC Profile Compat: e0
AVC Level: 30
AVC NALU Length Size: 4
AVC SPS: [2742e01ea9181405ff2e00d418041adb0ad7bdf010]
AVC PPS: [28de09c8]
Codecs String: avc1.42E01E
Track 3:
flags: 7 ENABLED IN-MOVIE IN-PREVIEW
id: 3
type: Hint
duration: 60095 ms
language: eng
media:
sample count: 0
timescale: 90000
duration: 0 (media timescale units)
duration: 0 (ms)
bitrate (computed): 45.859 Kbps
Sample Description 0
Coding: rtp (RTP Hints)
Track 4:
flags: 7 ENABLED IN-MOVIE IN-PREVIEW
id: 4
type: Hint
duration: 60095 ms
language: eng
media:
sample count: 0
timescale: 22050
duration: 0 (media timescale units)
duration: 0 (ms)
bitrate (computed): 5.510 Kbps
Sample Description 0
Coding: rtp (RTP Hints)
File:
major brand: mp42
minor version: 0
compatible brand: mp42
compatible brand: isom
compatible brand: avc1
Movie:
duration: 5568 ms
time scale: 90000
fragments: no
Found 2 Tracks
Track 1:
flags: 1 ENABLED
id: 1
type: Video
duration: 5533 ms
language: und
media:
sample count: 166
timescale: 90000
duration: 498000 (media timescale units)
duration: 5533 (ms)
bitrate (computed): 465.670 Kbps
display width: 560.000000
display height: 320.000000
frame rate (computed): 30.000
Sample Description 0
Coding: avc1 (H.264)
Width: 560
Height: 320
Depth: 24
AVC Profile: 66 (Baseline)
AVC Profile Compat: c0
AVC Level: 30
AVC NALU Length Size: 4
AVC SPS: [6742c01e9e218118534d40404050000003001000000303c8f162ee]
AVC PPS: [68ce06cb20]
Codecs String: avc1.42C01E
Track 2:
flags: 3 ENABLED IN-MOVIE
id: 2
type: Audio
duration: 5568 ms
language: eng
media:
sample count: 261
timescale: 48000
duration: 267264 (media timescale units)
duration: 5568 (ms)
bitrate (computed): 83.050 Kbps
Sample Description 0
Coding: mp4a (MPEG-4 Audio)
Stream Type: Audio
Object Type: MPEG-4 Audio
Max Bitrate: 91632
Avg Bitrate: 83051
Buffer Size: 280
Codecs String: mp4a.40.2
MPEG-4 Audio Object Type: 2 (AAC Low Complexity)
MPEG-4 Audio Decoder Config:
Sampling Frequency: 48000
Channels: 1
Sample Rate: 48000
Sample Size: 16
Channels: 1
最佳答案
如果 mp4 碎片化,t 工作正常。你可以使用bento4的来做到这一点。 mp4fragment 您可以在此处找到的工具:
https://www.bento4.com/documentation/mp4fragment/
关于HTML5 MediaSource 适用于某些 mp4 文件而不适用于其他文件(相同的编解码器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42234078/
所以我正在尝试构建一个直播应用程序,但遇到了一个奇怪的问题。 所以我使用 getUserMedia 来捕获用户的视频,然后将该用户标记为广播者。然后我使用 MediaRecorder 从 MediaS
我想测试我用Python编写的一些FFT分析代码是否与Javascript MediaSource FFT节点完全相同。 (参见此处的示例 Web Audio API Analyser Node No
我认为这可能与Changing with HTML5 Audio works in Chrome but not Safari有关 我遇到的问题是,将 MediaSource 附加到后台选项卡中的
我可以通过使用 GET 请求和 Range header 请求数据 block 来播放 mp4 视频。 var FILE = 'Momokuri_Ep_09-10_SUB_ITA_dashinit.m
使用 QT 4.6,我试图访问我的 QResource 文件中的 wav 文件以用作媒体播放器的媒体源,但它不起作用: Phonon::MediaObject *music; music=Phono
我正在尝试在 HTML5/JS 中实现可靠、无缝的视频播放列表。为此,我想在内存中缓冲一个动态播放列表,然后将缓冲区发送到 HTML5 视频元素。 我可以选择视频的编码方式,这只能在 Chrome 浏
我正在尝试使用 MediaSource 播放两个单独的流(音频和视频)。我已经成功地按任意大小的顺序附加了它们的缓冲区(通过 XHR 检索的 ArrayBuffer 类型): 大小相同的 XXX 字节
我有一个服务器应用程序,它呈现一个 30 FPS 的视频流,然后将其实时编码和多路复用到一个 WebM Byte Stream 中。 . 在客户端,HTML5 页面向服务器打开一个 WebSocket
想知道是否有人知道 Chrome 移动设备是否/何时会实现 MediaSource Extension (MSE)?我的 iphone 5 上安装了 30.0 版本,但未能通过演示测试 ( http:
我尝试使用 MediaSource 播放两个视频,但只有一个有效。两者都将编解码器设置为 avc1.4d401f 和 mp4a.40.2,但其中一个播放得很好,另一个在我调用 SourceBuffer
所以我有一个正在下载的 .mp4 文件。我想使用 MediaSource API 将下载文件流式传输到视频元素中。我该怎么做? const NUM_CHUNKS = 5; var video = do
所以我有一个使用 Google 的 Shaka player 的网络应用程序用于视频播放。它使用 MediaSource用于流式传输音频和视频片段的 API。 我想对音轨的原始 PCM 数据进行一些音
我坚持在 Exoplayer 中播放并行的不同媒体流 场景: 我有一个音频媒体源。和一个视频媒体源。 我想在 ExoPlayer 中同时播放这两个媒体源 经过大量的研发我发现 > https://gi
我对 mediastream 和 mediasource api 的经验有限,您认为从 getusermedia 获取数据然后将该数据附加到 mediasource 的最佳方法是什么。现在我正在使用
就 HTML5 而言,我是新手。我正在查看 this link 上给出的 MediaSource API 文档 我访问了 this link 上给出的演示链接 但是它不起作用(在chrome下)。当我
MediaSource.isTypeSupported('audio/ogg; codecs="vorbis"') 返回 false - 这是否意味着我无法将 ogg 作为 POST 的响应进行流式传
假设我有一个页面允许用户选择宽度、高度、颜色和持续时间。我希望该页面随后生成具有这些尺寸和持续时间的视频,该视频只是该颜色的静态帧,然后将在该页面的 标记中播放。我可以使用 HTML5 MediaSo
更新: 所以我能够通过使用 offsetTimestamp 属性(在附加每个视频后增加它)来让它工作。 我现在的问题:1) 为什么在将 MediaSource.mode 设置为序列时没有正确完成? 2
我正在使用 HTML5 VideoSource 扩展,我需要知道 'updateend' 上如何报告时间事件。当我将事件记录到 Chrome 控制台时,我得到以下数据: 如屏幕截图所示,有一个时间戳值
我在玩 MediaSource API。代码直接取自 Mozilla 的示例页面:https://developer.mozilla.org/en-US/docs/Web/API/MediaSourc
我是一名优秀的程序员,十分优秀!