dazzed
dazzed

Reputation: 669

Node puppeteer stream not recording audio

I'm trying to record video and audio using puppeteer stream, but it's getting written only the video to the output file:

async function videoRecorder() {
  require("puppeteer-stream");
  const puppeteer = require("puppeteer");
  const fs = require("fs");

  const filename = `./recordings/test.mp4`;

  const file = fs.createWriteStream(filename);

  const browser = await puppeteer.launch({
    executablePath:
      "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
    headless: true,
    defaultViewport: null,
    devtools: false,
    args: [
      "--window-size=1920,1080",
      "--window-position=1921,0",
      "--autoplay-policy=no-user-gesture-required",
    ],
    ignoreDefaultArgs: ["--mute-audio"],
  });

  const page = await browser.newPage();

  await page.goto(pathToPageWithVideo, {
    waitUntil: "load",
  });

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

  stream.pipe(file);

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

I've tried many other ways of recording video and audio but this is the one I got closer, since my main purpose is to get the audio only, I'm open to more suggestions.

Thanks

Upvotes: 3

Views: 4357

Answers (1)

dazzed
dazzed

Reputation: 669

Solved by saving as .webm instead of .mp4.

Reference: https://github.com/Flam3rboy/puppeteer-stream/issues/1

Upvotes: 2

Related Questions