ソースを参照

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

hujinliang 4 年 前
コミット
d314961f71
4 ファイル変更8 行追加4 行削除
  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,
         mute: false,
         config: '',
         config: '',
-        accurate: false
+        accurate: false,
+        // 帧偏移, 一般没用, 预留支持问题素材
+        offset: 0
       }, options);
       }, options);
       this.fps = 20;
       this.fps = 20;
       this.setBegin = true;
       this.setBegin = true;
@@ -1912,7 +1914,7 @@
 
 
         if (this.vapFrameParser) {
         if (this.vapFrameParser) {
           var timePoint = info && info.mediaTime >= 0 ? info.mediaTime : this.video.currentTime;
           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 frameData = this.vapFrameParser.getFrame(frame);
           var posArr = [];
           var posArr = [];
 
 

ファイルの差分が大きいため隠しています
+ 0 - 0
web/dist/vap.min.js


+ 3 - 1
web/src/video.ts

@@ -38,7 +38,9 @@ export default class VapVideo {
         // 是否静音播放
         // 是否静音播放
         mute: false,
         mute: false,
         config: '',
         config: '',
-        accurate: false
+        accurate: false,
+        // 帧偏移, 一般没用, 预留支持问题素材
+        offset: 0,
       },
       },
       options
       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);
     gl.clear(gl.COLOR_BUFFER_BIT);
     if (this.vapFrameParser) {
     if (this.vapFrameParser) {
       const timePoint = (info && info.mediaTime >= 0) ? info.mediaTime : this.video.currentTime
       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);
       const frameData = this.vapFrameParser.getFrame(frame);
       let posArr = [];
       let posArr = [];
 
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません