收藏
回答

wx.compressVideo压缩功能,IOS测试 视频大小不会被压缩?

组件: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

      }

    })


最后一次编辑于  2020-08-17
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签