Browse Source

feat(Web): 帧计算使用round替代floor & 支持设置帧偏移量

hujinliang 4 years ago
parent
commit
d314961f71
4 changed files with 8 additions and 4 deletions
  1. 4 2
      web/dist/vap.js
  2. 0 0
      web/dist/vap.min.js
  3. 3 1
      web/src/video.ts
  4. 1 1
      web/src/webgl-render-vap.ts

+ 4 - 2
web/dist/vap.js

@@ -1368,7 +1368,9 @@
         // 是否静音播放
         mute: false,
         config: '',
-        accurate: false
+        accurate: false,
+        // 帧偏移, 一般没用, 预留支持问题素材
+        offset: 0
       }, options);
       this.fps = 20;
       this.setBegin = true;
@@ -1912,7 +1914,7 @@
 
         if (this.vapFrameParser) {
           var timePoint = info && info.mediaTime >= 0 ? info.mediaTime : this.video.currentTime;
-          var frame = Math.floor(timePoint * this.options.fps);
+          var frame = Math.round(timePoint * this.options.fps) + this.options.offset;
           var frameData = this.vapFrameParser.getFrame(frame);
           var posArr = [];
 

File diff suppressed because it is too large
+ 0 - 0
web/dist/vap.min.js


+ 3 - 1
web/src/video.ts

@@ -38,7 +38,9 @@ export default class VapVideo {
         // 是否静音播放
         mute: false,
         config: '',
-        accurate: false
+        accurate: false,
+        // 帧偏移, 一般没用, 预留支持问题素材
+        offset: 0,
       },
       options
     );

+ 1 - 1
web/src/webgl-render-vap.ts

@@ -288,7 +288,7 @@ export default class WebglRenderVap extends VapVideo {
     gl.clear(gl.COLOR_BUFFER_BIT);
     if (this.vapFrameParser) {
       const timePoint = (info && info.mediaTime >= 0) ? info.mediaTime : this.video.currentTime
-      const frame = Math.floor(timePoint * this.options.fps);
+      const frame = Math.round(timePoint * this.options.fps) + this.options.offset;
       const frameData = this.vapFrameParser.getFrame(frame);
       let posArr = [];
 

Some files were not shown because too many files changed in this diff