Skip to content

Conversation

Copy link

Copilot AI commented Dec 9, 2025

Audio from multiple video sources connected through ImageConcat was being incorrectly interleaved per-frame instead of concatenated per-slot, producing garbled output.

Root Cause

VideoWriter was merging audio chunks on each frame update:

# For each frame: sort all slots by timestamp, merge, append
Frame 1: [slot1_chunk, slot0_chunk] → merged_chunk1
Frame 2: [slot1_chunk, slot0_chunk] → merged_chunk2
Final: [merged_chunk1, merged_chunk2]  # Interleaved audio ❌

This breaks temporal coherence - each video source's audio should play sequentially, not interleaved.

Changes

VideoWriter data structure

  • Changed _audio_samples_dict from list to dict[slot_idx, SlotData]
  • SlotData = {'samples': list, 'timestamp': float, 'sample_rate': int}

Collection logic

  • During recording: accumulate frames per-slot
  • On recording stop: concatenate each slot's frames, then sort slots by timestamp

Result:

# Collect per slot
Slot 0 (ts=100.0): [frame1, frame2, ...] → concatenated
Slot 1 (ts=99.9):  [frame1, frame2, ...] → concatenated

# Sort by timestamp
Final: [slot1_audio, slot0_audio]  # Correct temporal order ✓

Testing

  • Added test_video_writer_audio_slot_merge.py covering multi-slot, single-slot, and edge cases
  • Existing audio sync tests continue to pass
Original prompt

le son ne marche pas lors de la fusion image son lors de ça ====> chunk de l'audio fusionne de façon synchronisé, quand on passe l'audio et la video au travzers de la syncQueue, tous cela au finale au traverse de imageconcat et videowriter. vérifie ça.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 9, 2025 16:29
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix audio not working during image and audio merge Fix audio synchronization in VideoWriter multi-slot merging Dec 9, 2025
Copilot AI requested a review from hackolite December 9, 2025 16:40
@hackolite hackolite marked this pull request as ready for review December 10, 2025 11:09
@hackolite hackolite merged commit 5050ddb into main Dec 10, 2025
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.

2 participants