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

added ability to sync video with capture

Open MatthewRayfield opened this issue 7 years ago • 3 comments

🌻 Addresses https://github.com/spite/ccapture.js/issues/53 🌻

Adds a setting named "syncVideo". If a video element is provided for this setting it is synced with the framerate of the capture using the following method:

  • Video is paused upon capture start, and an event listener is added to video's "seeked" event.
  • On the capture process function the video is advanced by one frame step.
  • When the "seeked" event fires (signaling completion of video frame step) the timeout, interval, requestAnimation, etc. callbacks are called.
  • And the loop continues 💫

🦆 @spite I'll be interested to hear your thoughts 🦆

MatthewRayfield avatar Sep 14 '17 18:09 MatthewRayfield

This looks really good, thanks!

A few ideas to build upon this:

  • syncVideo could be an array of elements, just in case there are more media elements that need to sync up. It does complicate callbacks a bit more, and may be it's not the most usual scenario, but it feels more robust.
  • i guess this also works seamlessly with Audio Elements, so even though the sound won't be captured, it's very cool too. in the future we might have better AV encoding and muxing libraries for the web
  • a small demo showing how it works would be very helpful for everyone looking to integrate this specific solution

Nice work!

spite avatar Sep 15 '17 11:09 spite

Excellent method, works pretty good, however the "ended" listener is not working while capturing, I need to use it to trigger capturer.save(); How can I do it?

Thanks

tonycaso avatar Dec 23 '17 11:12 tonycaso

thank you Matthew!

hulkyuan avatar Feb 28 '22 09:02 hulkyuan