Archiving YouTube#

YouTube is one of the biggest video streaming sites on the Internet and you can find a video for basically everything on it. But in some cases, you can’t find a video anymore or it has been taken down or set to private for some reason. Having a local copy for personal or legal purposes can be useful, but by default YouTube only allows creators to export their content.

With the tool youtube-download, you can download the audio and/or video, and also subtitles in the languages you desire. The example below downloads the audio and video, and subtitles in English and Dutch. Also, it limits the frame size to 1920×1080 and stores everything in an MP4 container.

$ youtube-dl --embed-subs --embed-thumbnail \
    --add-metadata --write-info-json \
    --sub-lang en,nl --write-auto-sub \
    -o '%(title)s.%(ext)s' \
    -f 'bestvideo[ext=mp4,height<=1080]+bestaudio[ext=m4a]/bestvideo+bestaudio' \
    --merge-output-format mp4 \

More options are available, but this configuration seems to be correct for a lot of videos and can also be used to download everything in de playlist automatically. The later can be done by just feeding youtube-dl the URL of the playlist instead of the video and the tool will try to download every video in the playlist.

Keep in mind that this is only a short example and more options exist. Secondly, this should only be used for personal use only as these actions may violate terms of services and/or copyright law in your region.