在html5中查找mp4视频的功能无效 [英] Seeking functionality on mp4 video in html5 is not working

查看:180
本文介绍了在html5中查找mp4视频的功能无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net mvc 5网站,在主页上我需要以mp4格式显示视频。除寻求功能外,一切都很好。我花了几个小时寻找解决方案,但我没有运气。

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.

html元素:

<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!

推荐答案

问题很可能发生在服务器端,而不是客户端。

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.

例如,如果您使用正确的流媒体服务器和自适应比特率流协议(如HLS,平滑流,MPEG DASH等),然后您的客户端将能够轻松地请求视频的特定块并跳转到它(即搜索功能)。

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).

如果你使用HTTP'伪'流媒体(可能更有可能),那么你的客户端应该仍然只能请求视频的某个部分,但要支持你的服务器必须支持'Accept-Ranges'响应标题。

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.

请注意,您的mp4视频也必须设置为在开始时拥有元数据,以便在下载之前支持播放(请参阅: http://multimedia.cx/eggs/improving-qt-faststart/ ),但从您的描述中听起来像你已经有了这个。

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.

这篇关于在html5中查找mp4视频的功能无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆