壓縮的效果還不錯,36.5M 壓縮成 2.1M,清晰度沒差多少。
wx.chooseVideo(Object object)
拍攝視頻或從手機相冊中選視頻。
sourceType | Array.<string> | ['album', 'camera'] | 否 | 視頻選擇的來源 | |
compressed | boolean | true | 否 | 是否壓縮所選擇的視頻文件 | 1.6.0 |
maxDuration | number | 60 | 否 | 拍攝視頻最長拍攝時間,單位秒 | |
camera | string | 'back' | 否 | 默認拉起的是前置或者後置攝像頭。部分 Android 手機下由於系統 ROM 不支持無法生效 |
代碼:
<button catchtap="click_video" style="height:300rpx;line-height:300rpx">視頻壓縮測試</button>
click_video(){
wx.chooseVideo({
sourceType: ['album','camera'],
maxDuration: 60,
camera: 'back',
success(res) {
console.log(res.tempFilePath)
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success (res) {
console.log(res.errMsg)
}
})
}
})
},