Ubuntu – Download everything from a YouTube video using youtube-dl

avconvffmpegyoutubeyoutube-dl

I want to download everything (subtitles, cards, tags, annotations, thumbnails, etc. (and obviously the video w/ audio)) from a YouTube video (for example, this one).

I'm using youtube-dl and, with the overwhelming amount of switches to use, I can't seem to find anything to fit my needs. I also want to download the video/audio in the highest quality possible, with no quality loss. Even though it's not YouTube, I did also want to download some of my udemy courses I've bought so I can watch them while I'm on a long road trip.

I have ffmpeg installed, and I heard that you need this for lossless downloads from YouTube, but I'm not sure how to link it with youtube-dl.

This is my first time using youtube-dl, so any help is appreciated.

Best Answer

The relevant options you need:

# Filesystem
--write-annotations
--write-description
--write-info-json

# Thumbnail images
--write-all-thumbnails

# Video format
--format bestvideo+bestaudio/best
--merge-output-format mkv

# Subtitle
--all-subs
--write-auto-sub
--write-sub

# Post-processing
--add-metadata
--embed-subs

Copy that to your config file (either /etc/youtube-dl.conf or ~/.config/youtube-dl/config).

Using that configuration, I downloaded this video and youtube-dl wrote the following files:

$ ls
The Problem with Time & Timezones - Computerphile.annotations.xml
The Problem with Time & Timezones - Computerphile.description
The Problem with Time & Timezones - Computerphile.info.json
The Problem with Time & Timezones - Computerphile.jpg
The Problem with Time & Timezones - Computerphile.mkv

I can't post mediainfo's output here because it exceeds the characters limit, but you can see it in github.


I also want to download the video/audio in the highest quality possible, with no quality loss.

youtube-dl downloads videos at the highest quality possible by default, but you can force this behavior using --format bestvideo+bestaudio/best.


Even though it's not YouTube, I did also want to download some of my udemy courses I've bought so I can watch them while I'm on a long road trip.

Please read the article Can I Download a Course to my Computer?:

By default, complete courses are not downloadable from a computer. We do this out of concerns for piracy.

Please note that you can always save courses for offline viewing on the Udemy mobile app. For information on how to download video lectures to your iOS mobile device, please click here. For steps on how to download videos for offline viewing on an Android device, click here.


I have ffmpeg installed, and I heard that you need this for lossless downloads from YouTube, but I'm not sure how to link it with youtube-dl.

youtube-dl uses avconv by default, but --prefer-ffmpeg let you use ffmpeg instead. Anyway, this option is not needed for "lossless downloads". In the example I provided, youtube-dl only used ffmpeg to merge all the downloaded formats into a single mkv file.