Chrome不会播放.mp4文件 [英] Chrome won't play .mp4 file
问题描述
我正在努力让HTML5视频正常运行。我正在使用本地服务器。
I'm trying to get HTML5 video to work. I am working off a local server.
<video id="headervideo" controls>
<source src="<?php echo base_url(); ?>assets/home.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
但是,该文件拒绝播放。当我使用绝对路径访问它时,它只是显示播放按钮灰色的播放器。
这里可能出现什么问题?
However, the file refuses to play. When I access it with an absolute path it simply shows the player with the play button greyed out. What could be the issue here?
推荐答案
浏览器如Internet Explorer和Safari支持.H264编解码器播放mp4文件。 Firefox支持播放.ogv文件的Theora编解码器。 Chrome支持.H264和Theora。但要使您的视频适用于所有浏览器,您需要使用HandBrake等应用程序将mp4视频编码为不同的格式。然后点击你的代码:
Browsers like Internet Explorer and Safari support .H264 codec which plays mp4 files. Firefox support Theora codec which plays .ogv files. Chrome supports both .H264 and Theora. But to make your video works across all browser you need to encode your mp4 video into different formats using application like HandBrake. Then amke your code :
<video id="headervideo" controls>
<source src="<?php echo base_url(); ?>assets/home.mp4" type="video/mp4">
<source src="<?php echo base_url(); ?>assets/home.webm" type="video/webm">
<source src="<?php echo base_url(); ?>assets/home.ogv" type="video/ogg">
Your browser does not support the video tag.
</video>
并将您的.htacess文件更改为支持视频
and also change your .htacess file to support videos
AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
AddType video/ogg ogv
AddType audio/ogg ogg oga
AddType video/webm webm
这篇关于Chrome不会播放.mp4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!