josephrocca / getVideoFrames.js

Simple JavaScript library to break a video down into individual frames (uses WebCodecs API and MP4Box.js)
MIT License
39 stars 4 forks source link

Is there an easy way to play respecting frame duration ? #6

Open mpromonet opened 12 months ago

mpromonet commented 12 months ago

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.

tobiasBora commented 11 months ago

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.

mpromonet commented 11 months ago

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

tobiasBora commented 9 months ago

Which sample do you use?

mpromonet commented 9 months ago

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.

tobiasBora commented 8 months ago

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 commented 8 months ago

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