Closed YordinsonPolar closed 3 years ago
I dont undestarnd, unclear documentation `const getVideo = async () => { const data = await fetch(url, { headers: { range: 'bytes=0-567139' } }); let buff = await data.arrayBuffer(); console.log(buff)
mp4box = MP4Box.createFile();
mp4box.onError = function(e) { console.log("mp4box failed to parse data."); };
mp4box.onMoovStart = function () { console.log("Starting to receive File Information"); };
mp4box.onReady = function(info) { console.log(info.mime); mp4box.onSegment = (id, user, buffer, sampleNum) => { setBuffer(buffer) }
mp4box.setSegmentOptions(info.tracks[0].id, null, { nbSamples: 1000 }); var initSegs = mp4box.initializeSegmentation(); console.log(initSegs) mp4box.start();
};
var nextBufferStart = 0; buff.fileStart = nextBufferStart; nextBufferStart = mp4box.appendBuffer(buff); mp4box.flush();
const mediaSource = new MediaSource(); const mimeCodec = 'video/mp4; codecs="avc1.640029,mp4a.40.2"'; video.src = URL.createObjectURL(mediaSource);
function sourceopen() { console.log('open') const source = mediaSource.addSourceBuffer(mimeCodec); const setBuffer = (buff) => { source.appendBuffer(buff) }; } mediaSource.addEventListener('sourceopen', sourceopen, { once: true });
} `
Can you be more specific as to what you want to be clarified?
I added an example of simple file segmenter. It completely ignores MSE (there is already documentation on the web for MSE). Maybe it will help.
I dont undestarnd, unclear documentation `const getVideo = async () => { const data = await fetch(url, { headers: { range: 'bytes=0-567139' } }); let buff = await data.arrayBuffer(); console.log(buff)
mp4box = MP4Box.createFile();
mp4box.onError = function(e) { console.log("mp4box failed to parse data."); };
mp4box.onMoovStart = function () { console.log("Starting to receive File Information"); };
mp4box.onReady = function(info) { console.log(info.mime); mp4box.onSegment = (id, user, buffer, sampleNum) => { setBuffer(buffer) }
mp4box.setSegmentOptions(info.tracks[0].id, null, { nbSamples: 1000 }); var initSegs = mp4box.initializeSegmentation(); console.log(initSegs) mp4box.start();
};
var nextBufferStart = 0; buff.fileStart = nextBufferStart; nextBufferStart = mp4box.appendBuffer(buff); mp4box.flush();
const mediaSource = new MediaSource(); const mimeCodec = 'video/mp4; codecs="avc1.640029,mp4a.40.2"'; video.src = URL.createObjectURL(mediaSource);
function sourceopen() { console.log('open') const source = mediaSource.addSourceBuffer(mimeCodec); const setBuffer = (buff) => { source.appendBuffer(buff) }; } mediaSource.addEventListener('sourceopen', sourceopen, { once: true });
} `