VideoDecoder getFrameData 在安卓上视频解码未结束,但是返回 null ?
发布于 6 年前 作者 chou 7715 次浏览 来自 问答

视频地址 https://cdn2.h5no1.com/static-cdn/cpbz/v.mp4

用 wx.downloadFile 下载一个 21 秒的视频,然后使用 VideoDecoder 解码,在安卓上,总是解码到 16 秒的位置就停住了,getFrameData 返回 null

没有触发 ended 事件

没有触发 stop 事件

触发了一次 bufferchange 事件

在 ios 上正常

Page({
  videoSrc: 'https://cdn2.h5no1.com/static-cdn/cpbz/v.mp4',
  vDec: null,
  onReady() {
    this.vDec = wx.createVideoDecoder();
    console.log('开始下载视频文件');
    wx.downloadFile({
      url: this.videoSrc,
      success: res => {
        console.log('下载视频文件完成');
        this.vDec.start({
          source: res.tempFilePath
        });
      }
    });
    this.vDec.on('start', () => {
      console.log('开始解码视频, 24fps');
      this.timer = setInterval(() => {
        const frame = this.vDec.getFrameData();
        if (frame) {
          console.log('frame', frame); // 到 16 秒的时候 就开始返回 null
        }
      }, 1000 / 24);
    });
    this.vDec.on('ended', () => {
      console.log('解码视频结束 ended');
      clearInterval(this.timer);
    });
    this.vDec.on('stop', () => {
      console.log('stop');
    });
    this.vDec.on('bufferchange', () => {
      console.log('bufferchange');
    });
  }
});
1 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部