http://www.youtube.com/html5 indicates that Google Chrome is compliant with MediaSource Extensions & H.264.
I make a simple test checking that my video is supported by Chromium, using the <video id='player' autoplay='true'> <source src='/test.mp4' type='video/mp4' /> </video>
The video plays smoothly.
A second alternative that also works fine consists in loading through AJAX the byte chain and converting the buffer to a URI object. Then asigning such URI to the (video) source.src attribute.
Finally I try to load the same video through AJAX and inject it into a MediaSource Buffer. It fails with the error 4. (Source Not supported).
The code used is similar to:
var mediaSource = new (window.MediaSource || window.WebKitMediaSource)();
window.video = document.getElementById('video1');
window.video.addEventListener("error", function onError(err) {
alert("window.video error detected:");
console.dir(window.video.error); window.worker.terminate();
});
window.video.pause();
window.video.src = URL.createObjectURL(mediaSource);
var onMediaSourceOpen = function (e) {
mediaSource.removeEventListener('sourceopen', onMediaSourceOpen);
window.videoSource = mediaSource.addSourceBuffer('video/mp4;codecs="avc1.4d001e,mp4a.40.2"');
injectVideoIntoBuffer();
}
mediaSource.addEventListener('sourceopen', onMediaSourceOpen);
var injectVideoIntoBuffer = function onResponse() {
var xhr = new XMLHttpRequest();
xhr.open('GET', "test.mp4");
xhr.responseType = 'arraybuffer';
xhr.addEventListener("readystatechange", function () {
// Next line raises a MediaError, code: 4, (MEDIA_ERR_SRC_NOT_SUPPORTED)
videoSource.appendBuffer(new Uint8Array(xhr.response));
...
}, false);
xhr.send();
}
I tried different mp4 files, generated either with ffmpeg/avconv or MP4Box. Not luck at this moment. A similar code works fine with VP8/WebM test files.
Thanks in advance for any help/hint or link!
Enrique