mp4box.js icon indicating copy to clipboard operation
mp4box.js copied to clipboard

rapAlignment option has no effect when extracting samples

Open richardmitic opened this issue 10 years ago • 5 comments

mp4box.onSamples() will always receive a list of nbSamples samples, regardless of which ones are RAPs. The script below will reproduce the problem.

window.onload = function() { var mp4box = new MP4Box(); mp4box.onError = function(e) {}; mp4box.onReady = function(info) { videoTrackID = info.videoTracks[0].id; mp4box.setExtractionOptions(videoTrackID, null, {nbSamples:10, rapAlignement:true}); }; mp4box.onSamples = function(id, user, samples) { console.log("Received "+samples.length+" samples on track "+id+" for object "+user); console.log(samples); } var downloader = new Downloader(); downloader.setUrl("https://dl.dropboxusercontent.com/u/7245016/bug_buck_bunny_trailer.mp4") downloader.setCallback(function(response, eof) { mp4box.appendBuffer(response); mp4box.flush(); }); downloader.getFile(); }

richardmitic avatar Jan 13 '15 10:01 richardmitic

Thanks for the report. What would you expect if the file does not contain enough RAP ? or if the RAP are not aligned with the number of samples ? Should RAP=true have precedence over the number of samples requested ?

cconcolato avatar Jan 13 '15 13:01 cconcolato

Yes, I think RAP=true should have precedence. That's how it works in the standard mp4box, so it seems sensible to align it. For example:

wget https://dl.dropboxusercontent.com/u/7245016/bug_buck_bunny_trailer.mp4
mp4box -dash 1 -rap bug_buck_bunny_trailer.mp4

will ignore the segment time and split at the RAPs.

I'm not quite sure what you mean by "not enough RAPs" but it would make sense for any remaining samples to be output when you reach the end of the file, so you could ensure that you can process all samples as long as you call mp4box.flush().

richardmitic avatar Jan 14 '15 10:01 richardmitic

Ok, that's what I thought too. Will implement it when I have time.

cconcolato avatar Jan 21 '15 09:01 cconcolato

+1

IainCole avatar Jul 04 '15 17:07 IainCole

I've been using mp4box.js with great success. But I've run into this issue as well.

I looked into the source for this and it looks like the rapAlignement option isn't checked at all while processing segments.

I was able to figure out a change that will honor that setting. When I went to work on test coverage I found the .mp4 files for testing aren't in the repository so I'm not sure how to move forward.

collin avatar Feb 28 '24 03:02 collin