Trim leading and trailing silence from MP3 songs.
Project description
TrackTrim
TrackTrim is a Python library for trimming leading and trailing silence from MP3 songs while preserving MP3 output and common ID3 metadata.
Features
- Detects non-silent content at the beginning and end of a track
- Trims MP3 files and writes MP3 output
- Preserves common metadata and cover art through ID3 tag copying
- Uses a stable bitrate policy for predictable output size and quality
- Designed to be imported from other Python scripts
Installation
From GitHub
pip install git+https://github.com/DrSopes/tracktrim.git
pip install tracktrim
Usage
from tracktrim import trim_song, detect_content_bounds
info = detect_content_bounds("song.mp3", top_db=35)
print(info)
result = trim_song(
"song.mp3",
"song_trimmed.mp3",
top_db=35,
)
print(result)
Bitrate policy
TrackTrim uses a simple stable output policy:
- source bitrate <= 192 kbps -> output 192 kbps
- source bitrate 193 to 288 kbps -> output 256 kbps
- source bitrate > 288 kbps -> output 320 kbps
This avoids unpredictable VBR output and keeps file sizes consistent.
Development
Create a virtual environment and install the project in editable mode:
python -m venv .venv
On Windows CMD:
.venv\Scripts\activate
Then install:
pip install -e .
Build
python -m pip install --upgrade build
python -m build
This creates distribution files in dist/.
Publishing
This repository can publish to PyPI automatically through GitHub Actions using Trusted Publishing.
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.1.tar.gz.
File metadata
- Download URL: tracktrim-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
593c2367d153a9f4bfd275ba2212ff493bde840ec4a9c7e87c4aaf0038264096
|
|
| MD5 |
fa3bf81d09936455281fd4de5cf10848
|
|
| BLAKE2b-256 |
329747ba2cd3072e4648deb5ffa27275b6b3bf39fbf36318d4d4a74a964bc3a7
|
Provenance
The following attestation bundles were made for tracktrim-0.1.1.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.1.tar.gz -
Subject digest:
593c2367d153a9f4bfd275ba2212ff493bde840ec4a9c7e87c4aaf0038264096 - Sigstore transparency entry: 1450177267
- Sigstore integration time:
-
Permalink:
DrSopes/TrackTrim@056b18490dafcbf60b829669904cf56459a8a009 -
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@056b18490dafcbf60b829669904cf56459a8a009 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tracktrim-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tracktrim-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 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 |
eb4e3bca46b561d33f185a5b8a04047cc46106b455d50d52cb5042420af4e7ec
|
|
| MD5 |
132d94ba62b261c1efa1261702050e0d
|
|
| BLAKE2b-256 |
89ded01fc13bae4de7d601b354f696b7e053edb320c74e0226116a78f4e61024
|
Provenance
The following attestation bundles were made for tracktrim-0.1.1-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.1-py3-none-any.whl -
Subject digest:
eb4e3bca46b561d33f185a5b8a04047cc46106b455d50d52cb5042420af4e7ec - Sigstore transparency entry: 1450177794
- Sigstore integration time:
-
Permalink:
DrSopes/TrackTrim@056b18490dafcbf60b829669904cf56459a8a009 -
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@056b18490dafcbf60b829669904cf56459a8a009 -
Trigger Event:
workflow_dispatch
-
Statement type: