5

I'm trying to render HTML as a H.264 stream, and then streaming it to another PC on my network.

I've got the last part, streaming to to another PC on my network down. Now my only problem is rendering the webpage.

I can't render it once, because it isn't a static webpage. I need to load the webpage, fetch images, run javascript and open websockets.

The only way I can imagine this working, is if I run a browser (or maybe something like CEF?), and "capture" the output, and render it as H.264

I'm basically trying to do the same as OBS' BrowserSource, but the only reason I'm NOT using OBS, is because I can't find a good way to run it headless.

NOTE: I need to be able to do it through the commandline, completely headless.

MibMoot
  • 51
  • 1
  • 4
  • Have you considered headless Chrome? I haven't tried streaming video, but it seems like something you could get Chrome to do. https://stackoverflow.com/questions/44050259/headless-chrome-capture-screen-video-or-animation – Sidney Jan 19 '18 at 20:08
  • did you check webRTC ? – Redanium Jan 19 '18 at 20:09
  • @Redanium I did not (and have of course now). But I have to stream h.264 via RTC. – MibMoot Jan 19 '18 at 21:33
  • @Sidney Headless Chrome is useless for anything media. Sadly, they've broken it. – Brad Jan 20 '18 at 06:03

1 Answers1

3

I've done this with the Chromium Tab Capture API, and the Off-Screen Tab Capture API.

Chromium will conveniently handle all the rendering, including bringing in WebGL rendered stuff, and composite all together in a nice neat MediaStream for you. From there, you can use it in a WebRTC call or pass off to a MediaRecorder instance.

The off-screen tab capture even has a nice separate isolated process that cannot access local cameras and such.

https://developer.chrome.com/extensions/tabCapture

Brad
  • 159,648
  • 54
  • 349
  • 530