Comments (3)
Hey - I'm not a maintainer here, or have any existing knowledge of how to do this, but I wondered if you could take some inspiration from Puppeteer - I see this library does what you're looking for:
https://github.com/prasanaworld/puppeteer-screen-recorder
So that might give a start for the CDP commands needed to do this:
https://github.com/prasanaworld/puppeteer-screen-recorder/blob/main/src/lib/pageVideoStreamCollector.ts#L55
Good luck, this would be a very nice feature especially for looking at flakey tests! 🚀
PS It would be great if you could share your code!
from ferrum.
just an update on this - i've gotten this sort-of-almost working (it's creating .mp4 videos from jpegs but they're like 4 frames, but a success is a success) but i have some stuff to work out before i can call it actually working, would appreciate some guidance if you have any insight:
- as far as i can see the definitions for handling events (
on(event)
) are primarily in page.rb and there are none in browser.rb. i might be missing something that's leading me to misunderstand the code, though. anyway, screencasting would probably be per-browser, i assume, not per-page, unless pages stay alive for as long as the browser does. how would i implement the event handling for the browser? i'm currently defining it on the page. - the whole screencasting shebang needs to run in the background (i.e. sending back frame acknowledgements, adding new frames to the video file, etc.) while the browser is doing its thing, but it needs to run somewhat consistently and not whenever it feels like it. i've got a little bit of experience with dealing with threads/concurrency/asynchronous methods, but not a lot of it. what's the best way to get this to run in the background? it's also especially important that all of the frames finish being added before the call to close the ffmpeg subprocess goes through - is there a good way to check that if the adding of the frames is handled asynchronously? i know there's Concurrent::Async#wait but i'm not calling the frame adding method from the method that stops the screencasting... anyway i'm probably spouting confused nonsense since i'm not that experienced with that stuff.
- i'm using the open3 gem to run the ffmpeg process. is that alright/desirable or is there a subprocess gem that is preferred?
- on that same note, i'm feeding the images directly into ffmpeg without saving them to disk to prevent a bunch of useless disk space clutter, but if it would be better to save them to disk rather than have the open3 subprocess running in the background (to keep the ffmpeg pipe open as i feed it more frames) do advise
just a note: all good if this functionality is not actually something you want implemented in this gem for whatever reason! guidance would still be appreciated just to help me implement it locally for myself :). as far as i can tell, selenium doesn't have screen recording, https://github.com/kapoorlakshya/screen-recorder only has headless window screen recording for linux systems (as it relies on xvfb for it), and there's an additional library for puppeteer that someone made that you can add that only works in headful mode. point is, a cross-platform headless screen recording feature doesn't really exist, and it'd be useful.
from ferrum.
that's a good idea @singhprd , i dismissed that library out of hand bc it only works in headful mode but youre right that it uses the same cdp tool so i should have a look. thanks!
in terms of sharing code, anything i do gets pushed to https://github.com/saltlas/ferrum/tree/screencast , if you want to look, but be warned that at the moment it is Very Bad, i'm just trying to get a very basic working product before i make it pretty so it's fugly. at the moment it generates very short videos of a few frames but only when run without calling the stop_screencast method, which is... bad? but anyway, you're free to have a look and keep an eye on it. i've stopped working on it for now because i got a bit roadblocked with the concurrency issues and all the stuff i asked about here, but looking at the puppeteer library might help
from ferrum.
Related Issues (20)
- Send Emulation commands to Page HOT 1
- Ferrum::BinaryNotFoundError when using docker for chrome HOT 1
- Can I allow Page.go_to take additional wait parameter?
- Cannot call `exit` from within `.on()` blocks HOT 2
- Exceptions within `.on()` blocks are mysteriously ignored HOT 1
- Browser start fails with JRuby on Windows
- Chrome error: "Unable to create temporary file" on Windows with JRuby HOT 1
- Errno::ECONNREFUSED on browser initialization HOT 3
- Headless new gives Ferrum::NoSuchPageError on screenshot HOT 2
- consider using === in network blacklist matching
- Doesn't work on ruby 3.2 HOT 1
- Saving via browser.mhtml and via cmd+S differs a lot on Youtube HOT 3
- Network.loadingFailed error preventing file from downloading HOT 13
- Conditionally Render Page header and footer template HOT 2
- browser.quit doesn't close session HOT 7
- Include type and stackTrace in logging for console API
- `wait_for_network_idle` failing due to pending requests on previous page HOT 1
- Remove `disable-gpu`default flag for Apple Silicon HOT 3
- authenticate current_user in ferrum browser
- Hang/Timeout in dialog HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ferrum.