HTML5 frame-by-frame viewing / frame-seeking?

后端 未结 3 1867
Happy的楠姐
Happy的楠姐 2020-12-12 12:53

I\'m looking for a way to view HTML5 , frame-by-frame.

The scenario: Having a video, with an additional button that skips to the next frame

3条回答
  •  囚心锁ツ
    2020-12-12 13:18

    Having just been fighting this very same problem I cam up with a brute force method to find the frame rate.Knowing that the frame rate will never pass 60 frames a second I seek through the video at 1/60th second steps. Comparing each frame to the last by putting the video onto a canvas element and then using getImageData to get pixel data. I do this over a second of video and then count up the total number of unique frames to get the frame rate.

    You do not have to check every single pixel. I Grab about 2/3rds of the inside of the video and then check about every 8th pixel across and down (depending on the size). You can stop the compare with just a single pixel different so this method in reasonably fast and reliable, well not compared to say reading a frameRate property, but better than guessing.

提交回复
热议问题