SamuelScheit / puppeteer-stream

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

Unable to record two browsers simultaneously #109

Closed only77nt closed 1 year ago

only77nt commented 1 year ago

Hello!

I need to simultaneously open several pages (2 or more) using a Puppeteer and record each of them in a separate file by Puppeteer-stream. Scripts (.js files) are supposed to be run separately, but simultaneously.

When I run more than one recording, the files get broken. I began to understand the library code and found that when the getStream(...) function is launched, the index is not taken into account when allocating a port for the UDP stream. Corrected, the necessary audio and video gets into the files, but they still turn out to be broken. When recording for 15 seconds, less gets into the file and the audio plays normally, and the video freezes and slows down.

How can this be fixed?

SamuelScheit commented 1 year ago

This package needs a rewrite for the transmission protocol as it currently uses the deprecated chrome extension UDP api. PR's are welcome 🙌

SamuelScheit commented 1 year ago

you need install the latest version and add an offset to the base port in the getstream method: in browser1:

const stream = await getStream(page, {
    transmission: {
        basePort: 8000,
    },
}

in browser2:

const stream = await getStream(page, {
    transmission: {
        basePort: 9000,
    },
}