-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy path03-video-with-audio.ts
More file actions
45 lines (39 loc) · 931 Bytes
/
Copy path03-video-with-audio.ts
File metadata and controls
45 lines (39 loc) · 931 Bytes
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
/**
* Example 03 — Video with Audio
*
* Video layer and a background music track playing simultaneously. The music
* fades in (non-blocking) while the video starts.
*
* Run:
* npx tsx examples/03-video-with-audio.ts
*/
import VideoFlow from '@videoflow/core';
export function createProject() {
const $ = new VideoFlow({
name: 'Video with Audio',
width: 1920,
height: 1080,
fps: 30,
});
$.addAudio(
{ volume: 1 },
{
source: 'https://videoflow.dev/samples/sample.mp3',
transitionIn: { transition: 'fade', duration: '1s' },
},
);
$.addVideo(
{ fit: 'cover', volume: 1 },
{ source: 'https://videoflow.dev/samples/sample.mp4' },
{ waitFor: 'finish' },
);
return $;
}
if (typeof window === 'undefined') {
await createProject().renderVideo({
outputType: 'file',
output: './03-video-with-audio.mp4',
verbose: true,
});
console.log('Done → examples/03-video-with-audio.mp4');
}