SamuelScheit / puppeteer-stream

A Library for puppeteer to retrieve audio and/or video streams
MIT License
333 stars 105 forks source link

Puppeteer stream to record zoom calls #84

Open ricardowiseverge opened 1 year ago

ricardowiseverge commented 1 year ago

Hello,

I'm trying to record a zoom call using puppeteer-stream. The thing is after entering in the call puppeteer is not able to save the audio and only the video of the call.

What is the configuration issue?

I've tested the same code with an youtube video and it works.

CODE:

import { launch, getStream } from "puppeteer-stream";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const file = fs.createWriteStream(__dirname + "/test.webm");

async function test(meeting_url) {
  const zoomUrl = createZoomWebUrl(meeting_url);

  const browser = await launch({
    ignoreDefaultArgs: ["--mute-audio"],
    defaultViewport: {
      width: 1920,
      height: 1080,
    },
    channel: "chrome",
  });

  const page = await browser.newPage();
  await page.setRequestInterception(true);
  page.on("request", (request) => {
    if (request.url().endsWith(".exe")) request.abort();
    else request.continue();
  });
  await page.goto(zoomUrl);
  await page.waitForSelector("#onetrust-reject-all-handler");
  await page.click("#onetrust-reject-all-handler");

  await page.waitForTimeout(500);

  await page.waitForSelector("#wc_agree1");
  await page.click("#wc_agree1");

  await page.waitForTimeout(500);

  await page.waitForSelector("#inputname");
  await page.click("#inputname");
  await page.type("#inputname", "bot");
  await page.waitForTimeout(500);

  await page.waitForSelector("#joinBtn");
  await page.click("#joinBtn");
  await page.waitForTimeout(500);

  await page.waitForSelector("#root > div > div.preview > button");
  await page.click("#root > div > div.preview > button");
  await page.waitForTimeout(500);

  const stream = await getStream(page, { audio: true, video: true });
  console.log("recording");

  stream.pipe(file);
  setTimeout(async () => {
    await stream.destroy();
    file.close();
    console.log("finished");
    page.close();
  }, 10000 * 10);
}

const createZoomWebUrl = (invite_url) => {
  const regex = /(?<=j\/).*/;
  return "https://zoom.us/wc/join/" + invite_url.match(regex);
};

test(YOUR_ZOOM_INVITE_LINK);

Best regards,

Harsh4999 commented 1 year ago

Same issue I am facing did you find any solution?

bdegomme commented 6 months ago

I had the same issue, the solution was to add '--autoplay-policy=no-user-gesture-required' to the puppeteer args (and actually joining the audio of the meeting)

davidgu commented 2 months ago

If you didn’t want to deal with the complexities of implementing this yourself, an alternative is to use Recall.ai for your meeting bots instead. It’s a simple 3rd party API that lets you use meeting bots to get raw audio/video from meetings without you needing to spend months to build, scale and maintain these bots.

Disclaimer: I’m one of the founders.