更新记录
                                                                                                    
                                                    
                                                        1.0.9(2025-04-02)
                                                        
                                                    
                                                    ios getMediaInformation 完整回调
                                                                                                    
                                                    
                                                        1.0.8(2024-12-23)
                                                        
                                                    
                                                    ios成功信息回调
                                                                                                    
                                                    
                                                        1.0.7(2024-12-03)
                                                        
                                                    
                                                    ios统计信息回调
                                                                                                                                                    查看更多
                                                                                                
                                            
                                                                                                                                                        平台兼容性
                                                                                                                                                                                                                                                                                                                                uni-app
                                                                                                                                                                                                                                    
| Vue2 | 
Vue3 | 
Chrome | 
Safari | 
app-vue | 
app-nvue | 
Android | 
iOS | 
鸿蒙 | 
| √ | 
√ | 
- | 
- | 
- | 
- | 
7.0 | 
13 | 
- | 
                                                                                                                                                            
| 微信小程序 | 
支付宝小程序 | 
抖音小程序 | 
百度小程序 | 
快手小程序 | 
京东小程序 | 
鸿蒙元服务 | 
QQ小程序 | 
飞书小程序 | 
快应用-华为 | 
快应用-联盟 | 
| - | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                uni-app x
                                                                                                                                                                                                                                    
| Chrome | 
Safari | 
Android | 
iOS | 
鸿蒙 | 
微信小程序 | 
| - | 
- | 
7.0 | 
13 | 
- | 
- | 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                            <!-- @format -->
注意
- 需要 HBuilderX 打包自定义基座 进行调试 (请先点击试用)
 
FFmpegAsync (异步执行 FFmpeg 命令)
用法
import { FFmpegAsync } from "@/uni_modules/rmuu-ffmpeg"
const inFile = plus.io.convertLocalFileSystemURL(videoInfo.src)
const outFile = plus.io.convertLocalFileSystemURL("_doc/" + new Date().getTime() + ".mp4")
FFmpegAsync({
    cmd: `-i ${inFile} -crf 28 ${outFile}`,
    success: (res: object) => {
      console.log("success res", res)
    },
    statistics: (res: object) => {
      console.log("statistics ", res)
    },
  })
参数介绍
| 参数 | 
说明 | 
类型 | 
| cmd | 
FFmpeg 可执行的命令 | 
string | 
| success | 
成功的回调 | 
(res: object) => void | 
| statistics | 
会话的完整回调 | 
(res: Statistics) => void | 
interface Statistics {
  bitrate: number
  sessionId: number
  size: number
  speed: number
  time: number
  videoFps: number
  videoFrameNumber: number
  videoQuality: number
}
ffmpeg 常用命令
- 抽取音频流
 
-i input.mp4 -acodec copy -vn out.aac
- 抽取视频流
 
-i input.mp4 -vcodec copy -an out.h264
- 转格式
 
-i input.mp4 -vcodec copy -acodec copy out.flv
- 音视频合并
 
-i input.h264 -i input.aac -vcodec copy -acodec copy out.mp4
- 截取视频中指定时间的某一帧图片
 
-i input.mp4 -ss 00:00:50 -frames:v 1 out1.jpg
- 添加水印
 
-i input.mp4  -vf "movie=logo.png,scale=64:48[watermask];[in][watermask] overlay=30:10 [out]" out.mp4
注:-vf: movie指定logo位置,scale指定大小overlay指定logo摆放的位置
- 视频裁剪
 
-i input.mov  -vf crop=in_w-200:in_h-200 -c:v libx264 -c:a copy -video_size 1280x720 out.mp4
- 倍速播放
 
-i input.ts -filter:v "setpts=2.0*PTS" output.ts
ffmpeg 文档
getMediaInformation (获取文件的媒体信息)
用法
import { getMediaInformation } from "@/uni_modules/rmuu-ffmpeg"
getMediaInformation(
  res.tempFilePath,
  (info: object) => {
      console.log("info", info)
      //视频大小
      const size = Number(info.jsonObject.nameValuePairs.format.nameValuePairs.size / (1024 * 1024)).toFixed(2)
      //视频时长
      const duration = info.streams[0].jsonObject.nameValuePairs.duration
  },
  (err: string)=>{
    console.log(err)
  }
)
参数介绍
| 参数 | 
说明 | 
类型 | 
| file | 
文件地址 | 
string | 
| success | 
成功的回调 | 
(res: MediaInformation) => void | 
| err | 
失败的回调 | 
(err: string) => void | 
interface MediaInformation{
    jsonObject:{
        nameValuePairs:{
            format:{
                nameValuePairs:object
            },
            streams:{
                values:object[]
            }
        }
    }
    streams:object[]
    chapters:[]
}