Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
download video from YouTube, extract music and normalize volume
param(
[string]$url
)
youtube-dl `
$url `
--quiet `
--extract-audio `
--audio-format mp3 `
--audio-quality 3 `
--exec 'mp3gain -q -r -c "{}"'
#!/bin/bash
youtube-dl \
"$1" \
--quiet \
--extract-audio \
--audio-format mp3 \
--audio-quality 3 \
--exec 'mp3gain -q -r -c {} > /dev/null && echo {}'
@stesj4

This comment has been minimized.

Copy link

@stesj4 stesj4 commented Dec 17, 2018

Thank You, perfect. Just a couple of notations. I'm now running Ubuntu under Win 10 (Subsystem for Linux) and then I had to change from two "&&" to just one "&". It wasn't necessary under native Linux???.
I've also added a couple of lines so that the finished file is also tagged (even a Picture, only in YouTube):

#!/bin/bash
read -p ' Title : ' title
read -p 'Artist : ' artist
read -p ' Album : ' album
read -p ' Genre : ' genre
youtube-dl
"$1" \
--quiet \
--extract-audio \
--audio-format mp3 \
--audio-quality 3 \
--embed-thumbnail \
--exec 'mp3gain -q -r -c -s i {} > /dev/null & echo -n {}' \
|xargs -0 mid3v2 -t "$title" -a "$artist" -A "$album" -g "$genre"

@madjoe

This comment has been minimized.

Copy link

@madjoe madjoe commented Jun 8, 2020

FYI

  • mp3gain is no longer available in repositories, does not compile and has been replaced with r128gain.
  • ReplayGain 2.0 targets the same loudness as ReplayGain 1.0 specification, but utilizes the improved ITU BS.1770 algorithm for measuring original tracks.
  • mp3gain is based on ReplayGain 1.0 specification.

Improved script: https://gist.github.com/madjoe/b981fa7f3f81089a37257e366c1ef581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment