sergueik / selenium_cdp

Selenium 4x, executing Chrome DevTools Protocol commands
MIT License
50 stars 15 forks source link

use CDP screencast API to record mp4 videos #4

Open nirtal85 opened 1 year ago

nirtal85 commented 1 year ago

Currently, there is no real option without complex scripts to record in headless mode CDP provides screencast API selenium already implemented but does not use it (and no guides on using it) frameworks like cypress puppeteer and playwright use it already.

start screen cast devTools.send(Page.startScreencast(Optional.of(Page.StartScreencastFormat.JPEG), Optional.of(100), Optional.of(1920), Optional.of(1080), Optional.of(1))); stop screencast devTools.send(Page.stopScreencast()) and an event listener which receives the raw data (which are the frames)

https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-startScreencast https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-stopScreencast

can you please add an example how to use it to generate mp4?

sergueik commented 1 year ago

Hello Nir

The creation of the movie from frames is outside of Selenium CDP scope. There must be solitions for that.

To collect frames is easy with CDP: see commit https://github.com/sergueik/selenium_cdp/commit/99e16ef6a731955aa8a66499e575f8883774bb70

it implemets the test which collects the screencast frames Thanks

Serguei Kouzmine

 On Monday, February 6, 2023, 02:56:25 PM EST, Nir Tal ***@***.***> wrote:  

Currently, there is no real option without complex scripts to record in headless mode CDP provides screencast API selenium already implemented but does not use it (and no guides on using it) frameworks like cypress puppeteer and playwright use it already.

start screen cast devTools.send(Page.startScreencast(Optional.of(Page.StartScreencastFormat.JPEG), Optional.of(100), Optional.of(1920), Optional.of(1080), Optional.of(1))); stop screencast devTools.send(Page.stopScreencast()) and an event listener which receives the raw data (which are the frames)

https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-startScreencast https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-stopScreencast

can you please add an example how to use it to generate mp4?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

nirtal85 commented 1 year ago

thank you very much!