Seeking functionality on mp4 video in html5 is not working

做~自己de王妃 提交于 2019-12-24 02:39:12

问题


I have an asp.net mvc 5 site and on the home page I need to display a video in mp4 format. Everything works nice except the seeking functionality. I spent several hours looking for a solution but I didn't had any luck.

The html element:

<video id="appVideo" controls style="width: 100%; height: 100%">
        <source src="@Url.Action("HomePageVideo", "Home")"      type="video/mp4" />
    </video>

The controller method for retrieving the video:

    [HttpGet]
    [AllowAnonymous]
    public ActionResult HomePageVideo()
    {
        return File(@"somePath\file.mp4", "video/mp4");
    } 

What am I missing? Thanks in advance!


回答1:


The problem is most likely on the server side, not the client side.

Depending on how you host your video the seek functionality will work slightly differently.

For example if you are using a 'proper' streaming server and an adaptive bit rate streaming protocol (like HLS, Smooth streaming, MPEG DASH etc) then your client will be able to request a particular 'chunk' of the video easily and jump to it (i.e. seek functionality).

If you are using HTTP 'pseudo' streaming (which is probably more likely) then your client should still be able to request just a certain part of the video, but to support this your server has to support 'Accept-Ranges' response header.

This mechanism essentially allows the client request just a portion of the file form the server - it allows a browser save bandwidth by just downloading small chunks of a video before they are to play rather than always downloading the whole video, and it also allows it seek easily by requesting the chunk corresponding to the place the user is seeking to.

Not all servers support this or have it configured out of the box, so this may be where your problem sits.

Note that your mp4 video also has to be set up to have the metadata at the start to support playback before it has downloaded (see: http://multimedia.cx/eggs/improving-qt-faststart/), but from your description it sounds like you already have this.



来源:https://stackoverflow.com/questions/30801594/seeking-functionality-on-mp4-video-in-html5-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!