彻底解决vue-video-player播放视频有黑边
需求
最近需要接入海康视频摄像头,然后把视频的画面接入到自己的网站系统中。以前对接过rtsp固定IP的显示视频,这次的不一样,没有了固定IP。海康的解决办法是,摄像头通过配置服务器到萤石云平台,然后购买企业版账号和套餐【注意必须要购买套餐】最便宜的一个月是300元。如果不购买,视频会一直转圈圈,无法播放。
# 萤石云平台官网
https://open.ys7.com
1、购买萤石云平台企业版套餐。

2、购买4G卡的流量,默认500MB,新人注册免费领取2G。官方测评一天流量消耗是8个G。
3、购买4G版的摄像头。
效果图

技术方案
1、摄像头通过4G的SIM卡把视频画面传输到萤石云平台。
2、萤石云平台把视频画面生成https开始m3u8结束的访问地址。
3、VUE通过vue-video-player播放m3u8视频画面。
操作教程
如果前期工作都准备好了可以直接看6789
如果前期工作都准备好了可以直接看6789
如果前期工作都准备好了可以直接看6789
1、配置摄像头
海康4G版的摄像头必须通过网线连接,然后需要一台电脑安装软件【设备网络搜索】,这个摄像头的网线必须和电脑在同一个网段内。
# SADP(设备网络搜索)下载地址
https://www.hikvision.com/cn/support/tools/hitools/clea8b3e4ea7da90a9/
2、摄像头初始化
安装完成后打开软件,软件会自动搜索到摄像头设备,注意未激活字样是当前的设备,注意看IP,在说明书的最后一页有摄像头默认的IP,如果一样就是当前的这台设备。左边单机设备,然后右边选中【使用萤石云】,输入账号密码和验证码即可。保存后就初始化完成。官网教程地址
# 海康设备接入指南
https://open.ys7.com/bbs/article/34
3、摄像头绑定
切记不要用海康的APP绑定,如果绑定了必须先取消绑定,否则萤石云平台是无法绑定设备的。

4、萤石云平台添加设备
打开萤石云平台, 点击【云接入】-【视频监控控制台】。点击添加新设备,追个添加,输入摄像头的序列号和验证码。添加好了,手动刷新页面,数据不会自动刷新的。
5、企业版购买
6、获取播放地址
【云接入】-【视频监控控制台】-【直播】,然后就能看到生成的访问地址,然后复制地址到VUE代码中。注意播放地址的有效期,后续可以通过代码动态获取播放地址。
# 根据appKey和secret获取accessToken
https://open.ys7.com/help/81# 获取播放地址
https://open.ys7.com/help/1414#萤石配网SDK使用说明
https://open.ys7.com/help/38

7、VUE安装插件
# 安装插件 vue2不知道video-player6的版本,只能安装5
npm install vue-video-player@5 --save # 安装hls
npm install videojs-contrib-hls --save
8、修改main.js
require('video.js/dist/video-js.css');
require('vue-video-player/src/custom-theme.css');
import hls from 'videojs-contrib-hls';
import VideoPlayer from 'vue-video-player';Vue.use(hls);
Vue.use(VideoPlayer);
9、VUE代码
<template><!-- 详情 --><el-drawer direction="ttb" custom-class="demo-drawer my_drawer1" ref="drawer" title="视频播放测试":visible.sync="openInfo" :before-close="handleClose" :wrapperClosable="false" size="100%"style="width: 1000px; margin: 0 auto;" append-to-body><div class="demo-drawer__content"><div class="formOutDiv"><div style="width: 100%; height: 450px; "><video-player ref="videoPlayer" class="vjs-custom-skin" :options="playerOptions"></video-player></div></div></div></el-drawer>
</template><script>import {getDevice} from "@/api/flowinn/device";export default {name: "Device",components: {},data() {return {openInfo: false,// 按照如下的配置+底部的css样式就能完成视频铺满DIV的效果,否则两边有黑边playerOptions: {// playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度autoplay: false, //如果true,浏览器准备好时开始回放。muted: false, // 默认情况下将会消除任何音频。loop: false, // 导致视频一结束就重新开始。preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)language: 'zh-CN',// aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")// fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。sources: [{type: 'application/x-mpegURL',src: null, //你的m3u8地址(必填)}, ],//poster: '', //你的封面地址poster.jpgdefaultQuality: 0,width: '1000px',height: '450px',hls: true,notSupportedMessage: '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。},};},created() {},methods: {// 设备详情页面关闭前事件handleClose(done) {done();let myPlayer = this.$refs.videoPlayer.player;myPlayer.pause();},/** 设备详情,我的方法是在父类页面触发的,自己按照自己的业务配置触发即可 */handleInfo(row) {let _this = this;let myPlayer = this.$refs.videoPlayer.player;getDevice(id).then(response => {if (response.data.videoUrl != null && response.data.videoUrl != "") {// 必须这种赋值,如果是直接用等号赋值播放一会就会报错,// The media could not be loaded, either because the server or network failed or because the format is not supported._this.$set(_this.playerOptions.sources, 0, {type: "application/x-mpegURL",src: response.data.videoUrl,});// 停止播放// myPlayer.pause();setTimeout(function() {//播放myPlayer.play();}, 30);}});},},mounted() {}};
</script><style rel="stylesheet/scss"></style>
// 以下两个样式就可以完成视频,全屏铺满DIV,不然两边会有黑边
<style rel="stylesheet/scss" lang="scss" scoped>::v-deep .video-js .vjs-tech {object-fit: fill;}::v-deep .vjs-poster {background-size: cover;}
</style>
结束
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
package cn.renkai721.bean.vo;import lombok.extern.slf4j.Slf4j;@Slf4j
public class MakeUpTheWordCount {private String make_up_the_word_count_column_999999999_1;private String make_up_the_word_count_column_999999999_2;private String make_up_the_word_count_column_999999999_3;private String make_up_the_word_count_column_999999999_4;private String make_up_the_word_count_column_999999999_5;private String make_up_the_word_count_column_999999999_6;private String make_up_the_word_count_column_999999999_7;private String make_up_the_word_count_column_999999999_8;private String make_up_the_word_count_column_999999999_9;private String make_up_the_word_count_column_999999999_10;private String make_up_the_word_count_column_999999999_11;private String make_up_the_word_count_column_999999999_12;private String make_up_the_word_count_column_999999999_13;private String make_up_the_word_count_column_999999999_14;private String make_up_the_word_count_column_999999999_15;private String make_up_the_word_count_column_999999999_16;private String make_up_the_word_count_column_999999999_17;private String make_up_the_word_count_column_999999999_18;private String make_up_the_word_count_column_999999999_19;private String make_up_the_word_count_column_999999999_20;public String getMake_up_the_word_count_column_999999999_1() {return make_up_the_word_count_column_999999999_1;}public void setMake_up_the_word_count_column_999999999_1(String make_up_the_word_count_column_999999999_1) {this.make_up_the_word_count_column_999999999_1 = make_up_the_word_count_column_999999999_1;}public String getMake_up_the_word_count_column_999999999_2() {return make_up_the_word_count_column_999999999_2;}public void setMake_up_the_word_count_column_999999999_2(String make_up_the_word_count_column_999999999_2) {this.make_up_the_word_count_column_999999999_2 = make_up_the_word_count_column_999999999_2;}public String getMake_up_the_word_count_column_999999999_3() {return make_up_the_word_count_column_999999999_3;}public void setMake_up_the_word_count_column_999999999_3(String make_up_the_word_count_column_999999999_3) {this.make_up_the_word_count_column_999999999_3 = make_up_the_word_count_column_999999999_3;}public String getMake_up_the_word_count_column_999999999_4() {return make_up_the_word_count_column_999999999_4;}public void setMake_up_the_word_count_column_999999999_4(String make_up_the_word_count_column_999999999_4) {this.make_up_the_word_count_column_999999999_4 = make_up_the_word_count_column_999999999_4;}public String getMake_up_the_word_count_column_999999999_5() {return make_up_the_word_count_column_999999999_5;}public void setMake_up_the_word_count_column_999999999_5(String make_up_the_word_count_column_999999999_5) {this.make_up_the_word_count_column_999999999_5 = make_up_the_word_count_column_999999999_5;}public String getMake_up_the_word_count_column_999999999_6() {return make_up_the_word_count_column_999999999_6;}public void setMake_up_the_word_count_column_999999999_6(String make_up_the_word_count_column_999999999_6) {this.make_up_the_word_count_column_999999999_6 = make_up_the_word_count_column_999999999_6;}public String getMake_up_the_word_count_column_999999999_7() {return make_up_the_word_count_column_999999999_7;}public void setMake_up_the_word_count_column_999999999_7(String make_up_the_word_count_column_999999999_7) {this.make_up_the_word_count_column_999999999_7 = make_up_the_word_count_column_999999999_7;}public String getMake_up_the_word_count_column_999999999_8() {return make_up_the_word_count_column_999999999_8;}public void setMake_up_the_word_count_column_999999999_8(String make_up_the_word_count_column_999999999_8) {this.make_up_the_word_count_column_999999999_8 = make_up_the_word_count_column_999999999_8;}public String getMake_up_the_word_count_column_999999999_9() {return make_up_the_word_count_column_999999999_9;}public void setMake_up_the_word_count_column_999999999_9(String make_up_the_word_count_column_999999999_9) {this.make_up_the_word_count_column_999999999_9 = make_up_the_word_count_column_999999999_9;}public String getMake_up_the_word_count_column_999999999_10() {return make_up_the_word_count_column_999999999_10;}public void setMake_up_the_word_count_column_999999999_10(String make_up_the_word_count_column_999999999_10) {this.make_up_the_word_count_column_999999999_10 = make_up_the_word_count_column_999999999_10;}public String getMake_up_the_word_count_column_999999999_11() {return make_up_the_word_count_column_999999999_11;}public void setMake_up_the_word_count_column_999999999_11(String make_up_the_word_count_column_999999999_11) {this.make_up_the_word_count_column_999999999_11 = make_up_the_word_count_column_999999999_11;}public String getMake_up_the_word_count_column_999999999_12() {return make_up_the_word_count_column_999999999_12;}public void setMake_up_the_word_count_column_999999999_12(String make_up_the_word_count_column_999999999_12) {this.make_up_the_word_count_column_999999999_12 = make_up_the_word_count_column_999999999_12;}public String getMake_up_the_word_count_column_999999999_13() {return make_up_the_word_count_column_999999999_13;}public void setMake_up_the_word_count_column_999999999_13(String make_up_the_word_count_column_999999999_13) {this.make_up_the_word_count_column_999999999_13 = make_up_the_word_count_column_999999999_13;}public String getMake_up_the_word_count_column_999999999_14() {return make_up_the_word_count_column_999999999_14;}public void setMake_up_the_word_count_column_999999999_14(String make_up_the_word_count_column_999999999_14) {this.make_up_the_word_count_column_999999999_14 = make_up_the_word_count_column_999999999_14;}public String getMake_up_the_word_count_column_999999999_15() {return make_up_the_word_count_column_999999999_15;}public void setMake_up_the_word_count_column_999999999_15(String make_up_the_word_count_column_999999999_15) {this.make_up_the_word_count_column_999999999_15 = make_up_the_word_count_column_999999999_15;}public String getMake_up_the_word_count_column_999999999_16() {return make_up_the_word_count_column_999999999_16;}public void setMake_up_the_word_count_column_999999999_16(String make_up_the_word_count_column_999999999_16) {this.make_up_the_word_count_column_999999999_16 = make_up_the_word_count_column_999999999_16;}public String getMake_up_the_word_count_column_999999999_17() {return make_up_the_word_count_column_999999999_17;}public void setMake_up_the_word_count_column_999999999_17(String make_up_the_word_count_column_999999999_17) {this.make_up_the_word_count_column_999999999_17 = make_up_the_word_count_column_999999999_17;}public String getMake_up_the_word_count_column_999999999_18() {return make_up_the_word_count_column_999999999_18;}public void setMake_up_the_word_count_column_999999999_18(String make_up_the_word_count_column_999999999_18) {this.make_up_the_word_count_column_999999999_18 = make_up_the_word_count_column_999999999_18;}public String getMake_up_the_word_count_column_999999999_19() {return make_up_the_word_count_column_999999999_19;}public void setMake_up_the_word_count_column_999999999_19(String make_up_the_word_count_column_999999999_19) {this.make_up_the_word_count_column_999999999_19 = make_up_the_word_count_column_999999999_19;}public String getMake_up_the_word_count_column_999999999_20() {return make_up_the_word_count_column_999999999_20;}public void setMake_up_the_word_count_column_999999999_20(String make_up_the_word_count_column_999999999_20) {this.make_up_the_word_count_column_999999999_20 = make_up_the_word_count_column_999999999_20;}
}
相关文章:
彻底解决vue-video-player播放视频有黑边
需求 最近需要接入海康视频摄像头,然后把视频的画面接入到自己的网站系统中。以前对接过rtsp固定IP的显示视频,这次的不一样,没有了固定IP。海康的解决办法是,摄像头通过配置服务器到萤石云平台,然后购买企业版账号和…...
区域负责人常用的ChatGPT通用提示词模板
区域市场分析:如何分析区域市场的特点、竞争态势和客户需求? 区域销售策略制定:如何制定针对区域市场的销售策略,包括产品定位、价格策略、渠道策略等? 区域销售目标设定:如何设定明确的区域销售目标&…...
Java Spring boot 可變參數,以及弊端
function中 不固定的參數 public boolean sendEmail(String manFrom, String manTo,String manCc, String subject, String... msg); 必須是最後一個參數,傳值時可以多個。 sendEmail(“a.gmail”,"b.gmail","c.gmail","subject",…...
机器视觉系统选型-线阵工业相机选型
线阵相机特点: 1.线阵相机使用的线扫描传感器通常只有一行感光单元(少数彩色线阵使用三行感光单元的传感器) 2.线阵相机每次只采集一行图像; 3.线阵相机每次只输出一行图像; 4.与传统的面阵相机相比,面阵扫…...
单机开机无感全自动进入B\S架构系统
单机开机无感全自动进入B\S架构系统 标题:单机用jar包启动项目bat(批处理)不弹黑窗口,并设置开机自启,打开浏览器,访问系统。引言:在实际工作中,遇到单机部署的情况,如今…...
大一,如何成为一名fpga工程师?
1、数电(必须掌握的基础),然后进阶学模电(选学), 2、掌握HDL(HDLverilogVHDL)可以选择verilog或者VHDL,建议verilog就行。 3、掌握FPGA设计流程/原理(推…...
MyBatisPlus学习三:Service接口、代码生成器
学习教程 黑马程序员最新MybatisPlus全套视频教程,4小时快速精通mybatis-plus框架 Service接口 简介 在MyBatis-Plus框架中,Service接口的作用是为实体类提供一系列的通用CRUD(增删改查)操作方法。通常情况下,Servi…...
产品经理如何选择城市?
年底,全国性的人口大迁徙即将开始。选择城市,堪称年轻人的“二次投胎”,族望留原籍,家贫走他乡。 古人在选择城市时,主要的考量因素是家族势力,这一点放在当代,大致也成立,如果在老…...
再谈“敏捷”与“瀑布”在产品开发过程中的反思
作为一家专注于软件开发的公司《智创有术》,我们致力于为客户提供创新、高效和可靠的解决方案。通过多年的经验和专业知识,我们已经在行业内建立了良好的声誉,并赢得了客户的信任和支持。 支持各种源码,网站搭建,APP&a…...
设计模式② :交给子类
文章目录 一、前言二、Template Method 模式1. 介绍2. 应用3. 总结 三、Factory Method 模式1. 介绍2. 应用3. 总结 参考内容 一、前言 有时候不想动脑子,就懒得看源码又不像浪费时间所以会看看书,但是又记不住,所以决定开始写"抄书&qu…...
Hive 源码
hive 编译 issue Failed to execute goal com.github.os72:protoc-jar-maven-plugin:3.5.1.1:run (default) on project hive-standalone-metastore: Error resolving artifact: com.google.protobuf:protoc:2.5.0: The following artifacts could not be resolved: com.goog…...
调整几行代码,接口吞吐提升 10 倍,性能调优妙啊!
景 分析过程 总结 背景 公司的一个ToB系统,因为客户使用的也不多,没啥并发要求,就一直没有经过压测。这两天来了一个“大客户”,对并发量提出了要求:核心接口与几个重点使用场景单节点吞吐量要满足最低500/s的要求。 当时一想,500/s吞吐量还不简单。Tomcat按照100个线程…...
MACOS Atrust服务异常
MAC版Atrust服务异常 点击进入办公后出现提示其一: 核心服务未启动,部分功能存在异常,确定重新启动吗? 可能的原因: 1.上次已完全退出客户端 2.核心服务被其他程序优化禁用 点击重新启动后,出现提示&#x…...
LLM大语言模型(四):在ChatGLM3-6B中使用langchain
目录 背景准备工作工具添加LangChain 已实现工具Calculator、Weather Tool配置 自定义工具自定义kuakuawo Agent 多工具使用参考 背景 LangChain是一个用于开发由语言模型驱动的应用程序的框架。它使应用程序能够: 具有上下文意识:将语言模型与上下文源(提示指令&…...
Dubbo入门介绍和实战
1. 引言 Dubbo是一款开源的高性能、轻量级的Java RPC(远程过程调用)框架,旨在解决分布式服务之间的通信问题。本文将介绍Dubbo的基础概念、核心特性以及使用场景,包括实际示例演示。 2. 什么是Dubbo? Dubbo是阿里巴…...
如何实现无人机识别功能
无人机识别算法可以基于不同的传感器和技术,结合多种方法进行实现。以下是一些常见的无人机识别算法和技术: 视觉识别: 图像处理: 使用计算机视觉技术对无人机图像进行处理,包括特征提取、目标检测和跟踪等。深度学习&…...
Python学习笔记(四)流程控制方法
流程控制有三种方法:分支、循环、跳出 流程的控制通过布尔值来实现,分支和循环都需要对一定的条件进行判断,根据判断结果(布尔值)决定下一步要做什么 布尔值通过比较运算符、逻辑运算符来进行判断是True还是False 不…...
【Qt- C++ Qml 交互】
Qt编程指南 VX:hao541022348 ■ 将C对象注册到 QML中,在QML使用C对象■ C对象注册到元对象系统■ Q_INVOKABLE 宏定义是将C 的 函数(方法)声明为元对象系统可调用的函数■ 演示步骤 ■ 将 C类注册到 QML,并在QML声明一…...
ubuntu 20.04 自由切换 python 的版本
问题描述 当前 ubuntu 20.04 默认安装了多个 python 的版本,执行 python 时,默认版本是 Python 2.7.18 zhangszzhangsz:~$ python Python 2.7.18 (default, Jul 1 2022, 12:27:04) [GCC 9.4.0] on linux2 Type "help", "copyright&quo…...
程序性能优化全能手册
本文聊一个程序员都会关注的问题:性能。 当大家谈到“性能”时,你首先想到的会是什么? 是每次请求需要多长时间才能返回? 是每秒钟能够处理多少次请求? 还是程序的CPU和内存使用率高不高? 这些问题基本上…...
Sentinel-1A极化矩阵处理实战:用SNAP生成C2矩阵的7个关键参数解析与效果对比
Sentinel-1A极化矩阵处理实战:用SNAP生成C2矩阵的7个关键参数解析与效果对比 当处理Sentinel-1A极化SAR数据时,C2矩阵的生成质量直接影响后续地物分类、变化检测等应用的精度。许多初学者在使用SNAP的Polarimetric-Matrices算子时,往往直接采…...
PS软件插件开发思维:为视频编辑流程注入AI字幕能力
PS软件插件开发思维:为视频编辑流程注入AI字幕能力 不知道你有没有过这样的经历:辛辛苦苦剪完一个视频,到了加字幕这一步,整个人都蔫了。要么是手动敲字敲到手抽筋,要么是自动生成的字幕时间轴对不上,还得…...
163MusicLyrics:音乐数据智能解析引擎如何重构歌词获取体验
163MusicLyrics:音乐数据智能解析引擎如何重构歌词获取体验 【免费下载链接】163MusicLyrics Windows 云音乐歌词获取【网易云、QQ音乐】 项目地址: https://gitcode.com/GitHub_Trending/16/163MusicLyrics 深夜,一位音乐制作人正在为即将发布的…...
Windows系统OpenClaw避坑指南:nanobot镜像部署常见报错解决
Windows系统OpenClaw避坑指南:nanobot镜像部署常见报错解决 1. 为什么选择nanobot镜像部署OpenClaw 去年我在尝试将OpenClaw接入本地大模型时,被复杂的依赖关系和GPU配置折磨得够呛。直到发现星图平台的nanobot镜像——这个预装了Qwen3-4B-Instruct模型…...
Qwen-Image-Edit-2509场景应用:品牌VI统一与多语言海报智能修改
Qwen-Image-Edit-2509场景应用:品牌VI统一与多语言海报智能修改 1. 品牌视觉管理的痛点与机遇 全球500强企业的设计总监们每年要面对一个共同难题:如何确保分布在50个国家的分公司,在制作本地化营销素材时,都能严格遵守总部制定…...
基于SpringBoot + Vue的垃圾分类回收网站(角色:用户、回收人员、管理员)
文章目录前言一、详细操作演示视频二、具体实现截图三、技术栈1.前端-Vue.js2.后端-SpringBoot3.数据库-MySQL4.系统架构-B/S四、系统测试1.系统测试概述2.系统功能测试3.系统测试结论五、项目代码参考六、数据库代码参考七、项目论文示例结语前言 💛博主介绍&#…...
CameraFileCopy:重新定义无网络文件传输的安卓应用
CameraFileCopy:重新定义无网络文件传输的安卓应用 【免费下载链接】cfc Demo/test android app for libcimbar. Copy files over the cell phone camera! 项目地址: https://gitcode.com/gh_mirrors/cfc/cfc 在移动设备普及的今天,我们依然经常面…...
从PointNet++到SoftGroup:手把手带你复现5个经典3D点云分割算法(附PyTorch代码)
从PointNet到SoftGroup:5大3D点云分割算法实战解析与PyTorch实现指南 1. 3D点云分割技术演进与核心挑战 在三维视觉领域,点云分割技术正经历着从基础架构到复杂系统的革命性演变。不同于传统图像处理,点云数据具有非结构化、稀疏性和无序性三…...
国科大研一CS选课避坑指南:从算法分析到模式识别,我的踩坑与真香体验
国科大研一CS选课避坑指南:从算法分析到模式识别,我的踩坑与真香体验 第一次踏入国科大雁栖湖校区的图书馆时,我被落地窗外绵延的燕山山脉震撼得说不出话——直到发现座位插座没电、WiFi信号时断时续,才意识到理想与现实的参差。这…...
如何用MAT修复老照片?3个实用技巧让破损图像重获新生
如何用MAT修复老照片?3个实用技巧让破损图像重获新生 【免费下载链接】MAT MAT: Mask-Aware Transformer for Large Hole Image Inpainting 项目地址: https://gitcode.com/gh_mirrors/ma/MAT 想象一下,你从祖辈那里继承了一张珍贵的黑白老照片&a…...
