gpac / mp4box.js

JavaScript version of GPAC's MP4Box tool
https://gpac.github.io/mp4box.js/
BSD 3-Clause "New" or "Revised" License
1.88k stars 318 forks source link

How to extract samples from fragmented MP4 file? #360

Open Avijobo opened 9 months ago

Avijobo commented 9 months ago

Hi,

I am using MP4Box.js extraction and the WebCodecs api to decode and display individual MP4 frames. All works well with non-fragmented MP4 files.

However when I pass the uri of a fragmented MP4 file, extract samples, create encodedVideoChunks from the samples and decode them, after about 10 frames I get a decoder error from the WebCodecs VideoDecoder.

Any idea why this happens? Is there a different approach needed to extract samples from a fragmented MP4 file?

Avijobo commented 9 months ago

FYI: It turned out this only happens with fragmented MP4 files created by MediaRecorder in (iOS) Safari. They have a duration of 0, which is probably not expected by the parser.