ffmpeg – Generate MPEG-DASH segments when requested

Up front disclaimer: this question is almost identical to the one here: Generate single MPEG-Dash segment with ffmpeg but it seems that ffmpeg has updated over time and now the answer provided by Coumeu is no longer accurate.

Using ffmpeg, I am attempting to “lazily create” the segments needed for MPEG DASH playback. I have a static manifest (MPD) which includes SegmentTemplates for 1 video and 1 audio stream.

Only when the endpoints provided in the SegmentTemplate for init or media segments is hit it will generate this segment. In other words, nothing is processed up front.

I am creating the init segment using the following movflags:

+frag_keyframe+faststart+skip_trailer 

I am creating the media segment using the following movflags

+frag_keyframe+default_base_moof+delay_moov+skip_trailer+dash+global_sidx

and the following additional commands any segment type:

-map_metadata -1 -copyts -start_at_zero -map 0:${streamIndex}

This results in playable video with the correct duration, but it seems to be switching fragments quite fast. On average one fragment per second. When I omit the delay_moov flag, the video also starts glitching, like it’s stepping over I-Frames.

My observations when I look at the boxes:

  • earliest_presentation_time (sidx box) is 0 for all segments
  • base_media_decode_time (moof->traf->tfdt box) is 0 for all segments

I’m looking for either the correct command line to create segments on the fly, or hacky ways to get it done right if ffmpeg doesn’t provide it out of the box. Even information about what to look for would be helpful, because my knowledge about mp4 and MPEG-DASH is running out.

Read more here: Source link