首页 > 其他分享 >vue使用EasyPlayer.js显示H.265/HEVC格式的监控视频

vue使用EasyPlayer.js显示H.265/HEVC格式的监控视频

时间:2023-03-17 16:55:22浏览次数:34  
标签:H.265 vue HEVC min easyplayer EasyPlayer input easydarwin js

背景

  最近在写关于在pc页面上显示hls的m3u8格式的监控视频,vue常用的播放插件如vue-video-player或者videojs,只支持h264编码的视频,项目中返回的监控地址,显示的是h265编码的格式,为此头秃了两天……

解决问题

EasyPlayer.js

  (1)在线演示,查看是否能展示你要展示的视频,再决定是否使用。(http://www.easydarwin.org/easyplayer/)

  (2)要是之前下载了vedio.js,请先删除安装包

  vue3项目引入

  1.npm install @easydarwin/easyplayer --save

  2.粘贴node包里面的EasyPlayer.wasm和EasyPlayer-element.min.js

    

   3.复制到public文件下,与index。html同级。自己找个jquery.min.js

    

  4.在index.html引入

    

   5.在页面中使用EasyPlayer

<template>
    <div id="app">
        <el-row>
            <el-col :span="24">
                <EasyPlayer :videoUrl="videoUrl" fluent autoplay live stretch></EasyPlayer>
                <el-input v-model="input" placeholder="请输入播放地址" size="mini"></el-input>
                <p>
                    列如:http://127.0.0.1:10800/test.flv
                    <a href="http://www.easydarwin.org/easyplayer/" target="_blank">在线演示</a>
                </p>
                <el-button class="player-button" size="mini" type="success" @click="player">播放</el-button>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import EasyPlayer from '@easydarwin/easyplayer';
export default {
    data() {
        return {
            videoUrl: '',
            input: ''
        };
    },
    components: {
        EasyPlayer
    },
    mounted() {},
    methods: {
        player() {
            if (!this.input) {
                this.$message.error('请输入播放地址地址!');
            } else {
                this.videoUrl = this.input;
            }
        }
    }
};
</script>

<style lang="scss">
#app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    // text-align: center;
    color: #2c3e50;
}
.el-row,
.div-btn {
    max-width: 800px;
    margin: auto;
}
.div-btn {
    padding: 5px 0;
}
.el-col {
    min-height: 300px;
    // border: 1px pink solid
    .easy-player {
        height: 500px !important;
    }
}
.el-input {
    padding: 5px;
    box-sizing: border-box;
}

.player-button {
    margin: 5px;
    width: 100%;
}
p {
    font-size: 12px;
    color: #67c23a;
}
.el-input__inner:focus {
    border-color: #67c23a !important;
}
</style>

  

  vue2项目引用

  1.npm install @easydarwin/easyplayer --save

  2.复制EasyPlayer-lib.min.js文件

    

   3.随便找个地方放都行,只要index.hrml加载正确就行

    

   4.在index.html加载,对了,记得自己再找个jquery.min.js

    

   5.修改webpack.dev.conf.js,找到CopyWebpackPlugin,里面写上EasyPlayer.wasm,crossdomain.xml和EasyPlayer-lib.min.js,目的是运行时和index.html同级,加上时记得重新运行,否则会报错,显示video.js找不到

new CopyWebpackPlugin([{
        from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer.wasm'
      },
      {
        from: 'node_modules/@easydarwin/easyplayer/dist/component/crossdomain.xml'
      },
      {
        from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer-lib.min.js'
      },
      {
        from: path.resolve(__dirname, '../static'),
        to: config.dev.assetsSubDirectory,
        ignore: ['.*']
      }
    ])

  6.使用

  <easy-player :videoUrl="videoUrl" fluent autoplay live stretch style="width: 100%;height: 100%;"></easy-player>

  import EasyPlayer from "@easydarwin/easyplayer"

  components: { EasyPlayer }

  把接口获取到的视频地址赋给videoUrl就行

标签:H.265,vue,HEVC,min,easyplayer,EasyPlayer,input,easydarwin,js
From: https://www.cnblogs.com/xmpz/p/17227357.html

相关文章

  • Vue 常用语句
    删除对象数组中的一个对象tableData.value.splice(tableData.value.findIndex((m)=>m.id==row.id),1)批量删除rows.forEach((ro......
  • Vue.js 生命周期-引出生命周期
    视频<!DOCTYPEhtml><html> <head> <metacharset="UTF-8"/> <title>引出生命周期</title> <!--引入Vue--> <scripttype="text/javascript"src="../js/vue......
  • Vue.js 内置指令 v-pre指令
    视频<!DOCTYPEhtml><html> <head> <metacharset="UTF-8"/> <title>v-pre指令</title> <!--引入Vue--> <scripttype="text/javascript"src="../js/vue.js......
  • Vue.js 内置指令 v-once指令
    视频<!DOCTYPEhtml><html> <head> <metacharset="UTF-8"/> <title>v-once指令</title> <!--引入Vue--> <scripttype="text/javascript"src="../js/vue.j......
  • uniapp 隐藏nvue子窗口 不生效
    下面是uniapp官方给到,显示和关闭NVue子窗体的方法 //通过id获取nvue子窗体constsubNVue=uni.getSubNVueById('map_widget')//打开nvue子窗体su......
  • vue添加eslint配置规则
    eslint配置方法eslint的规则有三个选项:"off"或者0,不启用这个规则"warn"或者1,出现问题会有警告"error"或者2,出现问题会报错在根目录创建.eslintrc.js,代码如下:modul......
  • Vue 学习笔记
      各目录作用{{}}引用data中的值v-html引用data中的值并渲染到页面上v-bind控制属性中的值缩写v-model数据双向绑定v-ifv-on:click监听事件缩写{{message|c......
  • 万字血书Vue—Vue语法
    模板语法插值语法Mustache插值采用{{}},用于解析标签体内容,将Vue实例中的数据插入DOM中<h1>Hello{{name}}</h1>指令语法指令用于解析标签,是vue为开发者提供的一套......
  • vue中的get方法\post方法如何实现传递数组参数
    问题:后端接口参数里面带有数组,但是前端按常规方式提交后后台收不到数组数据解决方法:将数据用qs处理过后再提交请求封装:exportclassAxiosHttpService{$http:Ax......
  • Electron + Vue3 + TS + sqlite3项目搭建
    Electron+Vue3+TS+sqlite3项目搭建基础环境nodev14.20.1npmv6.14.17安装vue-cli$npminstall@vue/[email protected]//等待安装完成$vue-V//@vue/cli5......