Tuesday, April 12, 2016

Calculate .m4s segment file suffix in HTML5 video streaming when user seek to another time

Leave a Comment

I have created segments of 10 Sec for a long mp4 video using Mp4Box. The Mp4Box creates a meta info file mv_init.mp4 and and segments like mv_1.m4s, mv_2.m4s... Now i stream it using HTML5 Media Source Extension. The streaming is working properly.

But the problem is that I am unable to utilize TIME SEEKING feature of HTML5 player. When a user seek through the seekbar and switch to another time then I need to fetch the correct segment file (mv_{number}.m4s) for that currentTime. Currently I calculate the segment file suffix using the following technique:

Example:-

Video Duration: 2 Hour

Segment Size: 10 Sec

Let say the user seeked to time 25 Min, so in this case I load the following segment file:

25 Min = 25 *60 = 1500 Seconds As each segment is of 10 Sec So I divide 1500 by 10 = 1500 / 10 = 150

Segment File = mv_150.m4s

The calculation apparently seems correct but the HTML5 player then downloads many more files after mv_150.m4s to continue with the streaming.

Can anyone guide me in this case of how to correctly calculate segment file number so that after seeking the streaming run smoothly without downloading any extra files.

I used the following command to created Segments of Mp4 video:

MP4Box -dash 10000 -out video.mpd -dash-profile live -segment-name mv_ -rap video.mp4

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment