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

news2024/9/24 17:19:37

前言

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

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

一、Demo1:iframe

video_url_player.html代码:

<html>
<head>
  <style>
    html,body,div{margin:1px;padding:0px;}
    td{padding:0px 1px 1px 0px;}
    table{border-collapse:collapse;border:0px solid #ff0000;text-align:center;}
  </style>
</head>
<body>
<table width=100% height=100%>
  <tr>
    <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
    <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
    <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  </tr>
  <tr>
    <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
    <td><iframe frameborder=0 src=http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4 width=100% height=100%></iframe></td>
  </tr>
</table>
</body>
</html>

效果:

说明:

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

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

二、Demo2:VLC插件

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

html代码:

<html>
<head>
</head>

<body> 
	<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
		version="VideoLAN.VLCPlugin.2" width="320" height="240" id="vlc"
		target="file:///C:/Users/YJL/Desktop/testVideo/1080p_60fps_h264.mp4">
	</embed>
</body>
</html>

效果:

说明:

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

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

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

1. veoplayer

html代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>videoplayer</title>
    <script src="./veoplayer.global.min.js"></script>

	<style>
      /* 容器元素 */
      .container {
        display: grid;
        grid-template-columns: repeat(3, 1fr); /* 列数为3,每列平均分配剩余空间 */
        grid-template-rows: repeat(4, 1fr); /* 行数为4,每行平均分配剩余空间 */
        grid-gap: 10px; /* 单元格之间的间距 */
      }

      /* 单元格元素 */
      .cell {
        background-color: #ccc; /* 背景颜色 */
        padding: 20px; /* 内边距 */
        text-align: center; /* 文字居中 */
      }
    </style>
  </head>
  <body>
    <canvas id="video-canvas"></canvas>
	<script type="text/javascript">
      document.addEventListener('click', () => {
		let player = new JSMpeg.Player("rtsp://127.0.0.1:8554/live",{
			canvas: document.getElementById('jsmpeg-canvas'),
			// 要在用户点击过页面后,才可以播放声音
			// audio: false,
		})
	  }, { once: true })
      
    </script>

  <div class="container">
    <div class="cell" id="veo0"></div>
	<div class="cell" id="veo1"></div>
	<div class="cell" id="veo2"></div>
	<div class="cell" id="veo3"></div>
	<div class="cell" id="veo4"></div>
	<div class="cell" id="veo5"></div>
	<div class="cell" id="veo6"></div>
	<div class="cell" id="veo7"></div>
	<div class="cell" id="veo8"></div>
	<div class="cell" id="veo9"></div>
	<div class="cell" id="veo10"></div>
	<div class="cell" id="veo11"></div>
  </div>

    <script type="text/javascript">
      let player0 = new VeoPlayer({
        id: "veo0",
		autoplay: true,
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player1 = new VeoPlayer({
        id: "veo1",
        autoplay: true,
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player2 = new VeoPlayer({
        id: "veo2",
        autoplay: true,
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player3 = new VeoPlayer({
        id: "veo3",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player4 = new VeoPlayer({
        id: "veo4",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player5 = new VeoPlayer({
        id: "veo5",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	<script type="text/javascript">
      let player6 = new VeoPlayer({
        id: "veo6",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	
	<script type="text/javascript">
      let player7 = new VeoPlayer({
        id: "veo7",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player8 = new VeoPlayer({
        id: "veo8",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player9 = new VeoPlayer({
        id: "veo9",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player10 = new VeoPlayer({
        id: "veo10",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>
	    <script type="text/javascript">
      let player11 = new VeoPlayer({
        id: "veo11",
        url: "./test.mp4",
        height: 660,
        width: 445,
        style: {
          themeColor: "#91CB40",
          processColor: "#91CB40",
          animation: true,
          processHeight: 8,
        },
      });
    </script>

	    
  </body>
</html>

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

相关文件看文章后面源码

2. kurento 播放rtsp

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="./img/kurento.png" type="image/png" />

<script src="./js/jquery.min.js"></script>

<script src="./js/kurento-client.min.js"></script>
<script src="./js/kurento-utils.min.js"></script>

<script src="./js/index.js"></script>
<title>Kurento RTSP to WebRTC player</title>
</head>

<body>
	
	<div class="container">
		<div class="page-header">
			<h1>Kurento RTSP to WebRTC player</h1>
		</div>
		<div class="row">
			<div class="col-md-5">
				<h3>播放窗口</h3>
				<video id="videoOutput" autoplay width="480px" height="360px" style="border: 1px solid #857f7f;" poster="./img/webrtc.png"></video>
				</br>
				rtsp/http地址: <input style="width:350px;" id="address" type="text">
				</br></br>
			</div>
			<div class="col-md-2">
				<a id="start" href="#" class="btn btn-success"><span
					class="glyphicon glyphicon-play"></span> 播放</a><br /> <br /> <a
					id="stop" href="#" class="btn btn-danger"><span
					class="glyphicon glyphicon-stop"></span> 暂停</a>
			</div>
		</div>

		
	</div>
</body>
</html>

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

3. video.js 

这个没测试成功

4.其他:nodejs开启服务,实现网络播放rtsp

【前端】rtsp 与 rtmp 视频流的播放方法_Never Yu-华为云开发者联盟

相关源码:

html播放多路视频官方版下载丨最新版下载丨绿色版下载丨APP下载-123云盘

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1489945.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

97 spring 中的泛型类型注入

前言 呵呵 同样是 最近同事碰到的一个问题 他不太懂 英语, 看到的说明是 缺少一个 RedisTemplate 的实例, 但是找到了一个 RedisTemplate 的实例 呵呵 和我这里 spring 版本似乎是不太一样, 错误信息 有一些差异 以下环境基于 jdk8 spring-5.0.4-RELEASE 测试用例 BeanCon…

23种设计模式——工厂方法模式

定义&#xff1a; 一个用于创建对象的接口&#xff0c;让子类决定实例化哪一个类。工厂方法使一个类的实例化延迟到其他子类。 工厂方法通用类图&#xff1a; 这个图更好理解 在工厂方法模式中&#xff0c;抽象产品类Product负责定义产品的共性&#xff0c;实现对事物最抽象的…

人大金仓KingbaseES:银河麒麟V10安装

人大金仓KingbaseES&#xff1a;银河麒麟V10安装 众所周知的原因&#xff0c;为了响应国家信创支持国产操作系统和数据库&#xff0c;现在我们公司的项目要从开源数据库PostgreSQL切换到人大金仓KingbaseES数据库&#xff08;本质是早期版本的PostgreSQL&#xff09;。使用的是…

自适应控制算法讲解-案例(附C代码)

目录 一、自适应控制算法的基本原理 二、自适应控制算法分类 三、案例 3.1自适应PID控制 1&#xff09; 模型识别 2&#xff09;动态调整PID参数逻辑 3&#xff09;PID控制器 自适应控制算法是一种高级控制算法&#xff0c;用于处理那些参数不确定或者动态变化的系统。这类…

Elasticsearch:向量相似度计算 - 可笑的速度

作者&#xff1a;Chris Hegarty 任何向量数据库的核心都是距离函数&#xff0c;它确定两个向量的接近程度。 这些距离函数在索引和搜索期间执行多次。 当合并段或在图表中导航最近邻居时&#xff0c;大部分执行时间都花在比较向量的相似性上。 对这些距离函数进行微观优化是值…

AI-数学-高中-34概率-古典概率模型

原作者视频&#xff1a;【概率】【一数辞典】3古典概型_哔哩哔哩_bilibili 等可能性&#xff1a;每个样本点出现的可能性是相同的。 随机事件A的发生事件A的样本点数k / 样板空间总样本点数n。 示例1&#xff1a; 示例2&#xff1a;

[DevOps云实践] IaaC:通过CloudWatch Agent和自定义Metric监视服务器

[DevOps云实践] IaaC:通过CloudWatch Agent和自定义Metric监视服务器 现在有许多第三方工具可以用于监控EC2实例。尽管事实如此,我想为您提供使用AWS原生资源和工具(如AWS CloudWatch、CloudWatch Agent和CloudFormation)快速设置EC2监控所需的所有信息。 首先,您应该知…

2024.3.4

思维导图 作业1&#xff1a;广播 发送端&#xff1a; #include<myhead.h> int main(int argc, const char *argv[]) {//创建套接字int sfd socket(AF_INET,SOCK_DGRAM,0);if(sfd -1){perror("sockeet error");return -1;}//设置当前套接字允许广播属性int …

idea中引入新JDK环境

在不同的项目中往往会需要不同的运行环境&#xff0c;那么如何下载一个新的环境并运用到idea中呢&#xff1f; 下面给出的就是oracle官网&#xff0c;以JDK17为例教大家如何下载 Java Archive Downloads - GraalVM for JDK 17https://www.oracle.com/java/technologies/javase…

End-to-End Weakly-Supervised SemanticSegmentation with Transformers

摘要 弱监督语义分割&#xff08;WSSS&#xff09;使用图像级标签是一项重要且具有挑战性的任务。由于高训练效率&#xff0c;端到端的WSSS解决方案受到社区越来越多的关注。然而&#xff0c;当前的方法主要基于卷积神经网络&#xff0c;并未正确地探索全局信息&#xff0c;因…

在Visual Studio配置C++的netCDF库的方法

本文介绍在Windows电脑的Visual Studio软件中&#xff0c;配置C 语言最新版netCDF库的方法。 netCDF&#xff08;Network Common Data Form&#xff09;是一种用于存储、访问和共享科学数据的文件格式和库&#xff0c;其提供了一种灵活的方式来组织、描述和存储多维数据&#x…

【系统架构设计师考试大纲】

曾梦想执剑走天涯&#xff0c;我是程序猿【AK】 目录 简述概要知识图谱考试目标考试要求考试题目题型分析计算机基础知识&#xff08;20%&#xff09;信息化战略与规划&#xff08;9%&#xff09;软件工程&#xff08;25%&#xff09;系统架构设计&#xff08;35%&#xff09;信…

适用于 Windows 的7大数据恢复软件解决方案

数据丢失是数字世界中令人不快的一部分&#xff0c;它会在某一时刻影响许多计算机用户。很容易意外删除一些重要文件&#xff0c;这可能会在您努力恢复它们时带来不必要的压力。幸运的是&#xff0c;数据恢复软件可以帮助恢复已删除的文件&#xff0c;即使您没有备份它们。以下…

AI大模型与小模型之间的“脱胎”与“反哺”(第三篇)

51. **异构图神经网络集成&#xff08;Heterogeneous Graph Neural Network Integration&#xff09;**&#xff1a; 构建异构图神经网络来捕获和整合各行业间复杂的实体关系及属性信息。每个行业的小模型可视为一个子图&#xff0c;将它们整合进一个统一的大图模型中&#xff…

力扣206反转链表

206.反转链表 力扣题目链接(opens new window) 题意&#xff1a;反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 1&#xff0c;双指针 2&#xff0c;递归。递归参考双指针更容易写&#xff0c; 为什么不用头插…

学习JAVA的第十三天(基础)

目录 API之Arrays 将数组变成字符串 二分查找法查找元素 拷贝数组 填充数组 排序数组 Lambda表达式 集合的进阶 单列集合 体系结构 Collection API之Arrays 操作数组的工具类 将数组变成字符串 //将数组变成字符串char[] arr {a,b,c,d,e};System.out.println(Arra…

Linux-信号3_sigaction、volatile与SIGCHLD

文章目录 前言一、sigaction__sighandler_t sa_handler;__sigset_t sa_mask; 二、volatile关键字三、SIGCHLD方法一方法二 前言 本章内容主要对之前的内容做一些补充。 一、sigaction #include <signal.h> int sigaction(int signum, const struct sigaction *act,struc…

计数排序详解(附源码)

目录 思想&#xff1a; 源码&#xff1a; 思想&#xff1a; 计数排序&#xff1a;用一个数组记录按原始数据中&#xff0c;每个数据出现的次数 非常牛批的思路&#xff0c;没有用到比较 直接对每个数据进行计数 然后从计数的数组中&#xff0c;往回覆盖数据 从左到右&#xf…

解决Qtcreator搜狗输入法无法输入中文问题

由于搜狗输入法依赖fcitx&#xff0c;所以我们解决该问题的核心操作是为QtCreator提供支持fcitx 本系统环境说明&#xff1a;ubuntu22.04、Qt5.12.8、Qt6.6.1&#xff08;我安装了Qt5、Qt6&#xff09; 一、尝试拷贝系统自带libfcitxplatforminputcontextplugin.so到Qt安装目…

科技云报道:阿里云降价,京东云跟进,谁能打赢云计算价格战?

科技云报道原创。 就在大家还在回味2月29日阿里云发布“史上最大降价”的惊喜时&#xff0c;京东云连夜发布降价消息&#xff0c;成为第一家跟进的云服务商&#xff0c;其“随便降&#xff0c;比到底&#xff01;”的口号&#xff0c;颇有对垒的意味&#xff0c;直接吹响了云计…