小程序視頻壓縮並且設置視頻時長

壓縮的效果還不錯,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)
          }
        })
      }
    })
  },

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章