Skip to main content

Trim leading and trailing silence from MP3 songs.

Project description

TrackTrim

TrackTrim is a Python library and CLI for trimming leading and trailing silence from MP3 songs.

It detects the first and last non-silent regions of a track, trims the file, writes MP3 output, and preserves common ID3 metadata.

Features

  • Detect leading and trailing silence
  • MP3 input to MP3 output
  • Preserve common metadata and cover art
  • Stable bitrate policy for predictable output size
  • Public Python API and command-line interface

Installation

PyPI

pip install tracktrim

GitHub

pip install git+https://github.com/DrSopes/TrackTrim.git

Python API

from tracktrim import inspect_mp3, detect_content_bounds, trim_song

info = inspect_mp3("song.mp3")
print(info)

bounds = detect_content_bounds("song.mp3", top_db=35)
print(bounds)

result = trim_song("song.mp3", "song_trimmed.mp3", top_db=35)
print(result)

CLI

tracktrim input.mp3 output.mp3 --top-db 35

Optional bitrate override:

tracktrim input.mp3 output.mp3 --bitrate 320

Bitrate policy

TrackTrim uses a stable default policy:

  • source bitrate <= 192 kbps -> output 192 kbps
  • source bitrate 193 to 288 kbps -> output 256 kbps
  • source bitrate > 288 kbps -> output 320 kbps

Development

python -m venv .venv

Windows CMD:

.venv\Scripts\activate

Install in editable mode:

pip install -e .

Build

python -m pip install --upgrade build
python -m build

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

Project details


Download files

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

Source Distribution

tracktrim-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

tracktrim-0.1.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file tracktrim-0.1.2.tar.gz.

File metadata

  • Download URL: tracktrim-0.1.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tracktrim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 77c85e27bada5de08eb1b340471432a92ac917f4d59f405505abb6945ab4cc74
MD5 8179b51ff7088c223f019ce549fafc0c
BLAKE2b-256 3c262a92951aaf24404e52c18978cf76c8b681d145c169266f5df7c291746aec

See more details on using hashes here.

Provenance

The following attestation bundles were made for tracktrim-0.1.2.tar.gz:

Publisher: publish.yml on DrSopes/TrackTrim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tracktrim-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tracktrim-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tracktrim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eb4a569b83053b925905957902dc616a2ec75ed0096e70220784949757ddb9ad
MD5 1874e3a13db0bc6da44893429582b490
BLAKE2b-256 38f16303e27536207114f4fbf498908ab69592cf90006371a6e5d4d22db5ec58

See more details on using hashes here.

Provenance

The following attestation bundles were made for tracktrim-0.1.2-py3-none-any.whl:

Publisher: publish.yml on DrSopes/TrackTrim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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