设为首页收藏本站
网站公告 | 这是第一条公告
     

 找回密码
 立即注册
缓存时间02 现在时间02 缓存数据 以后会唱更多好听的歌给大家的 关注一下吧~

以后会唱更多好听的歌给大家的 关注一下吧~ -- 我要找到你

查看: 908|回复: 2

html网页播放多个视频的几种方法

[复制链接]

  离线 

TA的专栏

  • 打卡等级:热心大叔
  • 打卡总天数:227
  • 打卡月天数:0
  • 打卡总奖励:3343
  • 最近打卡:2025-04-13 11:14:19
等级头衔

等級:晓枫资讯-上等兵

在线时间
0 小时

积分成就
威望
0
贡献
417
主题
387
精华
0
金钱
4590
积分
856
注册时间
2023-1-6
最后登录
2025-5-31

发表于 2024-3-8 21:03:30 | 显示全部楼层 |阅读模式

前言

因为项目测试需要,我需要可以快速知道自己推流的多路视频流质量,于是我想到可以使用html网页来播放视频,实现效果极其简单,方法有好几种,以下是几种记录:

注意:测试过,VLC需要使用360急速浏览器,于是以下都是基于360急速浏览器测试的:

一、Demo1:iframe

video_url_player.html代码:

  1. <html>
  2. <head>
  3. <style>
  4. html,body,div{margin:1px;padding:0px;}
  5. td{padding:0px 1px 1px 0px;}
  6. table{border-collapse:collapse;border:0px solid #ff0000;text-align:center;}
  7. </style>
  8. </head>
  9. <body>
  10. <table width=100% height=100%>
  11. <tr>
  12. <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  13. <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  14. <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  15. </tr>
  16. <tr>
  17. <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  18. <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  19. </tr>
  20. </table>
  21. </body>
  22. </html>
复制代码

效果:

1.png

说明:

1. 支持几种常见的播放格式,无论是本地还是网络视频流都可以

2. 支持的格式不是特别多,一些特殊格式,无法播放

二、Demo2:VLC插件

需要安装VLC,然后就可以了,不过浏览器必须使用低版本的浏览器,测试一下很多浏览器不行,但是发现360急速浏览器就不需要所谓的低版本。

html代码:

  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  6. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  7. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  8. </embed>
  9. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  10. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  11. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  12. </embed>
  13. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  14. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  15. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  16. </embed>
  17. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  18. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  19. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  20. </embed>
  21. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  22. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  23. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  24. </embed>
  25. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  26. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  27. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  28. </embed>
  29. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  30. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  31. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  32. </embed>
  33. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  34. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  35. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  36. </embed>
  37. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  38. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  39. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  40. </embed>
  41. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  42. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  43. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  44. </embed>
  45. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  46. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  47. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  48. </embed>
  49. <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
  50. version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
  51. target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
  52. </embed>
  53. </body>
  54. </html>
复制代码

效果:

2.png

说明:

可以自由排布,以及支持非常多的格式,只要安装好环境以后,就可以使用,只是浏览器比较麻烦,但是效果和质量是真的好。

三、Demo3:使用一些常见的js

优势:嵌入简单,而且自动使用OpenGL渲染,有些支持硬件加速。

1. veoplayer

html代码:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>videoplayer</title>
  6. <script src="./veoplayer.global.min.js"></script>
  7. <style>
  8. /* 容器元素 */
  9. .container {
  10. display: grid;
  11. grid-template-columns: repeat(3, 1fr); /* 列数为3,每列平均分配剩余空间 */
  12. grid-template-rows: repeat(4, 1fr); /* 行数为4,每行平均分配剩余空间 */
  13. grid-gap: 10px; /* 单元格之间的间距 */
  14. }
  15. /* 单元格元素 */
  16. .cell {
  17. background-color: #ccc; /* 背景颜色 */
  18. padding: 20px; /* 内边距 */
  19. text-align: center; /* 文字居中 */
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <canvas id="video-canvas"></canvas>
  25. <script type="text/javascript">
  26. document.addEventListener('click', () => {
  27. let player = new JSMpeg.Player("rtsp://127.0.0.1:8554/live",{
  28. canvas: document.getElementById('jsmpeg-canvas'),
  29. // 要在用户点击过页面后,才可以播放声音
  30. // audio: false,
  31. })
  32. }, { once: true })
  33. </script>
  34. <div class="container">
  35. <div class="cell" id="veo0"></div>
  36. <div class="cell" id="veo1"></div>
  37. <div class="cell" id="veo2"></div>
  38. <div class="cell" id="veo3"></div>
  39. <div class="cell" id="veo4"></div>
  40. <div class="cell" id="veo5"></div>
  41. <div class="cell" id="veo6"></div>
  42. <div class="cell" id="veo7"></div>
  43. <div class="cell" id="veo8"></div>
  44. <div class="cell" id="veo9"></div>
  45. <div class="cell" id="veo10"></div>
  46. <div class="cell" id="veo11"></div>
  47. </div>
  48. <script type="text/javascript">
  49. let player0 = new VeoPlayer({
  50. id: "veo0",
  51. autoplay: true,
  52. url: "./test.mp4",
  53. height: 660,
  54. width: 445,
  55. style: {
  56. themeColor: "#91CB40",
  57. processColor: "#91CB40",
  58. animation: true,
  59. processHeight: 8,
  60. },
  61. });
  62. </script>
  63. <script type="text/javascript">
  64. let player1 = new VeoPlayer({
  65. id: "veo1",
  66. autoplay: true,
  67. url: "./test.mp4",
  68. height: 660,
  69. width: 445,
  70. style: {
  71. themeColor: "#91CB40",
  72. processColor: "#91CB40",
  73. animation: true,
  74. processHeight: 8,
  75. },
  76. });
  77. </script>
  78. <script type="text/javascript">
  79. let player2 = new VeoPlayer({
  80. id: "veo2",
  81. autoplay: true,
  82. url: "./test.mp4",
  83. height: 660,
  84. width: 445,
  85. style: {
  86. themeColor: "#91CB40",
  87. processColor: "#91CB40",
  88. animation: true,
  89. processHeight: 8,
  90. },
  91. });
  92. </script>
  93. <script type="text/javascript">
  94. let player3 = new VeoPlayer({
  95. id: "veo3",
  96. url: "./test.mp4",
  97. height: 660,
  98. width: 445,
  99. style: {
  100. themeColor: "#91CB40",
  101. processColor: "#91CB40",
  102. animation: true,
  103. processHeight: 8,
  104. },
  105. });
  106. </script>
  107. <script type="text/javascript">
  108. let player4 = new VeoPlayer({
  109. id: "veo4",
  110. url: "./test.mp4",
  111. height: 660,
  112. width: 445,
  113. style: {
  114. themeColor: "#91CB40",
  115. processColor: "#91CB40",
  116. animation: true,
  117. processHeight: 8,
  118. },
  119. });
  120. </script>
  121. <script type="text/javascript">
  122. let player5 = new VeoPlayer({
  123. id: "veo5",
  124. url: "./test.mp4",
  125. height: 660,
  126. width: 445,
  127. style: {
  128. themeColor: "#91CB40",
  129. processColor: "#91CB40",
  130. animation: true,
  131. processHeight: 8,
  132. },
  133. });
  134. </script>
  135. <script type="text/javascript">
  136. let player6 = new VeoPlayer({
  137. id: "veo6",
  138. url: "./test.mp4",
  139. height: 660,
  140. width: 445,
  141. style: {
  142. themeColor: "#91CB40",
  143. processColor: "#91CB40",
  144. animation: true,
  145. processHeight: 8,
  146. },
  147. });
  148. </script>
  149. <script type="text/javascript">
  150. let player7 = new VeoPlayer({
  151. id: "veo7",
  152. url: "./test.mp4",
  153. height: 660,
  154. width: 445,
  155. style: {
  156. themeColor: "#91CB40",
  157. processColor: "#91CB40",
  158. animation: true,
  159. processHeight: 8,
  160. },
  161. });
  162. </script>
  163. <script type="text/javascript">
  164. let player8 = new VeoPlayer({
  165. id: "veo8",
  166. url: "./test.mp4",
  167. height: 660,
  168. width: 445,
  169. style: {
  170. themeColor: "#91CB40",
  171. processColor: "#91CB40",
  172. animation: true,
  173. processHeight: 8,
  174. },
  175. });
  176. </script>
  177. <script type="text/javascript">
  178. let player9 = new VeoPlayer({
  179. id: "veo9",
  180. url: "./test.mp4",
  181. height: 660,
  182. width: 445,
  183. style: {
  184. themeColor: "#91CB40",
  185. processColor: "#91CB40",
  186. animation: true,
  187. processHeight: 8,
  188. },
  189. });
  190. </script>
  191. <script type="text/javascript">
  192. let player10 = new VeoPlayer({
  193. id: "veo10",
  194. url: "./test.mp4",
  195. height: 660,
  196. width: 445,
  197. style: {
  198. themeColor: "#91CB40",
  199. processColor: "#91CB40",
  200. animation: true,
  201. processHeight: 8,
  202. },
  203. });
  204. </script>
  205. <script type="text/javascript">
  206. let player11 = new VeoPlayer({
  207. id: "veo11",
  208. url: "./test.mp4",
  209. height: 660,
  210. width: 445,
  211. style: {
  212. themeColor: "#91CB40",
  213. processColor: "#91CB40",
  214. animation: true,
  215. processHeight: 8,
  216. },
  217. });
  218. </script>
  219. </body>
  220. </html>
复制代码

3.png

一样可以支持多种格式,效果还不错,不过支持的没有VLC的多。

相关文件看文章后面源码

2. kurento 播放rtsp

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="cache-control" content="no-cache">
  6. <meta http-equiv="pragma" content="no-cache">
  7. <meta http-equiv="expires" content="0">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  9. <link rel="shortcut icon" href="./img/kurento.png" type="image/png" />
  10. <script src="./js/jquery.min.js"></script>
  11. <script src="./js/kurento-client.min.js"></script>
  12. <script src="./js/kurento-utils.min.js"></script>
  13. <script src="./js/index.js"></script>
  14. <title>Kurento RTSP to WebRTC player</title>
  15. </head>
  16. <body>
  17. <div class="container">
  18. <div class="page-header">
  19. <h1>Kurento RTSP to WebRTC player</h1>
  20. </div>
  21. <div class="row">
  22. <div class="col-md-5">
  23. <h3>播放窗口</h3>
  24. <video id="videoOutput" autoplay width="480px" height="360px" style="border: 1px solid #857f7f;" poster="./img/webrtc.png"></video>
  25. </br>
  26. rtsp/http地址: <input style="width:350px;" id="address" type="text">
  27. </br></br>
  28. </div>
  29. <div class="col-md-2">
  30. <a id="start" href="#" class="btn btn-success"><span
  31. class="glyphicon glyphicon-play"></span> 播放</a><br /> <br /> <a
  32. id="stop" href="#" class="btn btn-danger"><span
  33. class="glyphicon glyphicon-stop"></span> 暂停</a>
  34. </div>
  35. </div>
  36. </div>
  37. </body>
  38. </html>
复制代码

4.png

这个是别人的代码,测试可用

3. video.js 

这个没测试成功

相关源码:

链接: https://pan.baidu.com/s/19p9qroD-xx5SxX4avW2CEw?pwd=v4cq 提取码: v4cq 

到此这篇关于html网页播放多个视频的几种方法的文章就介绍到这了,更多相关html播放多个视频内容请搜索晓枫资讯以前的文章或继续浏览下面的相关文章,希望大家以后多多支持晓枫资讯!


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
晓枫资讯-科技资讯社区-免责声明
免责声明:以上内容为本网站转自其它媒体,相关信息仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同其观点或证实其内容的真实性。
      1、注册用户在本社区发表、转载的任何作品仅代表其个人观点,不代表本社区认同其观点。
      2、管理员及版主有权在不事先通知或不经作者准许的情况下删除其在本社区所发表的文章。
      3、本社区的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,举报反馈:点击这里给我发消息进行删除处理。
      4、本社区一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
      5、以上声明内容的最终解释权归《晓枫资讯-科技资讯社区》所有。
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~

  离线 

TA的专栏

等级头衔

等級:晓枫资讯-列兵

在线时间
0 小时

积分成就
威望
0
贡献
0
主题
0
精华
0
金钱
19
积分
18
注册时间
2022-12-27
最后登录
2022-12-27

发表于 2024-3-31 11:40:52 | 显示全部楼层
路过,支持一下
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~

  离线 

TA的专栏

等级头衔

等級:晓枫资讯-列兵

在线时间
0 小时

积分成就
威望
0
贡献
0
主题
0
精华
0
金钱
17
积分
14
注册时间
2022-12-27
最后登录
2022-12-27

发表于 4 天前 | 显示全部楼层
感谢楼主分享。
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~
严禁发布广告,淫秽、色情、赌博、暴力、凶杀、恐怖、间谍及其他违反国家法律法规的内容。!晓枫资讯-社区
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1楼
2楼
3楼

手机版|晓枫资讯--科技资讯社区 本站已运行

CopyRight © 2022-2025 晓枫资讯--科技资讯社区 ( BBS.yzwlo.com ) . All Rights Reserved .

晓枫资讯--科技资讯社区

本站内容由用户自主分享和转载自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。

如有侵权、违反国家法律政策行为,请联系我们,我们会第一时间及时清除和处理! 举报反馈邮箱:点击这里给我发消息

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表