如何使用视频标签在html网页中嵌入.h264视频文件 [英] How to embed .h264 video file in html webpage using video tags

查看:1107
本文介绍了如何使用视频标签在html网页中嵌入.h264视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在浏览器中播放 .h264 文件,试图使用html视频标签来完成此操作。结果总是一个空框架。



我确实在网上检查了一些链接,他们建议在 .mp4 容器中播放视频。



有人可以帮我完成这项工作吗?

更新代码:

参考文献:

我如何播放H264视频?

播放.h264文件网络播放器



http://www.htmlgoodies.com/html5/client/how-to-embed- video-using-html5.html#fbid = 6u-u00TH7Je

解决方案

您不必包含h .264在你的html代码中,你只需要包含视频文件的路径和视频文件名。所以,假设你的视频文件是.mp4,你的文件名是 myvideo.mp4 ,你的 myvideo.mp4 是在一个名为 videos 的文件夹中,你的html文件就在你项目文件夹下的 videos 文件夹之外,那么这就是你必须这样做:

 < video width =560controls> 
< source src =videos / myvideo.mp4type =video / mp4>
< / video>

只要您的视频采用mp4格式编码,这将会起作用。 h264是一种编解码器,在这种情况下它是完全不相关的。



你应该首先在网上找到一个mp4编码器,有许多免费编码器,将你的视频编码为.mp4,然后使用上面的html代码,你的视频就可以正常播放。

I am trying to play .h264 file in browser, Trying to accomplish this using html video tags. The result is always an empty frame.

I did check some links on web, They recommend to play the video in .mp4 container.

Can someone help me to accomplish this?

UPDATED CODE:

<video width="560" height="340" preload controls>

  <source src="hh.h264" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
  	<!--<source src="hh.mov" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
	<source src="hh.ogv" type='video/ogg; codecs="theora, vorbis"' />
	<source src="hh.webm" type='video/webm; codecs="vp8, vorbis"' />-->



</video>

References:

How do i play H264 video?

Play .h264 files webplayer

http://www.htmlgoodies.com/html5/client/how-to-embed-video-using-html5.html#fbid=6u-u00TH7Je

解决方案

You don't have to include h.264 in your html code, you only need to include the path to your video file and the video file name. So, let's say your video file is .mp4 and your file's name is myvideo.mp4 and your myvideo.mp4 is in a folder named videos and your html file is just outside that videos folder in your project folder then this is what you have to do:

<video width="560" controls>
  <source src="videos/myvideo.mp4" type="video/mp4">
</video>

This will work, provided your video is encoded in mp4 format. The h264 is a codec and it's completely irrelevant in this situation.

You should first find an mp4 encoder online, there are many free encoders, encode your video to .mp4 then use the html code above and your video will play fine.

这篇关于如何使用视频标签在html网页中嵌入.h264视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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