且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Html视频播放器播放声音,但不播放视频

更新时间:2023-09-21 21:07:46

你的问题与文件编码有关。 HTML5只支持很少的类型,不幸的是,每个浏览器只能播放这个窄列表的一部分。



如果您将mp4文件转换为 H。 264 编码它可以在Chrome和IE9及更高版本上运行,但显然由于专利问题,firefox不支持它,但是如果操作系统可以播放,它将播放它。这真的很烦人,仍然需要使用播放器才能在不支持的浏览器中播放文件。


Im in the process of making a webpage, and im trying to insert a video. The video player loads fine, and you can press play, but only the audio plays, not the video. (When previewing in chrome) When viewing in firefox it works properly

My code is as follows...

<video width="600" height="400" controls>
  <source src="ds2.mp4" type="video/mp4">
  <source src="ds2.ogv" type="video/ogv">
  <source src="ds2.webm" type="video/webm">

Your browser does not support the video tag.

</video>

My Doctype is <!Doctype html>

I checked the MIME type, its Video/mp4. however, one of the mime requests is in red and cancelled (When checking with google dev tools networking)

Im using microsoft expression web 4 (incase it is relevant)

If i've neglected any important information please let me know and ill update the post :) Thanks in advance for your help :)

Your problem is with the file encoding. HTML5 supports very few types and, sadly, every browser can play only part of this narrow list.

If you convert your mp4 file to H.264 encoding it will work on chrome and IE9 and above, but apparently due to patent issues, firefox does not support it but will play it if the OS can play it. This is really annoying and still require the use of players in order to play files in not-supported browsers.