var index = 1;
var frameLag = 0;
var segments = [];
var ms = new MediaSource();
var sourceBuffer, videoBits, arrayOfBytes, chunk, file, initialization, ini, frameRate;
var container, mesh, camera, scene, renderer, texture;
var video = document.createElement('video');
video.src = window.URL.createObjectURL(ms);
video.muted = true;
ms.addEventListener('sourceopen', onMediaSourceOpen);
container = document.getElementById('container');
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1100);
camera.target = new THREE.Vector3(0, 0, 0);
scene = new THREE.Scene();
texture = new THREE.VideoTexture(video);
texture.minFilter = THREE.LinearFilter;
texture.format = THREE.RGBFormat;
scene.add(camera);
mesh = new THREE.Mesh(
new THREE.PlaneGeometry(1920, 1080),
new THREE.MeshBasicMaterial({
map: texture
}));
mesh.position.set(0, 0, -1000);
scene.add(mesh);
camera.add(mesh);
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
// Safari behavior is different depending on the framerate used. Seems to indicate the issue has something to due with its buffering / stall / gap handling.
//getData('uhd_dash.mpd'); // Baseline 1fps.
//getData('uhd30fps_dash.mpd'); // On Chrome, playback choppier than 1fps. Possibly due to rounding issues with timestamps.
getData('uhd60fps_dash.mpd'); // On Chrome, playback choppier than 1fps. Possibly due to rounding issues with timestamps.
//getData('uhd1000fps_dash.mpd'); // On Chrome, playback appears same as 1fps
function animate() {
// playbackRate is for testing lag / sensitivity.
// For production this should be = 1 and the appended buffer's framerate / timing should be at 60fps.
video.playbackRate = 1;
renderer.animate(render);
}
function render() {
renderer.render(scene, camera);
if (index < segments.length) {
if (sourceBuffer.buffered.length >...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.