gpac / mp4box.js

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

MP4 fragmentation without splitting audio / video #75

Closed chrisprobst closed 8 years ago

chrisprobst commented 8 years ago

Hi,

I use this library for MSE MP4 fragmentation. Unfortunately, the "documentation way" of segmenting a MP4 splits audio and video stream buffers.

Therefore, I have to use 2!! MediaSource SourceBuffers, which, of course, never stay synchronized.

(Because I have multiple mp4 files, which I want to play one after the other. However, the audio track might be shorter than the video track, so just appending means accumulating out-of-sync problems.)

Is it possible, to fragment a complete MP4 file without splitting it ?

(I want to use 1!! SourceBuffer for both, audio and video)

cconcolato commented 8 years ago

Yes it would be possible to create multiplexed segments. It's not yet coded though and would require some work. It's strange that the 2 SourceBuffers don't stay synchronized. What browser are you using? Do you have an example? Have you filed a bug to the browser doing that?

chrisprobst commented 8 years ago

I totally forgot this issue.

The reason for out-of-sync was my own foolishness. I'm using video chunks of 5 seconds and I used to create them using the segment option of ffmpeg.

BUT: ffmpeg does not make (or maybe cannot) both the video and audio track equally long. Long story short: a 5 sec. chunk of video might only have 4.998 seconds of audio.

This difference accumulated into something noticeable =[.

I ended up implementing a simple atom parser myself, therefore I do not need the ffmpeg segmenting in the first place, because i can simply collect ftyp+moov and moof+mdat atoms and merge them together as I like. (Maybe I could have used mp4box.js for this as well, but I had no clue about atom and thus it was a nice learning project)

Anyways, thanks for answering on this issue ;)

Cheers

[I consider this closed, but maybe others do have similar issues...]