fix(rendering): synchronize FPS, implement render locks, respect brand segment duration, and fix local audio path resolving for ffmpeg
This commit is contained in:
@@ -87,8 +87,23 @@ export function getAspectDimensions(aspect: string): { w: number; h: number } {
|
||||
export function getTemplateDuration(
|
||||
template: ExpressTemplate,
|
||||
videoDurations?: Record<string, number>,
|
||||
designMD?: DesignMD,
|
||||
): number {
|
||||
return template.scenes.reduce((sum, scene) => {
|
||||
// If it's a brand segment, read duration from designMD instead of template
|
||||
if (scene.segmentSource === 'brand' && designMD) {
|
||||
if (scene.type === 'intro') {
|
||||
if (!designMD.introVideoUrl) return sum; // Skipped
|
||||
const frames = designMD.introDurationFrames || (scene.durationSeconds * 30);
|
||||
return sum + (frames / 30);
|
||||
}
|
||||
if (scene.type === 'outro') {
|
||||
if (!designMD.outroVideoUrl) return sum; // Skipped
|
||||
const frames = designMD.outroDurationFrames || (scene.durationSeconds * 30);
|
||||
return sum + (frames / 30);
|
||||
}
|
||||
}
|
||||
|
||||
// If we know the actual video duration for this scene, use it
|
||||
if (videoDurations && videoDurations[scene.id]) {
|
||||
return sum + videoDurations[scene.id];
|
||||
@@ -121,10 +136,24 @@ export function compileExpressToTimeline(
|
||||
|
||||
// Process each scene sequentially — the template's scenes are the sole source of truth
|
||||
for (const scene of template.scenes) {
|
||||
// Use actual video duration if available (from useVideoDurations)
|
||||
const sceneDuration = (videoDurations && videoDurations[scene.id])
|
||||
? videoDurations[scene.id]
|
||||
: scene.durationSeconds;
|
||||
// Default to template's duration
|
||||
let sceneDuration = scene.durationSeconds;
|
||||
|
||||
// Override if brand segment
|
||||
if (scene.segmentSource === 'brand' && designMD) {
|
||||
if (scene.type === 'intro') {
|
||||
if (!designMD.introVideoUrl) { sceneDuration = 0; }
|
||||
else { sceneDuration = (designMD.introDurationFrames || (scene.durationSeconds * 30)) / 30; }
|
||||
}
|
||||
if (scene.type === 'outro') {
|
||||
if (!designMD.outroVideoUrl) { sceneDuration = 0; }
|
||||
else { sceneDuration = (designMD.outroDurationFrames || (scene.durationSeconds * 30)) / 30; }
|
||||
}
|
||||
} else if (videoDurations && videoDurations[scene.id]) {
|
||||
// Override if user uploaded video
|
||||
sceneDuration = videoDurations[scene.id];
|
||||
}
|
||||
|
||||
const sceneDurFrames = sceneDuration * fps;
|
||||
const sceneStart = frameOffset;
|
||||
const sceneEnd = frameOffset + sceneDurFrames;
|
||||
|
||||
Reference in New Issue
Block a user