kevinGodell / mp4frag

Parser that works with ffmpeg to read piped data and fragment mp4 into an initialization segment and media segments. It can also get the codec info and generate an fmp4 HLS m3u8 playlist.
https://kevingodell.github.io/mp4frag/
MIT License
68 stars 15 forks source link

Invalid duration for first segment #16

Closed stuartm closed 2 years ago

stuartm commented 2 years ago

Following the changes to segment duration calculation in 0.4.2 I'm seeing an issue where for some encodings I get an incorrect duration for the first segment, subsequent segment durations are correct.

The initial value tends to be far higher than it should be with values ranging from 58 seconds to 262 seconds seen so far, when the actual duration is ~3 seconds. This breaks playback with some players.

I can provide mp4 samples if required.

kevinGodell commented 2 years ago

Previously, the durations were estimated based on timestamps created in js. Currently, I tried to account for some ways to calculate durations, but there are so many different ways that the data can be packed into an mp4 that I am sure that I missed something. Can you please share some code and ffmpeg parameters and possibly the video source used by ffmpeg to create the live mp4 that is passed into mp4frag? Also, please tell me which video player chokes on the incorrect durations.

kevinGodell commented 2 years ago

please try version 0.5.1, https://www.npmjs.com/package/mp4frag/v/0.5.1