Safari 9.0 无法在存储服务器上播放 mp4 视频 [英] Safari 9.0 can not play mp4 video on the storage server

查看:23
本文介绍了Safari 9.0 无法在存储服务器上播放 mp4 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下视频链接无法使用safari 9.0(最新版本)播放.但是旧版本的 safari、chrome 和 firefox 可以玩.

虽然下面的这个例子显示了一个在 Safari 中无法播放但在 Chrome 中可以播放的视频 - 可以看出服务器只是响应了一个 200 请求:

您可以使用 CURL 命令测试服务器是否正确接受范围请求 - 请在此处查看来自 Apple 的信息:

<块引用>

如果您不确定您的媒体服务器是否支持字节范围请求,您可以在 OS X 中打开终端应用程序并使用 curl 命令行工具从服务器上的文件下载一个短片段:

curl --range 0-99

在上面的示例中使用相同的 CURL 命令,该命令在 Safari 中不播放(但在 Chrome 中播放)表明服务器正在响应完整文件,而不仅仅是请求的范围:

此 CURL 测试可能是检查您的服务器是否正确尝试处理请求的最快方法.

原答案

这似乎是 Safari 上某些 mp4 文件反复出现的问题.

我在 localhost node.js 静态服务器上测试了您的视频,它在 Safari 中播放良好,这意味着视频本身应该没问题.

如果您查看 Safari 中的 Web 检查器,您将看到 Web 请求不包含某些标头.这会导致一些服务器出现问题,并且它们不会以 Safari 期望的方式响应,或者根本不响应.

您可以看到正在讨论的类似问题(我认为第二个不是您的情况,但说明发送到服务器的请求中包含的信息可能导致服务器决定"不按照您的意愿进行响应):

更新 1:

使用wireshark捕获来自Chrome的请求,可以看到导致来自服务器的响应以及要播放的视频,而来自Safari(在同一台机器上)的请求导致服务器没有响应.

请求通常相似,并且都包含引用标头.Safari 浏览器最初只要求从服务器返回前 2 个字节 - 它通过使用范围"标头来实现,该标头用于指定文件返回的字节范围:

  • 范围:字节=0-1

另一方面,Chrome 请求其范围请求中的整个视频:

  • 范围:字节=0-

但是,在 Chrome 上使用 HTTP 工具(例如 Postman)并将范围更改为 0-1 似乎并没有阻止服务器在 Chrome 情况下响应.实际上使用该工具设置,尽可能与 Safari 设置的标题相同,似乎仍然可以返回视频.

The following video link cannot be played with safari 9.0 (latest version). But older versions of safari, chrome and firefox can play.

http://assets00.grou.ps/0F2E3C/wysiwyg_files/Videos/saksuka/20150928104628-lhmkkfbhnkiisbhht.mp4

I can play with safari 9.0 when i download the video from the server to my computer.

That's why I don't think this problem stems video encoding.

I have done these settings;

mime.types
video/mp4   mp4 m4v
video/ogg   ogv
video/webm  webm

httpd.conf
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm

.htaccess
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm

解决方案

Update 2 - June 2020

The most common root cause of this issue appears to be servers that are not configured to handle range requests properly.

Safari expects to see a '206' response when it sends a request with a byte range. If the server responds with a '200' request it appears Safari cannot handle this. Some other browsers seem to be ok with this - for example Chrome.

The inspection network tab screenshot below shows a successful video playback with range requests and a 206 'Partial Content' response:

While this example below shows a video which fails to play in Safari but does play in Chrome - and it can be seen that the server is simply responding with a 200 request:

You can test if the server is properly accepting range requests using a CURL command - see info from apple here:

If you are not sure whether your media server supports byte-range requests, you can open the Terminal application in OS X and use the curl command-line tool to download a short segment from a file on the server:

curl --range 0-99 http://example.com/test.mov -o /dev/null

If the tool reports that it downloaded 100 bytes, the media server correctly handled the byte-range request. If it downloads the entire file, you may need to update the media server. For more information on curl, see OS X Man Pages.

(from: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html#//apple_ref/doc/uid/TP40006514-SW6)

Using the CURL command in the above reference for the first video which plays correctly, we can see the response is that just the range requested is returned as expected:

Using the same CURL command with the example above which does not play in Safari (but does in Chrome) shows that the server is responding with the full file, instead of just with the range requested:

This CURL test is probably the quickest way to check whether your server is correctly try handling the request.

Original Answer

This seems to be recurring problem with some mp4 files on Safari.

I tested your video on a localhost node.js static server and it played fine in Safari, which means the video itself should be fine.

If you look at the web inspector in Safari you will see that the web request is not including some headers. This causes some servers problems and they do not respond the way Safari is expecting, or do not respond at all.

You can see similar problems being discussed (the second one is not your case I think but illustrates that the info included in the request sent to the server can cause the server to 'decide' not to respond as you want):

Update 1:

Using wireshark to capture the request from Chrome, it can be seen to result in a response from the server with the video to be played while the request from Safari (on the same machine) results in no response from the server.

The requests are generally similar and both do include the referrer header. The Safari browser is only asking for the first 2 bytes to be returned from the server initially - it does this by using the 'range' header, which is used to specify the bytes range that a file returns:

  • Range: bytes=0-1

Chrome on the other hand requests the entire video in its range request:

  • Range: bytes=0-

However, using a HTTP tool (e.g. Postman) on Chrome and changing the range to 0-1 does not seem to stop the server responding in the Chrome case. In fact using the tool to set, as far as possible, all the same headers as Safari sets seems still seems to return the video ok.

这篇关于Safari 9.0 无法在存储服务器上播放 mp4 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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