getVideoFrames.js icon indicating copy to clipboard operation
getVideoFrames.js copied to clipboard

Is there an easy way to play respecting frame duration ?

Open mpromonet opened this issue 2 years ago • 6 comments

Hi,

Thanks for this, it seems really nice. I was wondering if there an easy way to wait for frame.duration between 2 rendering ?

Best Regards, Michel.

mpromonet avatar Sep 02 '23 10:09 mpromonet

Note that I’m not the creator of this package, but I have been playing the video using requestAnimationFrame that will be called each time the screen refreshes. Using the current time and comparing with the time used to start the video, you can easily compute the current frame to display. Of course, syncing with sound is another question… if you know more about sound sync I’m quite curious.

tobiasBora avatar Sep 19 '23 19:09 tobiasBora

Hi, Thanks. I started from webcodec sample that play at normal speed. Best Regards Michel

mpromonet avatar Sep 21 '23 14:09 mpromonet

Which sample do you use?

tobiasBora avatar Dec 02 '23 15:12 tobiasBora

Hi,

The video player sample https://github.com/w3c/webcodecs/tree/main/samples/video-decode-display. I made some experimentation in https://github.com/mpromonet/gin-tflite/blob/master/static/video.html

Best Regards, Michel.

mpromonet avatar Dec 04 '23 21:12 mpromonet

The example you show just plays at max speed (but I guess we can easily adapt it to wait before two frames), but someone made me realize also that there is https://webcodecs-samples.netlify.app/audio-video-player/audio_video_player.html to play in real time a video with sound. I also played here to create a mini "player" that plays a video in real time here https://leo-colisson.github.io/blenderpoint-web/index_memory_efficient.html?video=https://leo-colisson.github.io/blenderpoint-web/Demo_24fps.mp4 (source code is https://github.com/leo-colisson/blenderpoint-web)

tobiasBora avatar Dec 09 '23 03:12 tobiasBora

There is also this really interesting advises I got here https://github.com/w3c/webcodecs/issues/753

tobiasBora avatar Dec 09 '23 03:12 tobiasBora