Code Monkey home page Code Monkey logo

Comments (3)

singhprd avatar singhprd commented on September 24, 2024 1

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.

saltlas avatar saltlas commented on September 24, 2024

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:

  1. 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.
  2. 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.
  3. i'm using the open3 gem to run the ffmpeg process. is that alright/desirable or is there a subprocess gem that is preferred?
  4. 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.

saltlas avatar saltlas commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.