axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
2.01k stars 482 forks source link

mp4hls preserve timestamps? #268

Open codercurtis opened 6 years ago

codercurtis commented 6 years ago

Is there a way to preserve timestamps when converting from mp4 to hls?

I'm attempting to split an mp4 video into multiple mp4 segments, convert these segments with mp4hls, and then join the stream-levels together.

For example, frame timestamps in mp4 inputs: [0,1,2] [3,4,5] [6,7,8]

frame timestamps in m3u8 outputs: [0,1,2] [0,1,2] [0,1,2]

This causes a problem with most HLS players. It either freezes at the boundary of the first segment, or replaces video frames of an earlier segment with those of a later segment. I assume it's looking at the timestamps of the latest downloaded fragment and queuing them up accordingly, ignoring the order of the fragment in the manifest.

example of inputs and combined output: https://nofile.io/f/kpPMxe19N0O/test.zip

barbibulle commented 6 years ago

I assume that you're converting the segments one by one, as you go, and you can't wait until all the segments are available before converting? What you'd need here is a way to specify a timecode offset for your segment when converting. That's not currently an option that's available, but that would be fairly simple to add. I'll make a note of this feature and see if I can add support for it shortly.

codercurtis commented 6 years ago

I do have all the segments available before converting, actually. Is there something I can do to preserve timestamps, given this?

Thanks for considering this enhancement, either way.

codercurtis commented 6 years ago

@barbibulle This might be something we could help with. Can you point me toward the code where this could be handled?

open-shuaijun commented 1 year ago

I also encountered a similar issue when using MP42ts. After converting one by one, the playback of the synthesized m3u8 file was abnormal