首页 好物正文

【推荐】uniapp插件视频压缩、视频裁剪、视频码率、视频帧图片

yuange 好物 2022-09-11 2003 0 uniapp插件

直接到插件市场购买点击:image.png

8E3563BB20F47086D17609BB92E32817.jpg

概述

支持视频压缩、码率
支持视频裁剪
支持获取视频某一帧的图片
支持获取视频的基本宽高长度信息

如何调用插件

var pluginModule = uni.requireNativePlugin('yuange-YGVideoCompressModule')

压缩视频

   pluginModule.callNativeCompressVideo({                    
                   inFilePath: plus.io.convertLocalFileSystemURL(path), //输入文件路径
                    // outHeight: 1920, //输出视频高度
                    // outWidth: 1080, //输出视频宽度
                    bitrate: 55000, //码率
                    // frameRate: 30, //帧率
                }, (res) => {                    if (res.success) {                        this.text = "执行压缩完成"                        
                        this.outPath = res.outPath //输出路径
                    }                    this.text = '执行压缩进度:' + this.progressPercent(res.progress)
                }, (e) => {                    this.text = '执行压缩失败'
                })

裁剪视频

  pluginModule.callNativeCutVideo({                   
                   inFilePath: plus.io.convertLocalFileSystemURL(path),//输入文件路径
                    startTimeMs: 0, //毫秒单位 例如从0毫秒开始
                    endTimeMs: 10000 //毫秒单位 例如截止时间10毫秒
                }, (res) => {                    if (res.success) {                        this.text = "执行压缩裁剪"
                        this.outPath = res.outPath //输出路径
                    }                    this.text = '执行裁剪进度:' + this.progressPercent(res.progress)
                }, (e) => {                    this.text = '执行裁剪失败'
                })

获取视频信息:某一帧的图片、视频的宽、高、长度

    pluginModule.callNativeGetVideoInfo({                   
                   inFilePath: path, //本地视频绝对路径
                    // timeUs: 1000000, //1s 不指定返回首帧图片,单位是(微妙)
                }, (res) => {                    this.framePic = 'data:image/jpeg;base64,' + res.framePic; //指定时间帧图片
                    this.duration = res.duration + 'ms'; //时长 毫秒
                    this.width = res.width; //宽
                    this.height = res.height; //高
                }, (e) => {})


Demo下载链接: https://pan.baidu.com/s/105AJkLnjJksrpJHiS8Ky3g  密码: le33

评论

在线客服-可直接交谈

您好!有什么需要可以为您服务吗?