resolveAudioMix function
ResolvedAudioMix
resolveAudioMix({
- required Video video,
- required int fps,
- int totalFrames = 0,
- GenerativeResolver? generative,
Resolves video's declared Audio tracks into an encoder-neutral
ResolvedAudioMix for a non-FFmpeg encoder (such as fluvie_mobile_encoder).
It collects the tracks in deterministic declaration order and resolves every
track's delay, trim, gain, and fades against fps and the totalFrames
window — the same timing math the FFmpeg mix uses, so an on-device render
matches a desktop render. Pure and synchronous: it reads no files, so each
track keeps its authored ResolvedAudioTrack.source; the custom encoder
materializes those sources itself. The default render path never calls this;
it is the opt-in seam for custom encoders. A video with no audio yields an
empty mix.
Implementation
ResolvedAudioMix resolveAudioMix({
required Video video,
required int fps,
int totalFrames = 0,
GenerativeResolver? generative,
}) {
final scope = TimeScopeData(fps: fps, startFrame: 0, durationFrames: totalFrames);
final tracks = <ResolvedAudioTrack>[
for (final track in collectAudioTracks(video, generative: generative))
resolveAudioTrack(track, fps: fps, scope: scope),
// A clip's embedded audio (including a generated video's, for example Veo 3)
// plays where the clip plays: delayed to its scene start and trimmed to the
// scene window (so sequential clips don't bleed).
for (final plan in collectClipAudioPlans(video.scenes, fps, generative: generative))
_clipAudioTrack(plan, fps, scope),
];
return ResolvedAudioMix(tracks: tracks);
}