Metadata-Version: 2.4
Name: tracktrim
Version: 0.1.1
Summary: Trim leading and trailing silence from MP3 songs.
Author: Dr.Sopes
License-Expression: AGPL-3.0-only
Project-URL: Homepage, https://github.com/DrSopes/tracktrim
Project-URL: Repository, https://github.com/DrSopes/tracktrim
Project-URL: Issues, https://github.com/DrSopes/tracktrim/issues
Keywords: audio,mp3,trim,silence,music
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Topic :: Multimedia :: Sound/Audio
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: librosa>=0.11.0
Requires-Dist: soundfile>=0.12.1
Requires-Dist: numpy>=1.26
Requires-Dist: mutagen>=1.47.0
Requires-Dist: lameenc>=1.2.0
Dynamic: license-file

# 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

```bash
pip install git+https://github.com/DrSopes/tracktrim.git
```

```bash
pip install tracktrim
```

## Usage

```python
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:

```bash
python -m venv .venv
```

On Windows CMD:

```bash
.venv\Scripts\activate
```

Then install:

```bash
pip install -e .
```

## Build

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