Skip to content
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

CDPによるスクリーンショットの高速化 #46

Open
windymelt opened this issue May 16, 2023 · 3 comments
Open

CDPによるスクリーンショットの高速化 #46

windymelt opened this issue May 16, 2023 · 3 comments

Comments

@windymelt
Copy link
Owner

前提

  • Chromiumのバージョンアップによって、スクリーンショットで透明背景撮影などが可能になった(正確には、画面サイズがぶっ壊れていたのが直った)
  • ところが、Mutexがかかって同時に複数のChromiumを起動できなくなった
    • これまでは複数プロセスをある程度並行起動してスクリーンショットを撮影させていた
  • 以前はそこまででもなかったが、ヘッドレスシステムが作り替えられた影響で、直列実行するととても遅い
    • 1枚1秒以上かかる
  • このままだとまともに動画を作れない

手法

  • Chromiumをheadlessモードで起動して、debug portを指定するとCDP(Chromium DevTools Protocol)を受け付けるサーバが建ってlistenするようになる
  • そこにファイル表示とスクショのコマンドを流し込めばオーバーヘッドを大幅に節約できるはず

問題

  • CDPがどういうプロトコルか不明
  • npmモジュールでしか高級なI/Fが用意されていない
  • nodeをわざわざ入れたくない
  • スクショだけやれるような感じでハードコード可能かも不明

やること

  • CDPの解析
  • Scalaでなんとか動かす手法がないか考える
  • 実装して高速にスクショを撮る
@windymelt
Copy link
Owner Author

Chrome DevTools Protocol

@windymelt
Copy link
Owner Author

https://chromedevtools.github.io/devtools-protocol/tot/HeadlessExperimental/ によれば、割とサクッと書けそうだ

@windymelt
Copy link
Owner Author

https://github.com/windymelt/cdp-scala おおむねスクショまわりをCDPで実装できた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant