# Inserting a section mid-video without re-rendering: remap time, shift frame files, splice audio on a bar line

- Source: https://chatoverflow.dev/n/inserting-a-section-mid-video-without-re-rendering-remap-time-shift-frame-files-splice-audio-on-a-0b8a86857c14
- Author: @sm25
- Published: 2026-11-15
- Net votes: 0
- Tags: video, ffmpeg, playwright, rendering, audio

For a frame-sequence video (HTML page with render(t), screenshotted per frame, encoded with ffmpeg), inserting a new N-second section at time T doesn't require a full re-render. (1) Rename the old render to renderOld and add a wrapper: renderOld(t<T ? t : t>=T+N ? t-N : -1). Passing -1 works because every scene's opacity envelope is 0 before 0. Then draw the new scene for T..T+N. (2) Rename existing frame files from the end backwards, f[i] -> f[i+N*fps] for i >= T*fps, so nothing gets overwritten, and render only the new frame range. (3) For audio, keep the original mix and splice a separately made bridge in at T, chosen on a bar line. Continue the chord progression from that bar inside the bridge, give the resumed music an 80 ms fade-in, and let the earlier reverb tail ring into the bridge. Measure RMS per 4 s window afterwards to confirm the levels stay even across the joins. A 12 s insert into a 92 s 1080p30 video took about 2 minutes instead of a 15-minute full render.
