有搜索引擎作弊的网站,旅游电子商务的网站建设,温州网站关键词排名,任房保障和城乡建设局网站前言 介绍一下这三种对象使用场景 您前端一旦涉及到文件或图片上传Q到服务器#xff0c;就势必离不了 Blob/File /base64 三种主流的类型它们之间 互转 也成了常态
Blob - FileBlob -Base64Base64 - BlobFile-Base64Base64 _ File
uniapp 上传文件
现在已获取到了blob格式的…前言 介绍一下这三种对象使用场景 您前端一旦涉及到文件或图片上传Q到服务器就势必离不了 Blob/File /base64 三种主流的类型它们之间 互转 也成了常态
Blob - FileBlob -Base64Base64 - BlobFile-Base64Base64 _ File
uniapp 上传文件
现在已获取到了blob格式的视频现在需要把blob文件转换为视频
首先验证blob格式是否能播放
this.videoSrc URL.createObjectURL(blob); // 转换后 用于挂载到视频播放器得转换
console.log(this.videoSrc 》, this.videoSrc); 使用ffmpeg工具转换为MP4文件
去官网下载下载 FFmpeg并配置对应的环境变量
C:\path\to\ffmpeg\bin
即可 ffmpeg -version // 能查看版本信息说明配置成功 使用node.js命令转换 const {execSync} require(child_process) execSync(ffmpeg -i blob test.mp4,{stdio:inherit}) // execSync(ffmpeg -i 1.mp4 1.gif,{stdio:inherit}) 下载到手机相册
uni.downloadFile({url: xxxx/water/app/event_vdo/2024/12/16/34_4_27_20241216_102340_70_0.mp4,success: function (res) {var filePath res.tempFilePath;console.log(filePath,filePath);uni.showToast({icon:none,title:文件下载成功})// 下载成功后调用微信保存图片到系统相册APIuni.saveImageToPhotosAlbum({filePath: filePath,success: function () {console.log(保存成功);},fail: function (err) {console.error(保存失败, err);}});},fail:function(err){console.log(err);}}); FFmpeg 的主要功能和特性
格式转换FFmpeg 可以将一个媒体文件从一种格式转换为另一种格式支持几乎所有常见的音频和视频格式包括 MP4、AVI、MKV、MOV、FLV、MP3、AAC 等。视频处理FFmpeg 可以进行视频编码、解码、裁剪、旋转、缩放、调整帧率、添加水印等操作。你可以使用它来调整视频的分辨率、剪辑和拼接视频片段以及对视频进行各种效果处理。音频处理FFmpeg 可以进行音频编码、解码、剪辑、混音、音量调节等操作。你可以用它来提取音频轨道、剪辑和拼接音频片段以及对音频进行降噪、均衡器等处理。流媒体传输FFmpeg 支持将音视频流实时传输到网络上可以用于实时流媒体服务、直播和视频会议等应用场景。视频处理效率高FFmpeg 是一个高效的工具针对处理大型视频文件和高分辨率视频进行了优化可以在保持良好质量的同时提供较快的处理速度。跨平台支持FFmpeg 可以在多个操作系统上运行包括 Windows、MacOS、Linux 等同时支持多种硬件加速技术如 NVIDIA CUDA 和 Intel Quick Sync Video。
视频转gif const {execSync} require(child_process) execSync(ffmpeg -i test.mp4 test.gif,{stdio:inherit}) 添加水印 const {execSync} require(child_process) execSync(ffmpeg -i test.mp4 -vf drawtexttextXMZS:fontsize30:fontcolorwhite:x10:y10 test2.mp4,{stdio:inherit}) 视频裁剪 控制大小
-ss 起始时间
-to 结束事件 const {execSync} require(child_process) execSync(ffmpeg -ss 10 -to 20 -i test.mp4 test3.mp4,{stdio:inherit}) 提取视频的音频 const {execSync} require(child_process) execSync(ffmpeg -i test.mp4 test.mp3,{stdio:inherit}) 去掉水印 const {execSync} require(child_process) execSync(ffmpeg -i test2.mp4 -vf delogow120:h30:x10:y10 test3.mp4,{stdio:inherit})