question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

puppeteer-stream is using using the resolution of the screen instead of the resolution of the browser

See original GitHub issue

So puppeteer-stream is recording the video in 1440x900 (The resolution of my screen) instead of 1350x2400 (The resolution of the browser)

The code to record is this:

    browser = await puppeteer_stream.launch(puppeteer, {
        //headless: true,
        executablePath: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
        args: [`--window-size=1350,2400`],
        //args: ["--start-maximized"],
        defaultViewport: null
    })

    page = await browser.newPage()

    await page.setViewport({
        width: 1350,
        height: 2400
    })

    await page.goto("http://localhost:5085/player.html", { waitUntil: "networkidle2" })

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
alvitoraidhycommented, Jun 17, 2022

Hi. I managed to record to a resolution that I desired using this code. Hopefully it helps

const browser = await launch({
  executablePath: RECORD_CHROME_BIN,
  args: [
    "--no-zygote",
    "--no-sandbox",
    "--disable-gpu",
    "--single-process",
    "--headless=chrome",
    "--start-fullscreen",
    "--ignore-certificate-errors",
    "--disable-software-rasterizer",
    `--window-size=${RECORD_CONFIG.width},${RECORD_CONFIG.height}`,
  ],
});

const page = await browser.newPage();

await page.setViewport({ width: 0, height: 0 });
await page.goto(url);

const videoConstraints = {
  mandatory: {
    minWidth: RECORD_CONFIG.width,
    minHeight: RECORD_CONFIG.height,
    maxWidth: RECORD_CONFIG.width,
    maxHeight: RECORD_CONFIG.height,
  },
};

const stream = await getStream(page, {
  audio: true,
  video: true,
  frameSize: 1000,
  // @ts-ignore
  videoConstraints,
});

In my case I set width and height to 1280 and 720.

2reactions
JijaProGamercommented, Jun 30, 2022

(This code has been tested on windows. I dont think it works on linux)

ffmpeg -y -rtbufsize 30M -f gdigrab -thread_queue_size 4096 -probesize 5M -draw_mouse 0 -i title=“Page Tittle - Google Chrome” -vcodec libx264 -preset slow -crf 0 -b:v 5M -pix_fmt rgb24 ./video.mkv

This basically records a application by the name of “Page Tittle - Google Chrome”.

When you open a page, chrome sets the title of the process “Tittle - Google Chrome”. Not sure about chromium and other browsers but it should be similar.

The page should be the one selected for ffmpeg to record. If you switch the page it will still record until closing ffmpeg.

-draw_mouse 0 will not show the mouse and -draw_mouse 1 will show it.

Example with audio (Using VB-Audio Virtual Cable, a audio loopback device. Set Chrome to use it instead of auto-selecting a audio device.):

ffmpeg -y -rtbufsize 30M -f gdigrab -thread_queue_size 4096 -probesize 5M -draw_mouse 0 -i title=“Page Tittle - Google Chrome” -f dshow -thread_queue_size 4096 -itsoffset 0.5 -rtbufsize 30M -i audio=“CABLE Output (VB-Audio Virtual Cable)” -acodec flac -vcodec libx264 -preset slow -crf 0 -b:a 328k -b:v 5M -pix_fmt rgb24 ./video.mkv

If the audio is out of sync change -itsoffset 0.5 to another number

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve difference between Browser Resolution and ...
The problem of difference between Screen and Browser Resolution Starts with devices having width 1600 and above. Actually some browser are ...
Read more >
Screen Resolution ≠ Browser Window | CSS-Tricks
The most popular screen resolution is 1680 x 1050 with almost 13% of visits having a monitor of that size. Predictably, there is...
Read more >
Set the screen resolution in the Web Transaction Recorder
Set the screen resolution in the Web Transaction Recorder. When you record a sequence, the Web Transaction Recorder captures browser dimensions for use...
Read more >
Change desktop screen resolution in Selenium tests
Change desktop screen resolution for Selenium tests using the resolution capability on BrowserStack Automate.
Read more >
Issues · SamuelScheit/puppeteer-stream - GitHub
puppeteer-stream is using using the resolution of the screen instead of the resolution of the browser. #50 opened on Jun 6 by JijaProGamer....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found