Problems embedding mp4 video

北战南征 提交于 2020-01-21 23:53:51

问题


I'm trying to use the html5 video tag to embed an mp4 but I'm having some issues that vary across different browsers.

My code looks like this:

<video controls="controls" width="640" height="360">
    <source src="http://www.mydomain.com/video.mp4" type="video/mp4" />
</video>

IE - Won't recognize the file when trying to embed (edit: IE was actually dragging on the file size not the format) and when the uri to my video is plugged into the address bar it opens the video in windows media player.

Chrome, Firefox - Simply will not recognized the file format (edit: Firefox was dragging on the size as well, Chrome was the only browser having issues) and when the uri is plugged into the address bar it attempts to play the video within the browser but fails.

Could there be something within the file that would prevent it from being embedded? If so, how can I find this out?


回答1:


The problem is likely that the browsers are not supporting MP4, because it is a proprietary format. To get the best cross-browser support you'll have to also encode your video in WebM and Ogg/Vorbis formats and then add those files to your video tag with their own source tags.

Just because a browser will play a video if you navigate directly to the video's URL does not mean that the browser supports that format. Usually, navigating straight to the video causes the browser to play the video with a plug-in such as Quicktime or VLC that has much better codec support than the browser does.




回答2:


try this without that "/"

<video controls="controls" width="640" height="360">
<source src="http://www.mydomain.com/video.mp4" type="video/mp4" >
<source src="http://www.mydomain.com/video.ogg" type="video/ogg" >
</video>


来源:https://stackoverflow.com/questions/24455797/problems-embedding-mp4-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!