May 01, 2020 Stardate: 73797.5 Tagged as: Ubuntu FFmpeg
I got bluetooth headphones for running since my old wired headphones were falling apart. I don’t need anything super-high quality since these are for running and I’ll be huffing and puffing - so I got what was available in India - JBL Endurance Dive. I currently jog with my phone playing Amazon Music, so I was going to bluetooth to my phone until I get a small bluetooth player like the SanDisk Clip Sport Plus. BUT, the JBL headphones have a built-in mp3 player with 1GB storage, so no external player needed! Of course, this is not the highest quality, but like I said I’m just running.
The next challenge is getting music for the player. I’m streaming music and don’t necessarily want to torrent. After a short time searching I found a cross-platform utility named youtube-dl.
Source: https://linoxide.com/linux-how-to/install-use-youtube-dl-ubuntu/
sudo apt install youtube-dl
Now that it is installed, I recommend installing FFmpeg also. This is pretty simple, as described in this tutorial instructions. This is just a very useful utility to have and I use a bunch for transcoding video formats.
sudo apt install ffmpeg
Once you have chosen a youtube video, you can list all available audio/video formats and bitrates. Note, replace
youtube-dl -F https://www.youtube.com/watch?v=<id>
If I run this command on the video “yYzrSGRzttk”, I see a whole list of audio and video files that are available. The first four; ID# 249, 250, 251, 140 are audio. The first three are in webm format and the last is m4a, both are optimized for delivering on the web. You can select the specific stream you want and download it.
youtube-dl -f 278 https://www.youtube.com/watch?v=yYzrSGRzttk
The better method is to let youtube-dl choose the best audio stream and download it.
Source: https://stackoverflow.com/questions/49804874/download-the-best-quality-audio-file-with-youtube-dl
youtube-dl -f bestaudio https://www.youtube.com/watch?v=<id>
You can specify the name of the downloaded file.
youtube-dl -f bestaudio https://www.youtube.com/watch?v=<id> --output "outputName.%(ext)s"
With FFmpeg installed, you can also convert to mp3. I know converting formats probably degrade the audio quality, but my cheap headphone mp3 player doesn’t play the webm file format.
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=<id>
And then finally, you can download, convert to mp3, and rename the file.
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=<id> --output "outputName.%(ext)s"]
sudo apt install audacity
Source: https://askubuntu.com/questions/246242/how-to-normalize-sound-in-mp3-files
The audio files downloaded from the web probably have different loudness levels which can be undesirable. You can run a normalize and clean up batch process to all the downloaded folder.
Select “Tools > Macros…”
Make sure the macro “MP3 Conversion” is selected, then click “Files…”. This will open up a standard file browser where you can shift/select all the mp3 files you want to normalize.
Then the magic happens! The modified files will be in a new folder named “macro-output”.
This is an automated list of software versions used during the writing of this article.
Software Version
OS Ubuntu 20.04 LTS
FFmpeg 4.2.2-1
youtube-dl 2020.03.24
Audacity 2.3.3