我试了添加图片 并主动加了duration 时长。最终保存出来的视频还是1帧。
我想添加照片并制定时长,请问支持吗?要怎么写呢?
目前的代码如下:
// index.js
// 获取应用实例
const app = getApp()
let mc = wx.createMediaContainer()
Page({
data: {
},
onLoad() {
wx.chooseImage({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success: res => {
console.log(res)
let videoPath = res.tempFilePaths[0]
let mt = mc.extractDataSource({
source:videoPath,
success: function(mt){
console.log(mt)
let videoKind = mt.tracks[0];
videoKind.duration = 18200000
mc.addTrack(videoKind)
//3.导出视频
mc.export({
success: (result) => {
console.log(result)
let tempArr1 = result.tempFilePath.split("//")
wx.saveVideoToPhotosAlbum({
filePath: result.tempFilePath,
success (res) {
console.log(res.errMsg)
},
fail(e){
console.log('保存失败',e)
}
})
mc.removeTrack(videoKind)
}
});
},
fail:function(e){
console.log('extractDataSource错误',e)
}
})
},
fail:function(e){
console.log('chooseVideo 错误',e)
}
})
},
})