I have created fixed length segments for a long MP4 video using Mp4Box. Mp4Box creates a meta info file mv_init.mp4
and segments like mv_1.m4s
, mv_2.m4s
, … I stream the video using HTML5 Media Source Extensions and the streaming is working properly.
The problem is that I am unable to utilize time seeking feature of my HTML5 player. When a user uses the seekbar to seek to another time point, I need to fetch the correct segment file (mv_{number}.m4s
) for that currentTime
.
For example:
- video duration: 2 hours
- segment size: 10 seconds
- user seeks to time: 25 minutes
25 minutes = 25 × 60 seconds = 1500 seconds. As each segment is of 10 seconds, I need segment number 1500 / 10 = 150. The needed segment file is mv_150.m4s
.
The calculation apparently seems correct, but the HTML5 player then downloads many more files after mv_150.m4s
before it continues with the streaming.
How to correctly calculate segment file number, so that after seeking, the streaming runs smoothly, without downloading any extra files?
To create the segments of the MP4 video, I used the following command:
MP4Box -dash 10000 -out video.mpd -dash-profile live -segment-name mv_ -rap video.mp4