问题
I want to serve a mp4 video in a HTML document but it doesn't play on the live server. Locally it works.
Even using only the file without any HTML it does play when I use my local Apache. On the webserver the iPad says "Movie could not be played"
The header for the file is "video/mp4" on both Servers.
What could be the problem here?
Regards
UPDATE:
Header local Apache:
Accept-Ranges bytes Cache-Control max-age=86400 Connection Keep-Alive Content-Length 8993646 Content-Type video/mp4 Date Thu, 23 Feb 2012 14:40:58 GMT Etag "733258-893b6e-36d96c80" Keep-Alive timeout=15, max=100 Last-Modified Thu, 23 Feb 2012 10:36:18 GMT
Header live server:
Cache-Control max-age=86400 Connection Keep-Alive Content-Length 8993670 Content-Type video/mp4 Date Thu, 23 Feb 2012 14:40:40 GMT Keep-Alive timeout=15, max=100 Server Apache X-Mod-H264-Streaming version=2.0
What's also weird is that the Content-Length differs from local to live...
回答1:
Check what the live server is sending out for a mime header v.s. what your local one is. The live server may be sending application/octet-stream
(or some other default type) instead of video/mp4
. Browsers go by the supplied mime-type in the response headers for the most part, not the served up file extension.
回答2:
Solution is a wrong Conten-Length
header from the live-server. After fixing this problem it worked.
Collegue fixed server settings, so I don't know excactly what he did. Just that the lenght is now the same as on my local machine
回答3:
If you are using the HTML5 along with a mp4 file. There should be no problems playing the file on your iPad.. the only thing left is to make sure the link is not broken and add this part to make further testing :
<video width="320" height="240" controls="controls">
<source src="movie.mp4" type="video/mp4" />
Your browser does not support the video tag. //add this line
</video>
回答4:
The web server serving the media files should also support 'Accept-Ranges' header. This is mentioned in another stackoverflow question which has a link to apple documentation.
来源:https://stackoverflow.com/questions/9415050/serving-mp4-video-to-ipad