youtube-dl is a versatile command line tool for downloading videos from YouTube and many other websites. I use it for making back up of my own YouTube videos.
By default, you use youtube-dl for downloading videos. How about extracting only the audio with youtubde-dl? That’s very simple actually. Let me show you the steps.
Attention
Downloading videos from websites could be against their policies. It’s up to you if you choose to download videos or audio.
Download only audio with youtube-dl
Please make sure that you have installed youtube-dl on your Linux distribution first.
sudo snap install youtube-dl
If you only want to download audio from a YouTube video, you can use the -x option with youtube-dl. This extract-audio option converts the video files to audio-only files.
youtube-dl -x video_URL
The file is saved in the same directory from where you ran the youtube-dl command.
Here’s an example where I downloaded the voice-over of our Zorin OS 16 review video.
youtube-dl -x https://www.youtube.com/watch?v=m_PmLG7HqbQ
[youtube] m_PmLG7HqbQ: Downloading webpage
[download] Destination: Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a
[download] 100% of 4.26MiB in 00:03
[ffmpeg] Correcting container in "Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a"
[ffmpeg] Post-process file Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a exists, skipping
Did you notice the audio format? It is in .m4a format. You may specify the audio format to something of your choice.
Say you want to extract the audio in MP3 format. You can use it like this:
youtube-dl -x --audio-format mp3 video_URL
Here’s the same example I showed previously. You can see that it uses ffmpeg to convert the m4a file into mp3.
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=m_PmLG7HqbQ
[youtube] m_PmLG7HqbQ: Downloading webpage
[download] Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a has already been downloaded
[download] 100% of 4.26MiB
[ffmpeg] Correcting container in "Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a"
[ffmpeg] Destination: Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.mp3
Deleting original file Zorin OS 16 Review - It's a Visual Masterpiece-m_PmLG7HqbQ.m4a (pass -k to keep)
Download entire YouTube playlist in MP3 format
Yes, you can totally do that. The main thing is to get the URL of the playlist here. It is typically in the following format:
https://www.youtube.com/playlist?list=XXXXXXXXXXXXXXXXXXX
To get the URL of a playlist, click on its name when the playlist is being displayed in the right sidebar.
It will take you to the playlist page and you can copy the URL here.
Now that you have the playlist URL, you can use it to download the audio files in MP3 format in the following fashion:
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" playlist_URL
That scary looking -o "%(title)s.%(ext)s"
specifies the output file (with option -o) and instructs it to use the title of the video and the extension (mp3 in this case) for naming the audio files.
I hope you find this quick tip helpful. Enjoy the audio files :)
from It's FOSS https://ift.tt/3mjmHRw
via IFTTT
Tidak ada komentar:
Posting Komentar