Skip to content

Feature request: add audio track to video #305

@christiaanwesterbeek

Description

@christiaanwesterbeek

Add a new tool to overlay or replace an audio track in a video file. This complements existing features like video trim/rotate/merge, audio trim/merge, and audio extraction from video, enabling users to customize video audio without external software. All processing remains client-side for privacy.

Rationale

Users often need to dub videos with new audio (e.g., music, voiceover) or fix audio issues. Given OmniTools' focus on lightweight, browser-based media editing, this fits seamlessly and enhances the video/audio suite.

Implementation Suggestion

Create a new tool under src/tools/video (similar to VideoTrimmer or VideoReverser), using the existing FFmpeg.wasm integration (assuming it's used for trim/merge/extract, as common in client-side media processing with @ffmpeg/ffmpeg).

  • UI: Inputs for video file and audio file; options for "replace existing audio" (default) or "mix/add as secondary track"; output format selector.
  • Logic: Load files via File API; use FFmpeg commands:
    • Replace: ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
    • Mix/Add: ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=shortest" -c:v copy output.mp4 (for mixing) or -map 0 -map 1:a -c copy (add track).
  • Reuse shared utils for file handling/progress (e.g., from merge tools).
  • Test: Ensure compatibility with common formats; handle duration mismatches by trimming longer audio.

This should be lightweight (~similar complexity to audio merge), leveraging existing libs without new dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions