组件:wx.compressVideo
基础库:2.12.0
IOS版本:iphone8 13.3.1
测试过程及结果:
wx.chooseVideo({
sourceType: ['album'],
compressed: false,
success(res) {
var aaa = res.tempFilePath
console.log('选择视频')
console.log('tempFilePath', res.tempFilePath)
console.log('duration', res.duration)
console.log('size', (res.size) / 1024)
console.log('height', res.height)
console.log('width', res.width)
var res_width = res.width
// if (max_height > 960) {
if (res_width > 544) {
wx.showLoading({
title: '压缩中,请稍等..',
mask: true
})
// if (max_height > 2560) {
if (res_width > 1080) {
console.log('压缩low')
var quality = 'low'
// } else if (max_height > 1280) {
} else if (res_width > 720) {
console.log('压缩medium')
var quality = 'medium'
} else {
console.log('压缩high')
var quality = 'high'
}
wx.compressVideo({
src: aaa,
quality: quality,
// bitrate: 1032,
// fps: 24,
// resolution:0.5,
success(res) {
var bbb = res.tempFilePath
console.log('压缩返回')
console.log('tempFilePath', res.tempFilePath)
console.log('size', res.size)
// //保存本地
// wx.saveVideoToPhotosAlbum({
// filePath: res.tempFilePath,
// success(res) {
// console.log(res.errMsg)
// }
// })
wx.getVideoInfo({
src: bbb,
success(res) {
wx.hideLoading()
console.log('duration::', res.duration)
console.log('size::', res.size)
console.log('heigh::', res.height)
console.log('width::', res.width)
console.log('fps::', res.fps)
console.log('bitrate::', res.bitrate)
}
})
},
fail(err) {
wx.hideLoading()
console.log("压缩失败")
}
})
} else {
console.log('不压缩')
}
return
}
})
你好,这个需要使用真机调试,然后你的代码片段我试了 正常的。
https://developers.weixin.qq.com/s/5yLvNFmr7Mjs
测试代码:https://developers.weixin.qq.com/s/OJKJuFmZ7xjz