SamuelScheit / puppeteer-stream

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

Using FFmpeg underneath the hood? #31

Closed toshvelaga closed 2 years ago

toshvelaga commented 2 years ago

Hey great library! I am using it for a project as it seems to be the only one I could find that supports both video and audio. My question for you is how does the library work from a 10,000 ft overview. I am guessing it uses FFmpeg underneath the hood to capture the video and audio right? I am writing an article and wanted to mention this library as a good solution to quickly record. Thank you so much!

SamuelScheit commented 2 years ago

It works by making use of the tab recorder api of chrome which is accessible by this puppeteer-stream browser extension, which is loaded on launch. When you want to record a webpage, puppeteer-stream notifies the extension to start recording (with the specified parameters). After that chrome starts capturing the audio and video of the page in a MediaStream, which is then converted into multiple packets using the MediaRecorder Api and transmitted back to puppeteer. You will then receive a webm stream that you can further process. Puppeteer-stream doesn’t use ffmpeg under the hood, but the stream can be passed and converted to ffmpeg (if wanted). Fun fact, you can even record DRM content using the tab recorder api.

Btw. puppeteer-stream is more lightweight than using a window+audio service to record puppeteer windows, however not as lightweight as the devtool startScreencast method, but this method can’t record audio.

toshvelaga commented 2 years ago

Ok awesome thank you so much for this! Appreciate you making this for others to use. Its super neat. Will include this in the article.

SamuelScheit commented 2 years ago

I would love to read the article when you published it 😄

toshvelaga commented 2 years ago

Absolutely, just published it :):

https://medium.com/@toshvelaga/recording-webrtc-with-a-ghost-participant-using-puppeteer-104756e2be40

krupeshanadkat-byjus commented 1 year ago

Great to know its working, I had found that chrome tabCapture api can record audio & video both for the given tab.

I am stuck with drm videos in my use case, puppeteer-stream is not able to record that, it shows blank screen with no audio.

I know disabling chrome hardware acceleration seems to solve this issue, but that causes poor performance of my website.