Skip to content

Instantly share code, notes, and snippets.

@saghul saghul/stream.js
Last active Sep 3, 2017

What would you like to do?
Streaming a webcam to a Jitsi Meet room
const puppeteer = require('puppeteer');
// Streams the first webcam in the system to the specified Jitsi Meet room. Audio is currently
// not sent, but it can be easily enabled by disabling the corresponding setting in `meetArgs`.
// - Detect if we are kicked from the room
// - Support authenticated deployments
// NOTE: only tested on GNU/Linux.
async function main(room, baseUrl='') {
const chromeArgs = [
// Disable sandboxing, gives an error on Linux
// Automatically give permission to use media devices
// Silence all output, just in case
const meetArgs = [
// Disable receiving of video
// Mute our audio
// Don't use simulcast to save resources on the sender (our) side
// No need to process audio levels
// Disable P2P mode due to a bug in Jitsi Meet
const url = `${baseUrl}/${room}#${meetArgs.join('&')}`;
console.log(`Loading ${url}`);
const browser = await puppeteer.launch({ args: chromeArgs, handleSIGINT: false });
const page = await browser.newPage();
// Manual handling on SIGINT to gracefully hangup and exit
process.on('SIGINT', async () => {
await page.evaluate('APP.conference.hangup();');
await page.close();
await page.goto(url);
// Set some friendly display name
await page.evaluate('APP.conference._room.setDisplayName("Streamer");');
main(process.argv[2] || 'test123');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.