标签:export play class height mic 原创 mda oom san
let mc = wx.createMediaContainer() wx.chooseVideo({ sourceType: [‘album‘, ‘camera‘], maxDuration: 60, camera: ‘back‘, success: res => { let videoPath = res.tempFilePath let mt = mc.extractDataSource({ source:videoPath, success: function(mt){ console.log(mt) let videoKind = mt.tracks[1]; mc.addTrack(videoKind) //3.导出视频 mc.export({ success: (result) => { let tempArr1 = result.tempFilePath.split("//") let tempArr2 = tempArr1[1].split("/") let tempArr3 = tempArr2[tempArr2.length-1].split("."); let tempString2=‘‘ for(let i=0;i<tempArr2.length-1;i++){ tempString2+=tempArr2[i]+"/" } let newPath = tempArr1[0]+"//"+tempString2+new Date().getTime()+"."+tempArr3[1]; //导出新视频的名字每次都是一样的,估计有缓存什么的,我用时间戳重命名新导出的文件 wx.getFileSystemManager().renameSync(result.tempFilePath,newPath) // 4.移除内容,清空容器 console.log(newPath) mc.removeTrack(videoKind) } }); } }) } })
欢迎关注公众号(web学习吧),一起学习进步
选择视频合成 let mc = wx.createMediaContainer()wx.chooseVideo({sourceType: [‘album‘, ‘camera‘],maxDuration: 60,camera: ‘back‘,success: res => {let videoPath = res.tempFilePathlet mt = mc.extractDataSource({source:videoPath,success: function(mt){console.log(mt)let videoKind = mt.tracks[1];mc.addTrack(videoKind)
//3.导出视频mc.export({success: (result) => {let tempArr1 = result.tempFilePath.split("//")let tempArr2 = tempArr1[1].split("/")let tempArr3 = tempArr2[tempArr2.length-1].split(".");let tempString2=‘‘for(let i=0;i<tempArr2.length-1;i++){tempString2+=tempArr2[i]+"/"}let newPath = tempArr1[0]+"//"+tempString2+new Date().getTime()+"."+tempArr3[1];//导出新视频的名字每次都是一样的,估计有缓存什么的,我用时间戳重命名新导出的文件wx.getFileSystemManager().renameSync(result.tempFilePath,newPath)// 4.移除内容,清空容器console.log(newPath)mc.removeTrack(videoKind)}});}})}})123456789101112131415161718192021222324252627282930313233343536欢迎关注公众号(web学习吧),一起学习进步
————————————————版权声明:本文为CSDN博主「qq_34231078」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/qq_34231078/article/details/105453646
标签:export play class height mic 原创 mda oom san
原文地址:https://www.cnblogs.com/sunjianhui/p/12979945.html