使用mp4box.js从大块ISOBMFF段中解析框

时间:2019-06-14 00:12:50

标签: node.js mp4box

我正在尝试读取分块的HTTP响应,并逐块附加到mp4box文件。然后,我想解析完整的文件以获取所有的moof + mdat框。由于某种原因,尽管响应主体有16个框(8组moof + mdat),但我在mp4box ISOFile中只看到2个框。

我正在从http界面监听数据事件。然后,我尝试按照mp4box.js自述文件中所述将arrayBuffer传递给ISOFile MSE Buffer。由于某种原因,我应该只看到两个框,而应该看到16。

const request = require('request');
var MP4Box = require('../../dist/mp4box.all.js');
const now = Math.trunc((new Date() / 8000));
console.log(now);
const m4s = MP4Box.createFile();

request(`https://livesim.dashif.org/livesim-chunked/chunkdur_1/ato_7/testpic4_8s/A48/${now}.m4s`,{encoding:null})//this response is chunked from the server
.on('response',function(response){
    console.log(response.statusCode);
    console.log(response.headers['content-type']);
    response.on('data',function(chunk){
        let ab = chunk.buffer;
        ab.fileStart = 0;
        console.log('got chunk: ' + ab.byteLength + ' bytes');//8 chunks of ~5,000 bytes which are moof+mdat pairs of audio
        m4s.appendBuffer(ab);
    });
    response.on('end',function(){
        console.log('body complete');
        console.log('found ' + m4s.boxes.length + ' boxes'); //result: 2 when it should be 16
    });
});```

I'm expecting to see 8 chunks (which are pairs of moof+mdat boxes) in the m4s object?

0 个答案:

没有答案