Skip to main content

SoundGraft

SoundGraft

Replace video clip audio with matched segments from a dedicated audio recording.

When you record an event with both a camera and a separate high-quality audio recorder, SoundGraft automatically aligns each video clip to the audio timeline and swaps in the better audio track. It also cleans up the replacement audio by attenuating applause and impulse noise, then peak-normalizes the result.

How it works

  1. File classification — Scans the input directory and sorts files into audio recordings and video clips by extension.
  2. Event grouping — Groups consecutive audio segments into events using a file-size heuristic (a short segment followed by a full-length one marks an event boundary).
  3. Alignment — Cross-correlates Chromaprint fingerprints to find where each video clip overlaps the audio timeline, at any relative offset (the audio need not contain the whole clip). Metadata timestamps provide a search hint when available. The output video is trimmed to the audio-covered overlap, snapped to a keyframe so the video stream is copied without re-encoding.
  4. Audio processing — For each matched clip:
    • Cuts the corresponding segment from the audio recording
    • Detects and attenuates applause sections (spectral flatness analysis)
    • Detects and attenuates impulse noise (transient peak analysis)
    • Peak-normalizes to 0 dBFS
  5. Muxing — Replaces the video's audio track with the processed audio using ffmpeg.

Per-clip .log files are written to the output directory with alignment, applause, impulse, and normalization details.

Installation

pip install soundgraft

You also need these system tools:

  • ffmpeg / ffprobe
  • sox
  • fpcalc (from libchromaprint-tools)

On Debian/Ubuntu:

sudo apt install ffmpeg sox libchromaprint-tools

Usage

soundgraft --input <input_dir> --output <output_dir> [options]

Place all raw audio recordings and video clips in a single input directory. Output videos (with replaced audio) and per-clip log files are written to the output directory.

Options

Flag Description
--input DIR Directory containing raw audio and video files (required)
--output DIR Directory for output files (required)
--clip N Process only video clip number N (1-indexed)
--from-clip N Process video clips from N onwards
--it-is-what-it-is Include low-confidence matches instead of skipping them
--no-hint Skip metadata timestamp heuristic, always do full scan
--keep-original-audio Keep the original video audio as a second track
--shotgun N Emit N candidate outputs per clip (different alignment offsets) instead of auto-picking one; use to recover from a bad match. Output files are named <clip>_cand<k>_<offset>s.<ext>.
--min-overlap SEC Minimum seconds of audio/video overlap required to emit a clip (default: 10). Clips with less overlap are skipped.
--offset-correction SEC Seconds added to the chromaprint-derived audio offset to correct its fixed bias (default: -0.19). Lower it if the replaced audio plays late, raise it if early.
--no-cleanup Skip applause and impulse detection/attenuation (peak normalization still applied).
--temp-dir DIR Directory for temporary files (default: system temp)

Supported formats

  • Audio: .wav, .flac, .mp3, .ogg, .aac
  • Video: .mp4, .mov, .avi, .mkv, .mts

Example

soundgraft --input ./concert-raw --output ./concert-fixed

This scans concert-raw/ for audio and video files, aligns each video clip to the audio recording, processes the audio, and writes the final videos to concert-fixed/.

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

soundgraft-0.3.3.tar.gz (734.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soundgraft-0.3.3-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file soundgraft-0.3.3.tar.gz.

File metadata

  • Download URL: soundgraft-0.3.3.tar.gz
  • Upload date:
  • Size: 734.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for soundgraft-0.3.3.tar.gz
Algorithm Hash digest
SHA256 0ef26ec0f8c0f9626b23c8f1f508140e3c0ed98d25f28fa498323647f59ff930
MD5 44b8392b5987a6dfe53d1b15b7bfbe5a
BLAKE2b-256 51be44aa7ca31fb37c7685d72071ad4eb5f82e2c9477b98ccbb9bdbeb8e572b8

See more details on using hashes here.

File details

Details for the file soundgraft-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: soundgraft-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for soundgraft-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b967b7787af2aaaa7b39aff3cd170e2e4ab94677c8dc6b51e79d274a6765155
MD5 a338bc9f57ba907faa56aee92506d960
BLAKE2b-256 c9143132dfb08c0f8f2d27c5f39a6113a6e5fcfbb83afb8351054ecd6e666302

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page