Youtube-dl

As part of Audio Video Editing in Linux How To , It can be very easy to upload something YouTube↗ , lose the original source video, and have only the YouTube version remaining. What is the easiest way to retrieve a copy of your YouTube videos.

Youtube-dl↗ is a nifty little tool you can use to grab videos from YouTube and several other video-streaming services. It’s super straightforward to use:

youtube-dl https://www.youtube.com/watch?v=2m5nW9CQLJ0

This command downloads the video at the URL indicated and saves it locally.

Youtube-dl has several options for controlling the quality and format of the downloaded video, but I find it easier to use the command above. It downloads the highest quality audio and video into a single file, then I use FFmpeg to convert them into the format I want.

To download best quality of Audio & Video in mp4

youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' url

download two files (bestaudio[ext=mp4] and bestvideo[ext=m4a]) without any transcoding

https://unix.stackexchange.com/questions/272868/download-only-format-mp4-on-youtube-dl/272934↗

To download a playlist(Starting at 36)

–playlist-start 36 playlisturl

Sample - https://www.youtube.com/playlist?list=PL4lJLtpfKDUEUofMMkp9XO0l8vM10BMAh↗

–playlist-start NUMBER Playlist video to start at (default is 1)

–playlist-end NUMBER Playlist video to end at (default is last)

–playlist-items ITEM_SPEC Playlist video items to download. Specify

indices of the videos in the playlist

separated by commas like: “–playlist-items

1,2,5,8” if you want to download videos

indexed 1, 2, 5, 8 in the playlist. You can

specify range: “–playlist-items

1-3,7,10-13”, it will download the videos

at index 1, 2, 3, 7, 10, 11, 12 and 13.

https://stackoverflow.com/questions/48422377/youtube-downloading-a-playlist-youtube-dl↗

To download audio only (default ogg opus format)

$ youtube-dl -x url

To download audio only (mp3 format)

$ youtube-dl -x --audio-format mp3 url

To download and install youtube-dl

$ sudo pip install --upgrade youtube_dl

Source: https://ytdl-org.github.io/youtube-dl/download.html↗

$ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl

To Update Youtube-dl

$ sudo youtube-dl -U

Source: https://www.ostechnix.com/youtube-dl-tutorial-with-examples-for-beginners/↗


© Prabu Anand K 2020-2026