forked from Vinlic/WebVideoCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-video.js
43 lines (41 loc) · 1.06 KB
/
single-video.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
/**
* 单幕视频合成示例
*
* 调用代码:
* import { examples, VIDEO_ENCODER } from "web-video-creator";
* await examples.singleVideo({
* url: "http://localhost:8080/test.html",
* width: 1280,
* height: 720,
* fps: 30,
* duration: 10000,
* videoEncoder: VIDEO_ENCODER.NVIDIA.H264, // 根据您的硬件设备选择适合的编码器
* outputPath: "./test.mp4"
* });
*/
import WebVideoCreator, { logger } from "../index.js";
export default async ({
url,
width,
height,
fps,
duration,
videoEncoder,
outputPath
}) => {
const wvc = new WebVideoCreator();
wvc.config({
mp4Encoder: videoEncoder
});
const video = wvc.createSingleVideo({
url,
width,
height,
fps,
duration,
outputPath,
showProgress: true
});
video.once("completed", result => logger.success(`Render Completed!!!\nvideo duration: ${Math.floor(result.duration / 1000)}s\ntakes: ${Math.floor(result.takes / 1000)}s\nRTF: ${result.rtf}`));
video.start();
}