Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not recording audio #1

Closed
dazzzed opened this issue Jan 17, 2021 · 9 comments
Closed

Not recording audio #1

dazzzed opened this issue Jan 17, 2021 · 9 comments

Comments

@dazzzed
Copy link

dazzzed commented Jan 17, 2021

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);
}
@SamuelScheit
Copy link
Owner

i'll have a look tomorrow

@SamuelScheit
Copy link
Owner

You are writing to a .mp4file however the default format is webm.
Also can you send the pathToPageWithVideo value

@tiagocostafdm
Copy link

@Flam3rboy I've tried with webm and din't work either.
The pathToPageWithVideo I was testing with was https://www.rtp.pt/play/p8157/e518677/telejornal

@SamuelScheit
Copy link
Owner

SamuelScheit commented Jan 19, 2021

also note that chrome doesn't support mimeType video/mp4.
Have a look at the HTML5 MediaRecorder Options

@SamuelScheit
Copy link
Owner

SamuelScheit commented Jan 19, 2021

weirdly enough everything works with video/webm as mimeType and saving it as an .webm file

@tiagocostafdm
Copy link

so you got it to save a file with audio and video by setting the mimeType to video/webm and saving as webm?

@SamuelScheit
Copy link
Owner

yes everything the same

@dazzzed
Copy link
Author

dazzzed commented Jan 19, 2021

@Flam3rboy yes I got it just opened it with another player, thanks.
One more thing, how can I save it as mp3 audio only?

@SamuelScheit
Copy link
Owner

only if the browser supports mp3 just specify the mimeType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants