Skip to content

DrSopes/TrackTrim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

TrackTrim is a Python library for trimming leading and trailing silence from MP3 songs while preserving MP3 output and common ID3 metadata.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages