-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (48 loc) · 1.64 KB
/
index.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as puppeteer from 'puppeteer';
import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder';
import * as readline from 'node:readline';
import * as url from 'url';
import process from 'node:process';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const durl = `file://${__dirname}/html`;
const vext = 'mp4'; // supports extension - mp4, avi, webm and mov
const Config = {
followNewTab: true,
fps: 25,
ffmpeg_Path: null, // '<path of ffmpeg_path>' ||
videoFrame: {
width: 1024,
height: 768,
},
videoCrf: 18,
videoCodec: 'libx264',
videoPreset: 'ultrafast',
videoBitrate: 1000,
autopad: {
color: 'black' | '#35A5FF',
},
aspectRatio: '4:3',
recordDurationLimit: 10,
};
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
console.log("Please enter filename:")
rl.on('line', async line => {
console.log("Launching browser...")
const browser = await puppeteer.launch({headless: "new"});
const page = await browser.newPage();
const recorder = new PuppeteerScreenRecorder(page, Config);
await recorder.start(`./report/video/${line}.${vext}`);
await page.goto(`${durl}/${line}`);
let wt = 3000
await new Promise(r => setTimeout(r, wt));
//await page.goto('https://test.com');
await recorder.stop();
console.log("Recorder is stopped")
let tdur = await recorder.getRecordDuration();
console.log(`Duration: ${tdur}`)
await browser.close();
process.exit()
});