Video with audio
Mix a video layer and a ducking music track.
// Video on a music bed: the audio track fades in alongside the video.
// Demonstrates `addAudio`, `addVideo`, audio `transitionIn: 'fade'` (which
// targets `volume` on auditory layers), and `waitFor: 'finish'`.
const $ = new VideoFlow({
name: 'Video with Audio',
width: 1920,
height: 1080,
fps: 30,
});
// Audio layer — `transitionIn: 'fade'` ramps `volume` from 0 → its set value.
const music = $.addAudio(
{ },
{
source: 'https://videoflow.dev/samples/sample.mp3',
transitionIn: { transition: 'fade', duration: '1s' },
},
);
// `waitFor: 'finish'` makes the outer flow wait for the clip's full source
// duration before moving on — auto-detected from the file when omitted.
const video = $.addVideo(
{ fit: 'cover', volume: 1 },
{ source: 'https://videoflow.dev/samples/sample.mp4' },
{ waitFor: 'finish' },
);
return $;