-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture speed! #23
Comments
Yeah, i'd be very interested to know what we can do to speed things up. I'm running this in a Firebase cloud function, so wondering whether increasing CPU and memory will improve things? |
Can you share some example or tutorial on how to setup this in the firebase cloud or aws lambda? Thanks |
@ahmic @danvoyce It will depend on a few things. Firstly, the speed of what you are rendering will limit the speed. You will also be limited by the speed at which puppeteer can screenshot the page, which can be improved be using jpegs instead of pngs. See https://github.com/tungs/timesnap#cli-options-screenshot-type. |
I ended up doing this completely client side. It's pretty easygoing to setup, and so much better for my use case https://github.com/ffmpegjs/ffmpeg.js |
@danvoyce Did you use that to actually record the browser too? |
Just the canvas. You can see a rough example here https://github.com/ffmpegjs/ffmpeg.js/issues/9 |
So @Asheboy did you tried to switch to jpgs ? did it speed up things ? |
@red1 Yes. If you're still needing it faster, you'll need to investigate what the bottle neck is (CPU, memory or maybe something inside Chrome?). Generally, if you're running on cloud infrastructure, you're not going to be getting the best performance as the resources are shared. |
The solution I'm thinking of is to split the complete process into multiple tasks and run it on AWS Lambda in parallel. Anyone here managed to port this to Lambda? |
@ahmic I've had that thought before and I'm sure it will work as I've seen others have used puppeteer on Lambda. Just bear in mind that the CPU on Lambda instances are not going to be the best. For my use-case, we've ended up going with a dedicated Hetzner server. |
@ahmic Is it even possible to parallel the process? |
There's a similar discussion happening in In theory it's possible to parallelize this, but it's not the intended use and might not be ultimately practical. If you want to pursue this you could use a different Alternatively, you could use If anyone does go this route, I'd be interested in the results, though I don't personally have the time to test this out myself. The bottleneck does seem to be capturing the screenshot, and parallelization should, in theory, bypass that bottleneck. |
@seifsg For my use case, it is possible. I'm recording multiple webpages for 5 seconds, and all generated videos are merging into one (using FFMPEG). If I set it up on the AWS lambda, the total duration for all pages will be like for one page with a current single instance.. |
@tungs I actually tried to implement your suggestion a couple of months ago, however I ended up getting timing issues and ending up with duplicate frames. |
What if there is nothing happening on the page between some actions? My idea is to skip those frames and duplicate then manually because i know the time when nothing is happening. Is there an event on pupeteer to see if nothing is happening on the page just to fast forward the images? at least to run it at normal speed |
Actually I tried canvasCaptureMode and was much faster on recording frames that are stale and only slows down when there is change in the canvas |
Voilà a shell script that splits the rendering into parts of equal duration, starts up multiple Docker containers for rendering simultaneously, and concatenates the output videos when the workers are finished. Maybe it is useful for someone else.
https://gist.github.com/traines-source/378677dd3b360de109d712dbb8205110 |
What's the best config I can follow to make the capture speed fast!
The whole library is awesome but Current capture speed is very slow, it's taking almost 2 minutes to capture a 7-second video, with 30fps.
Thanks in advance
The text was updated successfully, but these errors were encountered: