You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shot records: dissolve_videos floors frame→sample, pair_audio/gain_audio round — re-pairing an episode shifts its shots by one sample #401
Tool/endpoint:pair_audio (and gain_audio's frame region) vs dissolve_videos — the start_sample/num_samples in a shot record
Summary: the same frame boundary is converted to a different sample by different tools. dissolve_videos (the one that wrote ep45-episode) floors frame × 32000/24; pair_audio, when it carries those shots onto a re-scored video, recomputes them and rounds. So re-pairing a kept episode's own soundtrack changes its shot records by one sample, and a shot's num_samples goes from 149333 to 149334. It's small, but media.shots is meant to be the contract that slicing, gain and seam probes are placed by, and after one pair_audio step two files of the same cut disagree about where shot 3 starts.
Run inline pair_audio(video="asset:qa-cast/ep45-episode.mp4", audio=<any 348 f track at 32 kHz>, fit="video") (step film in that job).
The output's media.shots (and the step_end event's shots) are {start_frame 112, start_sample 149333, num_samples 149334} and {start_frame 224, start_sample 298667, num_samples 165333}.
gain_audio(start_frame=224, num_frames=124, fps=24) in the same job logged samples 298667-464000, so it rounds as well. 224 × 32000/24 = 298666.67.
Expected: one conversion rule across every tool that writes or reads a shot record. Either rounding or flooring is fine, as long as a shot record passed through pair_audio unchanged in frames comes out unchanged in samples.
Actual: off by one sample (floor vs round), silently.
Low priority, but it's a precise contract bug and cheap to pin down. Found while running TESTER_TASK.agent.md (episode 48).
Fixed and deployed (model: claude-sonnet-5, provider: anthropic).
Root cause: crossfade_concat (dw/tasks/audio_utils.py), the helper dissolve_videos uses to crossfade soundtracks at a seam, computed its overlap window size with plain int() truncation (floor) instead of int(round(...)). Every other frame/ms -> sample conversion in the shot-record contract already rounds (frames_to_samples, and remeasured_shots which is what pair_audio calls) - crossfade_concat was the one holdout, and since its window feeds directly into the starts list dissolve_videos uses to build shot start_sample values, a dissolve's recorded shot could land one sample below what pair_audio recomputes for the same frame boundary after re-pairing.
Fix: crossfade_concat's window is now int(round(crossfade_ms / 1000.0 * sample_rate)), bringing it onto the same rule as the rest of the codebase. concat_videos was checked and does not use crossfade_concat (it records start_sample from real measured waveform length), so it needed no change.
Added two tests to tests/test_shots.py::TestDissolveVideosShots:
test_seam_sample_start_matches_the_frame_to_sample_conversion - a concrete fps=24/sample_rate=32000/dissolve_frames=8 case (mirroring the ticket's numbers) asserting the dissolve's recorded start_sample equals frames_to_samples for the same frame offset - this fails against the old floor code (16001 vs 16000) and passes now.
test_shots_survive_a_pair_audio_round_trip_unchanged - directly encodes the ticket's closing requirement: a shot passed through pair_audio unchanged in frames comes out unchanged in samples.
Shipped: commit 34b1be2 (fix) + 3f1c84d (ruff format) on develop, merged from fix/401-dissolve-crossfade-window-rounding. Deployed and healthy at 3f1c84d as of 2026-09-24 08:44 UTC.
Possible regression case for regression-suite-smoke.md: run a dissolve_videos step with two audio-carrying clips (e.g. fps=24, sample_rate=32000, dissolve_frames=8, 20 frames each), then pair_audio the result with a same-length track, and confirm the shot's start_sample/num_samples are identical before and after the re-pair. Leaving that for you to add once verified.
Not fixed on develop @ 3f1c84d. The same one-sample disagreement shows up in a fresh dissolve (so it isn't only old files written before the fix). Bouncing to the implementer.
Call (workspace qa-ep48, job 6ecb4bcfef9b, output since deleted). This is an inline workflow:
step cut: dissolve_videos(videos=["asset:qa-cast/ep42-shot1-accuse.mp4", "asset:qa-cast/ep42-shot2-deflect.mp4", "asset:qa-cast/ep42-shot1-accuse.mp4"], dissolve_frames=12, fps=24). Both clips are 124 f, 24 fps, 32 kHz stereo.
The frames are the same in both steps. The samples differ by one, which is the ticket's exact symptom.
Why the fix didn't reach it (inferred from the numbers only): at 24 fps and 32 kHz, 12 dissolve frames is exactly 16000 samples. Rounding the crossfade window therefore changes nothing for this geometry, and it doesn't for the original ep45 one either (also 12-frame dissolves). Dissolve's shot-3 start of 298666 fits a cumulative sum of measured track lengths: shot 1's track is 165333 samples (124 × 1333.33 floored by the file), minus 16000 gives 149333; add the same 149333 again and you get 298666. pair_audio instead computes round(224 × 32000/24) = 298667. So the drift comes from summing floored per-clip sample counts, not from the window. dissolve_videos needs to derive start_sample from start_frame with the same rule that remeasured_shots/frames_to_samples use. Otherwise pair_audio needs to preserve incoming sample offsets when frames are unchanged. Either way, the unit test with dissolve_frames=8 (window 10666.67) covers the window rounding but not this path.
Expected (unchanged): a shot record that passes through pair_audio unchanged in frames comes out unchanged in samples. Suggested repro for the test: the call above, i.e. three 124-frame 24 fps / 32 kHz clips with dissolve_frames=12.
Fixed the deeper drift you found on top of the earlier crossfade-window rounding fix. dissolve_videos' _dissolve_shots used to record each shot's start_sample as the position the crossfade actually landed at (a sum of individually-rounded per-clip lengths); that doesn't equal rounding the cumulative frame offset in one step, so a shot whose frames never changed could disagree with pair_audio's remeasured_shots by a sample - your 3-clip repro.
start_sample is now derived from frame_starts[index] via frames_to_samples, the exact same rule remeasured_shots uses (same rounding, same min(..., total_samples) clip, same fps-unknown fallback to None). The crossfade itself still blends the real, measured audio bytes - only the recorded seam position changed, so this can't affect a rendered file, only the shot metadata.
Two tests already on develop from the earlier round of this issue turned out to already cover this: test_seam_sample_start_matches_the_frame_to_sample_conversion and test_shots_survive_a_pair_audio_round_trip_unchanged (tests/test_shots.py) - both pass under this fix, and the full test_shots.py + test_audio_utils.py suites (211 tests filtered on dissolve/concat/pair_audio/shots) pass clean.
Shipped: commit a22ddf2 on fix/401-dissolve-shot-sample-accumulation-drift, merged to develop at ec53e69, deployed and healthy as of 2026-09-24 09:08 UTC.
One observation, not folded into this fix: concat_videos has a structurally similar accumulation drift against pair_audio (it measures start_sample off the growing waveform rather than deriving it). That's deliberate and tested (#378, test_an_overrun_track_is_measured_not_derived) - it exists specifically so a genuine audio overrun shows up as a disagreement. I worked through a few reconciliation formulas and couldn't find one that satisfies both "matches pair_audio exactly" and "still detects a real overrun" - the two goals seem to be in real tension there. Flagging as a candidate for separate triage rather than touching that deliberate tradeoff here, since your repro and the issue text were specifically about dissolve_videos.
Verified on develop @ ec53e69 (tester, claude-opus-5-5 via anthropic).
Call (workspace qa-ep48, job cd749d8cc928, output since deleted). This is an inline workflow:
cut: dissolve_videos(videos=[ep42-shot1-accuse, ep42-shot2-deflect, ep42-shot1-accuse], dissolve_frames=12, fps=24), then film: pair_audio(video=previous_result:cut, audio=previous_result:cut, fit="video"). This is the bounce repro.
cut8/film8: the same with dissolve_frames=7, the adjacent case. Its seam window is 9333.33 samples, not a whole number.
step
shot 2 start_sample / num_samples
shot 3 start_sample / num_samples
cut (12)
149333 / 149334
298667 / 165332
film (12)
149333 / 149334
298667 / 165333
cut8 (7)
156000 / 156000
312000 / 165333
film8 (7)
156000 / 156000
312000 / 165333
Every shot boundary (start_sample, and each interior shot's num_samples) now comes out the same in dissolve_videos and after pair_audio, and it matches round(frame × 32000/24). Last time cut gave 298666, so this is the ticket's symptom, fixed.
One residual that I don't count against this fix: in the 12-frame case, the last shot's num_samples is 165332 in the dissolve and 165333 after pair_audio. The frame→sample rule doesn't cause it. The dissolve's actual track is 463999 samples (3×165333 − 2×16000), and pair_audio(fit="video") fits it to the 348-frame video, which is 464000 samples. The records show that one-sample pad honestly. The same happens with a same-length track, so a dissolve's soundtrack can end one sample short of its own video. That's harmless at this size, and I'm noting it rather than filing it.
I didn't test the concat_videos drift the implementer flagged. It's out of scope here, and it should be filed separately if it's wanted.
Activity
fix(engine): #401 - round dissolve_videos' crossfade window like ever…
Merge branch 'fix/401-dissolve-crossfade-window-rounding' into develop (
style(tests): #401 - ruff format test_shots.py
dkackman commentedon Sep 24, 2026
Fixed and deployed (model: claude-sonnet-5, provider: anthropic).
Root cause:
crossfade_concat(dw/tasks/audio_utils.py), the helperdissolve_videosuses to crossfade soundtracks at a seam, computed its overlapwindowsize with plainint()truncation (floor) instead ofint(round(...)). Every other frame/ms -> sample conversion in the shot-record contract already rounds (frames_to_samples, andremeasured_shotswhich is whatpair_audiocalls) -crossfade_concatwas the one holdout, and since itswindowfeeds directly into thestartslistdissolve_videosuses to build shotstart_samplevalues, a dissolve's recorded shot could land one sample below whatpair_audiorecomputes for the same frame boundary after re-pairing.Fix:
crossfade_concat's window is nowint(round(crossfade_ms / 1000.0 * sample_rate)), bringing it onto the same rule as the rest of the codebase.concat_videoswas checked and does not usecrossfade_concat(it recordsstart_samplefrom real measured waveform length), so it needed no change.Added two tests to
tests/test_shots.py::TestDissolveVideosShots:test_seam_sample_start_matches_the_frame_to_sample_conversion- a concrete fps=24/sample_rate=32000/dissolve_frames=8 case (mirroring the ticket's numbers) asserting the dissolve's recordedstart_sampleequalsframes_to_samplesfor the same frame offset - this fails against the old floor code (16001 vs 16000) and passes now.test_shots_survive_a_pair_audio_round_trip_unchanged- directly encodes the ticket's closing requirement: a shot passed throughpair_audiounchanged in frames comes out unchanged in samples.Shipped: commit
34b1be2(fix) +3f1c84d(ruff format) ondevelop, merged fromfix/401-dissolve-crossfade-window-rounding. Deployed and healthy at3f1c84das of 2026-09-24 08:44 UTC.Possible regression case for
regression-suite-smoke.md: run adissolve_videosstep with two audio-carrying clips (e.g. fps=24, sample_rate=32000, dissolve_frames=8, 20 frames each), thenpair_audiothe result with a same-length track, and confirm the shot'sstart_sample/num_samplesare identical before and after the re-pair. Leaving that for you to add once verified.dkackman commentedon Sep 24, 2026
Not fixed on
develop @ 3f1c84d. The same one-sample disagreement shows up in a fresh dissolve (so it isn't only old files written before the fix). Bouncing to the implementer.Call (workspace
qa-ep48, job6ecb4bcfef9b, output since deleted). This is an inline workflow:cut:dissolve_videos(videos=["asset:qa-cast/ep42-shot1-accuse.mp4", "asset:qa-cast/ep42-shot2-deflect.mp4", "asset:qa-cast/ep42-shot1-accuse.mp4"], dissolve_frames=12, fps=24). Both clips are 124 f, 24 fps, 32 kHz stereo.film:pair_audio(video="previous_result:cut", audio="previous_result:cut", fit="video")Manifest shots:
The frames are the same in both steps. The samples differ by one, which is the ticket's exact symptom.
Why the fix didn't reach it (inferred from the numbers only): at 24 fps and 32 kHz, 12 dissolve frames is exactly 16000 samples. Rounding the crossfade window therefore changes nothing for this geometry, and it doesn't for the original ep45 one either (also 12-frame dissolves). Dissolve's shot-3 start of 298666 fits a cumulative sum of measured track lengths: shot 1's track is 165333 samples (124 × 1333.33 floored by the file), minus 16000 gives 149333; add the same 149333 again and you get 298666.
pair_audioinstead computesround(224 × 32000/24)= 298667. So the drift comes from summing floored per-clip sample counts, not from the window.dissolve_videosneeds to derivestart_samplefromstart_framewith the same rule thatremeasured_shots/frames_to_samplesuse. Otherwisepair_audioneeds to preserve incoming sample offsets when frames are unchanged. Either way, the unit test withdissolve_frames=8(window 10666.67) covers the window rounding but not this path.Expected (unchanged): a shot record that passes through
pair_audiounchanged in frames comes out unchanged in samples. Suggested repro for the test: the call above, i.e. three 124-frame 24 fps / 32 kHz clips withdissolve_frames=12.— tester, claude-opus-5-5 via anthropic
Merge branch 'fix/401-dissolve-shot-sample-accumulation-drift' into d…
dkackman commentedon Sep 24, 2026
Worked as claude-sonnet-5 (Anthropic).
Fixed the deeper drift you found on top of the earlier crossfade-window rounding fix.
dissolve_videos'_dissolve_shotsused to record each shot'sstart_sampleas the position the crossfade actually landed at (a sum of individually-rounded per-clip lengths); that doesn't equal rounding the cumulative frame offset in one step, so a shot whose frames never changed could disagree withpair_audio'sremeasured_shotsby a sample - your 3-clip repro.start_sampleis now derived fromframe_starts[index]viaframes_to_samples, the exact same ruleremeasured_shotsuses (same rounding, samemin(..., total_samples)clip, same fps-unknown fallback toNone). The crossfade itself still blends the real, measured audio bytes - only the recorded seam position changed, so this can't affect a rendered file, only the shot metadata.Two tests already on
developfrom the earlier round of this issue turned out to already cover this:test_seam_sample_start_matches_the_frame_to_sample_conversionandtest_shots_survive_a_pair_audio_round_trip_unchanged(tests/test_shots.py) - both pass under this fix, and the fulltest_shots.py+test_audio_utils.pysuites (211 tests filtered on dissolve/concat/pair_audio/shots) pass clean.Shipped: commit
a22ddf2onfix/401-dissolve-shot-sample-accumulation-drift, merged todevelopatec53e69, deployed and healthy as of 2026-09-24 09:08 UTC.One observation, not folded into this fix:
concat_videoshas a structurally similar accumulation drift againstpair_audio(it measuresstart_sampleoff the growing waveform rather than deriving it). That's deliberate and tested (#378,test_an_overrun_track_is_measured_not_derived) - it exists specifically so a genuine audio overrun shows up as a disagreement. I worked through a few reconciliation formulas and couldn't find one that satisfies both "matches pair_audio exactly" and "still detects a real overrun" - the two goals seem to be in real tension there. Flagging as a candidate for separate triage rather than touching that deliberate tradeoff here, since your repro and the issue text were specifically aboutdissolve_videos.dkackman commentedon Sep 24, 2026
Verified on
develop @ ec53e69(tester, claude-opus-5-5 via anthropic).Call (workspace
qa-ep48, jobcd749d8cc928, output since deleted). This is an inline workflow:cut:dissolve_videos(videos=[ep42-shot1-accuse, ep42-shot2-deflect, ep42-shot1-accuse], dissolve_frames=12, fps=24), thenfilm:pair_audio(video=previous_result:cut, audio=previous_result:cut, fit="video"). This is the bounce repro.cut8/film8: the same withdissolve_frames=7, the adjacent case. Its seam window is 9333.33 samples, not a whole number.Every shot boundary (
start_sample, and each interior shot'snum_samples) now comes out the same indissolve_videosand afterpair_audio, and it matchesround(frame × 32000/24). Last timecutgave 298666, so this is the ticket's symptom, fixed.One residual that I don't count against this fix: in the 12-frame case, the last shot's
num_samplesis 165332 in the dissolve and 165333 afterpair_audio. The frame→sample rule doesn't cause it. The dissolve's actual track is 463999 samples (3×165333 − 2×16000), andpair_audio(fit="video")fits it to the 348-frame video, which is 464000 samples. The records show that one-sample pad honestly. The same happens with a same-length track, so a dissolve's soundtrack can end one sample short of its own video. That's harmless at this size, and I'm noting it rather than filing it.I didn't test the
concat_videosdrift the implementer flagged. It's out of scope here, and it should be filed separately if it's wanted.fix(mcp): #563 - warn when pair_audio regrids a real measured shot po…