SamuelScheit / puppeteer-stream

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

It stops streaming after 1h10, or/and after reaching 400mb #81

Closed romain130492 closed 1 year ago

romain130492 commented 1 year ago

Hey

I have been using that example to pipe the stream to ffmpeg and convert it to a mp4. Im also using it in headless mode using:

 args: ["--headless=chrome" ],
      headless: this.isHeadless,

It works well, however, as soon as it reaches 400mb (around 1hour 16min), the mediaRecorder seems to stop. I don't see any chunks from the ffmpeg listeners anymore.

I can see here that chrome limits the blob to be at 500mb https://stackoverflow.com/questions/28307789/is-there-any-limitation-on-javascript-max-blob-size, it might be why?

Do you have any idea about this by any chance? @Flam3rboy

SamuelScheit commented 1 year ago

The media recorder has an option frameSize, which specifies how often the media recorder produces a blob. Chrome's default is 0, which means it produces one big blob, after the recording stop. The extension overwrites the default with 20ms, if nothing else is specified. You can overwrite the default by specifying frameSize in the getStream options:

getStream(page, { frameSize: 1000 }

But this shouldn't be related to your issue as by default the frameSize is 20ms which definitely produces blobs smaller than 500mb.

romain130492 commented 1 year ago

The media recorder has an option frameSize, which specifies how often the media recorder produces a blob. Chrome's default is 0, which means it produces one big blob, after the recording stop. The extension overwrites the default with 20ms, if nothing else is specified. You can overwrite the default by specifying frameSize in the getStream options:

getStream(page, { frameSize: 1000 }

But this shouldn't be related to your issue as by default the frameSize is 20ms which definitely produces blobs smaller than 500mb.

Thanks for answering so quickly;)

I actually already set-up the frameSize to 25

   this.stream = await getStream(this.page, {
        audio: true,
        video: true,
        frameSize: 25,
        mimeType: "video/webm;codecs=vp8",
        audioBitsPerSecond: 128000,
        videoBitsPerSecond: 2500000,
        videoConstraints: {
          mandatory: {
            minWidth: 1920,
            minHeight: 1080,
            maxWidth: 1920,
            maxHeight: 1080,
          },
        },
      });

so on your side, you were able to record your screen for more than 1h without any issues,? using ffmpeg pipeline