Skip to content

Fix merge timeout: O(D) trim+overlay+concat replaces O(N×D) chained overlays#3

Open
anoob-optiroai wants to merge 2 commits into
mainfrom
add-source-code
Open

Fix merge timeout: O(D) trim+overlay+concat replaces O(N×D) chained overlays#3
anoob-optiroai wants to merge 2 commits into
mainfrom
add-source-code

Conversation

@anoob-optiroai

Copy link
Copy Markdown
Owner

Summary

  • Root cause: _apply_alpha_transitions chained N overlay filters on the full base video. FFmpeg had to encode the entire video N times (once per overlay link in the chain). With 30 transitions on a 47-minute video, that's ~24 hours of encoding work — impossible within the 900 s timeout.
  • Fix: Replaced with a trim + overlay + concat filter graph. The base video is decoded once, split into per-segment branches, each transition overlay is applied only to its ~1.2 s window, then all segments are concatenated. O(duration) regardless of transition count.
  • Drift fix also included: Cut points now use integer frame arithmetic (frame_acc += fc in integer counts, cut_times.append(frame_acc / FPS)) instead of t_acc += d float accumulation — eliminates sync drift at 6-7 minutes.
  • Timeout now scales to max(1800, base_dur × 5) seconds so long presentations are handled gracefully.

Test plan

  • Generate a video with 20+ slides and a custom transition clip — confirm it completes without timeout
  • Scrub through the output at minute 6-7 and beyond — confirm transitions land on correct slide cuts
  • Verify transition alpha compositing still works (transparent areas show base slide correctly)
  • Test with a short video (< 5 slides) — confirm plain-only path (no transitions) still works

🤖 Generated with Claude Code

anoob-optiroai and others added 2 commits April 11, 2026 21:48
- Switch from macos-latest (arm64/Apple Silicon) to macos-13 (Intel x64)
  because electron-builder has a known hdiutil/background.tiff crash on arm64
- Set dmg.background: null to avoid the .background/background.tiff lookup
- Set hardenedRuntime: false (no signing cert configured)
- Build separate x64 and arm64 DMG targets (cross-compiled from Intel runner)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The old _apply_alpha_transitions chained N overlay filters on the full
base video, making FFmpeg do O(N × duration) encoding work. With 30
transitions on a 47-minute video this exceeded the 900 s timeout.

The new approach splits the base video into segments in a single FFmpeg
pass, applies each transition overlay only to its ~1.2 s window, then
concatenates — O(duration) work regardless of transition count.

Also uses integer frame arithmetic for cut_times (zero float drift)
and scales timeout to 5× video duration (min 30 min) to handle long
presentations gracefully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant