Skip to content

Instantly share code, notes, and snippets.

@toshvelaga
Created January 17, 2022 03:22
Show Gist options
  • Select an option

  • Save toshvelaga/d9323a2286e0464ad29fa34dea4f8f9b to your computer and use it in GitHub Desktop.

Select an option

Save toshvelaga/d9323a2286e0464ad29fa34dea4f8f9b to your computer and use it in GitHub Desktop.
puppeteerStream.js
const { launch, getStream } = require('puppeteer-stream')
const fs = require('fs')
// node arguments are present from the third position going forward.
const args = process.argv.slice(2)
const file = fs.createWriteStream(`./reports/videos/${args[0]}.mp4`)
async function puppeteerStream() {
const browser = await launch()
const page = await browser.newPage()
await page.goto('https://video-meeting-socket.herokuapp.com/room')
await page.waitForSelector('button')
await page.click('button')
// records audio and video
const stream = await getStream(page, { audio: true, video: true })
stream.pipe(file)
await page.waitForTimeout(8000)
await stream.destroy()
await browser.close()
file.close()
}
puppeteerStream()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment