Open RobbieFernandez opened 1 year ago
How can i calculate bytes of data required for demuxing next n
frames of mp4 file?
@RobbieFernandez - I had wondered about that as well. In my case I was using segments rather than samples and onSegment was not firing after the file was downloading and seeking back in the file. What worked for me with segments was to make sure that mp4box was discarding it's buffers. Only then would seeking backwards cause onSegment events to fire. It might be the same for samples as well. So the process is:
mp4File = MP4Box.createFile(false);
filePosition = mp4File.seek(from, true).offset;
Hi, I'm using this library to stream mp4 files remotely and it's been working really well so far. I just have 1 question about the way in which
.seek
is intended to be used. I'm using mp4box for generating samples and then using the webcodecs VideoDecoder API to decode and present the samples.The main reason I'm using this library instead of an existing out-of-the-box player is because I need the ability to jump to specific frames with 100% accuracy. This is working quite well while the file is being fetched in the background, using .seek() to jump to the nearest RAP and then discarding frames until I reach the target. However once the file has been fully downloaded, calling .seek() will no longer trigger the
.onSamples
callback. Looking through the code for this library it looks to me like what happens is.seek
updates thenextSample
attribute but doesn't actually initiate any sample processing. The reason I'm getting the samples while the file is being fetched is because I'm calling.appendBuffer
which does eventually trigger sample processing. So my workaround for this is to just call.seek
and iff the file has already been fully fetched then also explicitly callprocessSamples(false)
I'm wondering if this is working as intended, or if I'm misunderstanding the way in which
.seek
should be called?