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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77c85e27bada5de08eb1b340471432a92ac917f4d59f405505abb6945ab4cc74
|
|
| MD5 |
8179b51ff7088c223f019ce549fafc0c
|
|
| BLAKE2b-256 |
3c262a92951aaf24404e52c18978cf76c8b681d145c169266f5df7c291746aec
|
Provenance
The following attestation bundles were made for tracktrim-0.1.2.tar.gz:
Publisher:
publish.yml on DrSopes/TrackTrim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracktrim-0.1.2.tar.gz -
Subject digest:
77c85e27bada5de08eb1b340471432a92ac917f4d59f405505abb6945ab4cc74 - Sigstore transparency entry: 1450344554
- Sigstore integration time:
-
Permalink:
DrSopes/TrackTrim@8c768ca3c6db06b011c513c138ad716197dcf7d1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DrSopes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c768ca3c6db06b011c513c138ad716197dcf7d1 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb4a569b83053b925905957902dc616a2ec75ed0096e70220784949757ddb9ad
|
|
| MD5 |
1874e3a13db0bc6da44893429582b490
|
|
| BLAKE2b-256 |
38f16303e27536207114f4fbf498908ab69592cf90006371a6e5d4d22db5ec58
|
Provenance
The following attestation bundles were made for tracktrim-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on DrSopes/TrackTrim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracktrim-0.1.2-py3-none-any.whl -
Subject digest:
eb4a569b83053b925905957902dc616a2ec75ed0096e70220784949757ddb9ad - Sigstore transparency entry: 1450344677
- Sigstore integration time:
-
Permalink:
DrSopes/TrackTrim@8c768ca3c6db06b011c513c138ad716197dcf7d1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DrSopes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c768ca3c6db06b011c513c138ad716197dcf7d1 -
Trigger Event:
workflow_dispatch
-
Statement type: