microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.58k stars 3.57k forks source link

[Question] Video Stream #4263

Closed nor0x closed 3 years ago

nor0x commented 3 years ago

I'm pretty sure it's not the intended behavior of the newly added video features and IVideo, but would it be possible to retrieve a live video stream from a headless browser context, similar to continuous calls to page.ScreenshotAsync.

As far as I understood the new video feature, it's for recording and saving it afterwards?

kblok commented 3 years ago

Hey @nor0x can you share a use case for that?

nor0x commented 3 years ago

in my specific usecase i would want to display a (in the best case live) feed of browser pages. A headful browser is not an option in my case because the view is rendered manually on various platforms

kblok commented 3 years ago

cc @arjunattam

arjunattam commented 3 years ago

Thanks for this @nor0x. Yes, the video feature is built to record and save a file. We could consider providing it as a stream. Does your scenario require cross-browser support? If not, we could explore a Chromium-only workaround to support this scenario.

I will move this issue to the main playwright repo, since this is an upstream change. We could use this issue to collect more feedback on this request.

nor0x commented 3 years ago

thanks for the reply @arjunattam - currently Chromium-only would be very fine. Do you have a hint at what code to look at?

atemiz commented 3 years ago

I think eliminating the delays (currently min 100ms) between ScreencastFrame events might be useful.

https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-screencastFrame

nor0x commented 3 years ago

@atemiz good idea, i didn't know that there are 100ms between ScreencastFrame events. Just to make sure i get this right - these 100ms are in Chromium or playwright?

atemiz commented 3 years ago

@nor0x Chromium; https://chromium.googlesource.com/chromium/src/+/refs/heads/master/content/browser/devtools/devtools_video_consumer.cc

pavelfeldman commented 3 years ago

Note that non-Chromium do not have this limitation and stream into vp8.

pavelfeldman commented 3 years ago

@atemiz: thanks for the pointer, I removed the limitation upstream: https://chromium-review.googlesource.com/c/chromium/src/+/2546475, I believe that was a regression. We are still dropping frames based on the backpressure, but it should not be as bad as it used to be.

nor0x commented 3 years ago

thanks for the update @pavelfeldman i will see how i can use this

nor0x commented 3 years ago

Hey @pavelfeldman, another (maybe stupid) question. Chromium uses Skia for rendering, right? If i wanted to get a snapshot or preview of the current browser content, do i always have to go through snapshotting - even if i use Skia for rendering the content on my side (currently as images)

dgozman commented 3 years ago

@nor0x In theory it is possible to expose some other format representing the content being drawn (DisplayList? Maybe even Skia commands list?), but that's not the usecase Playwright focuses on.

nor0x commented 3 years ago

@dgozman alright got it! thanks

pavelfeldman commented 3 years ago

Thank you for reporting this issue and providing comments to those that might be facing a similar problem. I am now closing this as a part of the triage, please feel free to file a new issue with additional details. Given the limited resource and a lot of requests, we need to fulfill most popular requests and at the same time keep our issue database manageable.

jfloodnet commented 3 weeks ago

@nor0x I have a similar use case, did you get something working?