diff --git a/backend/app/services/video_renderer.py b/backend/app/services/video_renderer.py index 188207d..0b71f15 100644 --- a/backend/app/services/video_renderer.py +++ b/backend/app/services/video_renderer.py @@ -280,6 +280,16 @@ class VideoRendererService: key=lambda p: p["pause_point"] ) + # Debug logging for pause points + logger.info(f"Pause-insert: {len(sorted_placements)} placements with pause points") + for i, p in enumerate(sorted_placements): + logger.info( + f" Placement {i}: cue_index={p.get('ad_cue_index')}, " + f"pause_point={p.get('pause_point'):.2f}s, " + f"ad_duration={p.get('ad_duration'):.2f}s, " + f"consolidated={p.get('consolidated_with_previous', False)}" + ) + if not sorted_placements: logger.warning("No pause points found, copying source video") await self._copy_video(source_video_path, output_path) @@ -344,6 +354,11 @@ class VideoRendererService: # 4. Add final segment from last pause point to end (re-encoded for uniformity) source_duration = await self._get_video_duration(source_video_path) + logger.info( + f"Final segment check: current_time={current_time:.2f}s, " + f"source_duration={source_duration:.2f}s, " + f"remaining={source_duration - current_time:.2f}s" + ) if current_time < source_duration: final_segment_path = temp_dir_path / "segment_final.mp4" await self._extract_segment_reencoded( @@ -354,6 +369,14 @@ class VideoRendererService: video_props ) segment_files.append(str(final_segment_path)) + logger.info(f"Added final segment: {current_time:.2f}s to {source_duration:.2f}s") + else: + logger.info("No final segment needed (current_time >= source_duration)") + + # Debug: Log all segments before concatenation + logger.info(f"Total segments to concatenate: {len(segment_files)}") + for idx, seg in enumerate(segment_files): + logger.info(f" Segment {idx}: {seg}") # 5. Concatenate all segments if segment_files: