SamuelScheit / puppeteer-stream

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

No impact of video configurations on headless browser Kubernetes cluster (linux). #156

Open ArslanMehmoodTkxel opened 2 months ago

ArslanMehmoodTkxel commented 2 months ago

Despite attempting various resolutions, I've observed no improvement in the video quality. Upon using ffmpeg, I encountered the following logs:

frame=80 fps=0.7 q=0.0 size=1536kB time=00:02:07.31 bitrate=98.8kbits/s dup=0 drop=1165 speed=1.04x These logs indicate that the generated video is of low quality.

My configurations are as follows:

const stream = await getStream(page, { 
    audio: true, 
    video: true,
    frameSize: 1000,
    bitsPerSecond: 5000000,
    videoConstraints: {
        mandatory: {
            minWidth: 1920,
            minHeight: 1080,
            maxWidth: 1920,
            maxHeight: 1080,
            minFrameRate: 25,
            maxFrameRate: 25,
        }
    }
});

I am launching chrome with these params

 const browser = await launch({
        defaultViewport: {
          width: 1080,
          height: 1920,
        },
        args: [
          '--no-sandbox',
          '--window-size=1080,1920',
          '--disable-setuid-sandbox',
          '--start-fullscreen',
          `--headless=new`
        ],

        executablePath: executablePath(),
        timeout: THIRTY_MINUTES_DELAY,
        protocolTimeout: THIRTY_MINUTES_DELAY,
      });

Here is the configuration of ffmpeg


const ffmpeg = childProcess.spawn(
        ffmpegPath,
        [ '-y', '-i', '-', '-c:v', 'libx264', '-b:v', '500k', '-c:a', 'copy', file]
    );  

Any suggestions on how to enhance the video quality would be greatly appreciated.

image

Note: I have deployed on Kubernetes cluster the quality was better when i tested this on local machine.

hassanamin994 commented 3 weeks ago

A bit late but try this

const stream = await getStream(page, { frameSize: 1000, videoBitsPerSecond: 7 1000 1000, audioBitsPerSecond: 320 * 1000, mimeType: 'video/webm;codecs=h264,opus', audio: { mandatory: { sampleRate: 44100, }, }, video: { mandatory: { minWidth: WIDTH, minHeight: HEIGHT, minFrameRate: 30, maxWidth: WIDTH, maxHeight: HEIGHT, }, }, });