Download a Youtube video to mp3 with the Linux shell.

Posted: December 23, 2015. At: 11:48 AM. This was 2 years ago. Post ID: 8603
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

Firstly, install youtube-dl.

[email protected]:~/Music$ sudo apt-get install youtube-dl

Then run this command with the Youtube video URL.

jason@darkstar:~/Music$ youtube-dl -f bestaudio -x --audio-format mp3 --prefer-ffmpeg https://www.youtube.com/watch?v=UWFm2LIYNjg
[youtube] UWFm2LIYNjg: Downloading webpage
[youtube] UWFm2LIYNjg: Extracting video information
[youtube] UWFm2LIYNjg: Downloading DASH manifest
[download] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a
[download] 100% of 13.85MiB in 00:11
[ffmpeg] Correcting container in "Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a"
[avconv] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.mp3
Deleting original file Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a (pass -k to keep)

Now the MP3 file will be created on your HDD. This is the best way to save an MP3 of your favourite song on Youtube.

The –write-thumbnail parameter will write the video thumbnail to a jpeg file as well as the MP3, this could be useful if you wish to have it as the music ID3 art.

jason@darkstar:~/Music$ youtube-dl -f bestaudio -x --audio-format mp3 --write-thumbnail --prefer-ffmpeg https://www.youtube.com/watch?v=UWFm2LIYNjg
[youtube] UWFm2LIYNjg: Downloading webpage
[youtube] UWFm2LIYNjg: Extracting video information
[youtube] UWFm2LIYNjg: Downloading DASH manifest
[youtube] UWFm2LIYNjg: Downloading thumbnail ...
[youtube] UWFm2LIYNjg: Writing thumbnail to: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.jpg
[download] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a
[download] 100% of 13.85MiB in 00:22
[ffmpeg] Correcting container in "Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a"
[avconv] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.mp3
Deleting original file Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a (pass -k to keep)

Use this whenever you want to save a Youtube video to a music file in your ~/Music folder.

No comments have been made. Use this form to start the conversation :)

Leave a Reply