Skip to content

Latest commit

 

History

History
119 lines (97 loc) · 7.96 KB

index.md

File metadata and controls

119 lines (97 loc) · 7.96 KB
hide
navigation

Trimmer

MP3 song normalizer

GitHub version (latest SemVer) Github Pages PyPI codecov

Do you find it annoying when songs on YouTube are recorded quietly and there is a long silence before and after the song?

Trimmer corrects this by generating the normalized MP3 for you:

  1. Downloads a song from a URL on Youtube (thanks to youtube-dl and yt-dlp)
  2. Trims down the silence at the beginning and at the end of a song (thanks to pydub)
  3. Normalizes volume (detects clipping), and applies fade-in and fade-out (thanks to pydub)
  4. Adds MP3 ID3 tags - both ID3v1 & ID3v2 (thanks to eyed3)
  5. Creates an mp3 file with a unified name Artist - Title.mp3

Downloading MP3

Create trimmed, normalized and tagged mp3 from Youtube URL:

```console $ trimmer https://www.youtube.com/watch?v=dQw4w9WgXcQ [2023-03-06 23:08:27] INFO source recognized as url source=https://www.youtube.com/watch?v=dQw4w9WgXcQ [2023-03-06 23:08:27] INFO fetching metadata from youtube page... url=https://www.youtube.com/watch?v=dQw4w9WgXcQ [2023-03-06 23:08:31] INFO youtube page metadata fetched yt_title="Rick Astley - Never Gonna Give You Up (Official Music Video)" artist=None [2023-03-06 23:08:31] INFO artist & title extracted from youtube page artist="Rick Astley" title="Never Gonna Give You Up" Enter Artist ("Rick Astley" by default): Rick Astley Enter Title ("Never Gonna Give You Up" by default): Never Gonna Give You Up [2023-03-06 23:08:36] INFO song name set name="Rick Astley - Never Gonna Give You Up" [2023-03-06 23:08:36] INFO downloading from youtube... url=https://www.youtube.com/watch?v=dQw4w9WgXcQ [2023-03-06 23:08:42] INFO song downloaded tmpfile=trimmer_dl_b737b09b-beb7-412e-901a-425e14418b5c.mp3 [2023-03-06 23:08:42] INFO song renamed new_name="Rick Astley - Never Gonna Give You Up.mp3" [2023-03-06 23:08:42] INFO loading song... [2023-03-06 23:08:42] INFO normalizing volume level... volume=-0.98dB dBFS=-16.97dB [2023-03-06 23:08:42] INFO volume normalized gain=0.98dB [2023-03-06 23:08:42] INFO trimming silence... [2023-03-06 23:08:43] INFO silence trimmed trim_start=0.000s trim_end=2.000s duration_before=3:32.045 duration_after=3:30.045 [2023-03-06 23:08:43] INFO applying fade-in & fade-out... fade_in=0.100s fade_out=1.000s [2023-03-06 23:08:43] INFO saving song... mp3_file="Rick Astley - Never Gonna Give You Up.mp3" duration=3:30.045 [2023-03-06 23:08:46] INFO tagging mp3... artist="Rick Astley" title="Never Gonna Give You Up" [2023-03-06 23:08:46] INFO song saved mp3_file="Rick Astley - Never Gonna Give You Up.mp3" ```

Editing MP3

trimmer "unknown001.mp3"

From this:
unknown001.mp3
Usage example
trimmer does that:
Mike Oldfield - Tubular Bells Part I.mp3
Usage example

You can also trim song manually using --trim-start and --trim-end (e.g. for cutting long applause at the end of song).

Installation

pip3 install trimmer

It requires Python 3.6 (or newer) with pip.

For Linux make sure that required libs are installed: apt install ffmpeg libavcodec-extra

For Windows you might need to put ffmpeg binaries to PATH.

Upgrading

Keep up-to-date frequently changing dependencies (due to Youtube API changes):

pip3 install --upgrade --upgrade-strategy eager trimmer

or do the same with:

trimmer --upgrade

Help

$ trimmer --help
trimmer v1.0.0 (nuclear v1.3.4) - MP3 song normalizer

Usage:
trimmer [OPTIONS] SOURCE

Arguments:
   SOURCE - song source (youtube URL or MP3 file)

Options:
  --version                   - Print version information and exit
  -h, --help [SUBCOMMANDS...] - Display this help and exit
  --artist ARTIST             - song artist
  --title TITLE               - song title
  --trim-start TRIM_START     - trim given seconds at the beginning
  --trim-end TRIM_END         - trim given seconds at the end
  --gain GAIN                 - increase volume by given dB
  --output OUTPUT             - output MP3 file (Artist - Title.mp3 by default)
  --no-normalize              - skip normalizing volume level
  --no-trim                   - skip trimming silence at the edges of song
  --no-fade                   - skip applying fade-in & fade-out
  --no-rename                 - skip renaming song to normalized filename (Artist - Title.mp3)

Install locally in develop mode

make setup
. venv/bin/activate