fix: dynamic video duration across ProductionForm + LivePreviewCanvas

- Expanded useVideoDurations to detect both form-sourced segments AND
  editable-slot video fields inside content scenes
- Wired videoDurations into ProductionForm (getTemplateDuration,
  compileExpressToTimeline, LivePreviewCanvas, ExportModal)
- LivePreviewCanvas now accepts videoDurations prop
- Simplified getTemplateDuration/compiler: any scene with a known
  video duration uses it, regardless of segmentSource type
- A 33s uploaded video now creates a 33s timeline, not 5s
This commit is contained in:
2026-06-02 09:58:37 -05:00
parent a21675e5fc
commit 560a413c1e
4 changed files with 73 additions and 36 deletions
+5 -5
View File
@@ -82,15 +82,15 @@ export function getAspectDimensions(aspect: string): { w: number; h: number } {
* Compute total duration of template in seconds.
* @param videoDurations Optional map of scene.id → actual video duration (seconds).
* When provided, overrides the static durationSeconds for scenes
* that source video from form uploads.
* that have user-uploaded video content.
*/
export function getTemplateDuration(
template: ExpressTemplate,
videoDurations?: Record<string, number>,
): number {
return template.scenes.reduce((sum, scene) => {
// If this scene has a form-sourced video and we know its actual duration, use it
if (videoDurations && scene.segmentSource === 'form' && videoDurations[scene.id]) {
// If we know the actual video duration for this scene, use it
if (videoDurations && videoDurations[scene.id]) {
return sum + videoDurations[scene.id];
}
return sum + scene.durationSeconds;
@@ -121,8 +121,8 @@ 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 for form-sourced scenes
const sceneDuration = (videoDurations && scene.segmentSource === 'form' && videoDurations[scene.id])
// Use actual video duration if available (from useVideoDurations)
const sceneDuration = (videoDurations && videoDurations[scene.id])
? videoDurations[scene.id]
: scene.durationSeconds;
const sceneDurFrames = sceneDuration * fps;