Skip to content

Instantly share code, notes, and snippets.

@jedi4ever
Last active February 12, 2024 09:11
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save jedi4ever/30eaf96d29f92da42ff5b79db06af125 to your computer and use it in GitHub Desktop.
Save jedi4ever/30eaf96d29f92da42ff5b79db06af125 to your computer and use it in GitHub Desktop.

These are notes while researching a way to convert a browser/website to a stream. This could be used for Facebook Live or for webrecording. TL'DR:

  • I started with Phantomjs - but that didn't support the html5 video tag
  • SlimerJS supports it, but there is no way to record audio directly (though this might come from desktop audio)
  • So I moved to research ffmpeg/X11/XVFB to record it with linux which works
  • But ffmpeg has no easy way to mix streams/overlays to I moved on to OBS with overlay browser support
  • I started researching options OBS in docker and it needed best a GPU , so I move to nvidia-docker
  • And so came across building game servers on EC2/AWS using GPUs and managed to run OBS inside of GPU g2x.large machine
  • I tried streaming to twich , which works great and managed to restream 4K 60FPS youtube on an AWS instance
  • Remote control works through OBS-Remote but OBS has kinda limit in types of features
  • Xsplit (some JS automation), Wirecast (no automation found, besides keypresses) , Livestream.com (non-scriptable) and found Vmix.com which an API (but costs 799$)
  • For Overlaying systems , nodeCG looks nice
  • Sending RTMP to FBlive and periscope works fine
  • Looked into redundancy for RTMP as FBLive ends the post/stream when the stream ends (options are ffmpeg UDP switch over and zencode RTMP ping)
  • For CDN still looking livestream.com vs Cloudfront/Fastly with their HLS setup
  • Possibly use restream.io to send it to multiple feeds.

To be continued.

Phantomjs:

Slimerjs:

XVFB linux recording:

Docker/X11/GPU:

Setup windows EC2/GPU/OBS:

Setup linux/GPU:

OBS:

Controlling OBS from remote:

Overlay systems:

Livestream control:

Xsplit control:

Vmix Scripting:

CDN:

RTMP:

@danielgormly
Copy link

Ah sorry I ended up just compositing locally with OBS and built a backend to direct which stream key goes to which live event in Youtube. I think if I approached the same problem now, I'd look at trying to composite it in a headless browser with GPU backed rendering like https://dev.to/ingun37/running-gpu-accelerated-webgl-application-in-headless-chrome-in-ec2-446f and then work out how to stream the output.

I'd go Websockets or a customer UDP backed implementation to direct the state of the graphics.

I'd probably avoid containerising them in the the proof of concept stage as it would be an extra headache. Then look at something like Nomad for scaling them.

Anyway good luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment