Skip to content

Instantly share code, notes, and snippets.

@dtony
Last active December 8, 2023 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtony/5ecbff663f6da3ff2aa67dda63422ad2 to your computer and use it in GitHub Desktop.
Save dtony/5ecbff663f6da3ff2aa67dda63422ad2 to your computer and use it in GitHub Desktop.
Headless jitsi meet on Raspberry pi
const puppeteer = require('puppeteer-core');
const readline = require('readline-sync');
// 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`.
//
// TODO
// - Detect end of call to gracefully exit
// - Send button press notification using Signal, Telegram...
//
// NOTE: only tested on GNU/Linux.
async function main(room, baseUrl='https://meet.jit.si') {
const chromeArgs = [
// Disable sandboxing, gives an error on Linux
'--no-sandbox',
'--disable-setuid-sandbox',
// Automatically give permission to use media devices
'--use-fake-ui-for-media-stream',
// You may need to play with these options to get proper input and output
//'--alsa-output-device=plug:hw:0,1'
'--alsa-input-device=plug:hw:1',
];
const meetArgs = [
// Disable receiving of video
'config.channelLastN=0',
// Unmute our audio
'config.startWithAudioMuted=false',
// Don't use simulcast to save resources on the sender (our) side
'config.disableSimulcast=true',
// Disable P2P mode due to a bug in Jitsi Meet
'config.p2p.enabled=false',
// Disable prejoin page
'config.prejoinPageEnabled=false'
];
const url = `${baseUrl}/${room}#${meetArgs.join('&')}`;
console.log(`Loading ${url}`);
const browser = await puppeteer.launch({
args: chromeArgs,
handleSIGINT: false,
executablePath: '/usr/bin/chromium-browser',
ignoreDefaultArgs: ['--mute-audio'],
});
const page = await browser.newPage();
// Manual handling on SIGINT to gracefully hangup and exit
process.on('SIGINT', async () => {
console.log('Exiting...');
await page.evaluate('APP.conference.hangup();');
await page.close();
browser.close();
console.log('Done!');
process.exit();
});
await page.goto(url);
// Set some friendly display name
await page.evaluate('APP.conference.changeLocalDisplayName("Doorbell");');
console.log('Running...');
}
main(process.argv[2] || 'VideoDoorbellTest');
@maglub
Copy link

maglub commented Dec 8, 2023

Hey, thanks for this addition to https://code.saghul.net/tag/headless/ and https://gist.github.com/saghul/179feba3df9f12ddf316decd0181b03e, as it got me on to the right track concerning the prejoin page.

Your take:

        // Disable prejoin page
        'config.prejoinPageEnabled=false'

Newer jitsi implementations have changed this, so this is what you need nowadays:

        'config.prejoinConfig.enabled=false'

Have a nice day!
//magnus

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