SamuelScheit / puppeteer-stream

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

[Question] How can you specify the quality of video? #63

Closed antoniott15 closed 1 year ago

antoniott15 commented 1 year ago

are the options

    audioBitsPerSecond
    videoBitsPerSecond
    bitsPerSecond
    frameSize

the things that manage video quality? what do I need to choose if I want 4k or 1080p? also, does frame size specify the frame rate? like 60fps?

SamuelScheit commented 1 year ago

These options are quality options for encoding: https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/MediaRecorder To change the resolution pass the videoConstraints option

videoConstraints: {
        mandatory: {
            minWidth: 1920,
            minHeight: 1080,
            minFrameRate: 60
        }
    }

and change the page viewport:

await page.setViewport({
    width: 1920,
    height: 1080
})
antoniott15 commented 1 year ago

I'm on version 2.1.1 of puppeteer-stream, and I don't see an option called videoConstraints, where should I put it?

SamuelScheit commented 1 year ago

you can specify them for audio/video in the getStream options:

getStream(page, {
    video: {
        mandatory: {
            minWidth: 1920,
            minHeight: 1080,
            minFrameRate: 60
        }
    }
})