@@ -308,13 +308,31 @@ export async function processVideoProduction(documentId: string): Promise<void>
308308 audioUrl,
309309 script : {
310310 hook : script . hook ,
311- scenes : script . scenes . map ( ( s , i ) => ( {
312- ...s ,
313- wordTimestamps : sceneWordTimestamps [ i ] ,
314- ...( infographicUrls . length > 0
315- ? { infographicUrl : infographicUrls [ i % infographicUrls . length ] }
316- : { } ) ,
317- } ) ) ,
311+ scenes : script . scenes . map ( ( s , i ) => {
312+ // Distribute infographic URLs across scenes as arrays
313+ // Each scene gets a chunk of images to cycle through (crossfade at ~4s intervals)
314+ let sceneInfographics : Record < string , unknown > = { } ;
315+ if ( infographicUrls . length > 0 ) {
316+ const sceneCount = script . scenes . length ;
317+ const urlsPerScene = Math . max ( 1 , Math . floor ( infographicUrls . length / sceneCount ) ) ;
318+ const startIdx = i * urlsPerScene ;
319+ // Last scene gets all remaining URLs
320+ const endIdx = i === sceneCount - 1
321+ ? infographicUrls . length
322+ : Math . min ( startIdx + urlsPerScene , infographicUrls . length ) ;
323+ const sceneUrls = infographicUrls . slice ( startIdx , endIdx ) ;
324+ sceneInfographics = {
325+ infographicUrls : sceneUrls ,
326+ // Keep single URL for backward compat (first image in the set)
327+ infographicUrl : sceneUrls [ 0 ] ,
328+ } ;
329+ }
330+ return {
331+ ...s ,
332+ wordTimestamps : sceneWordTimestamps [ i ] ,
333+ ...sceneInfographics ,
334+ } ;
335+ } ) ,
318336 cta : script . cta ,
319337 } ,
320338 bRollUrls,
0 commit comments