Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Node.js Puppeteer Project to Record Screen and Save it as MP4 Video File Using FFMPEG Library

Posted on January 30, 2023

 

 

Welcome folks today in this blog post we will be recording screen inside the browser and save it as mp4 video file using ffmpeg library and puppeteer library in command line. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new node.js project using the below command as shown below

 

 

npm init -y

 

 

npm i puppeteer

 

 

npm i puppeteer-screen-recorder

 

 

And after that you need to make a index.js file and copy paste the following code

 

 

index.js

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const puppeteer = require("puppeteer");
const { PuppeteerScreenRecorder } = require("puppeteer-screen-recorder");
(async () => {
  // insitiate puppetter
  const browser = await puppeteer.launch({
    headless: false,
    args: ["--autoplay-policy=no-user-gesture-required"],
  });
  const page = await browser.newPage();
  // record this video file
  const recorder = new PuppeteerScreenRecorder(page);
  await recorder.start("output.mp4");
  await page.goto("https://google.com");
  await page.waitForSelector(
    "body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input"
  );
  await page.type('input[aria-label="Search"]', "Coding Shiksha");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(4000); // 4 seconds
  await page.type('input[aria-label="Search"]', "Programming Tutorials");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(4000); // 4 seconds
  // stop the recording
  await recorder.stop();
  await browser.close();
})();

 

 

As you can see we are importing the puppeteer library and then we are recording the screen and saving it as mp4 video file inside the command line.

 

 

Recent Posts

  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Android Java Project to Download Youtube Video Thumbnail From URL & Save it inside SD Card
  • Android Java Project to Embed Google Maps & Add Markers Using Maps SDK
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme