Archiving Youtube videos with Youtube-dl
As part of the project Best practices for archiving social media in Flanders and Brussels, several tools were tested to archive various social media platforms. This publication describes the open source tool youtube-dl for archiving YouTube videos.
Many free open source software programs depend on the time volunteers can spend developing the software. This is also the case for youtube-dl; the code of youtube-dl is being updated less regularly these days.
In most use cases, youtube-dl still works fine. If you encounter problems archiving YouTube videos, first try updating youtube-dl with the -U option.
If it doesn't work to archive YouTube videos with the latest version of youtube-dl, it is recommended to download YT-DLP.
YT-DLP is a "fork" of the code from youtube-dl. The youtube-dl source code was used as a basis for further development and adding features.
The advantages of yt-dlp versus youtube-dl are that yt-dlp is updated faster when YouTube changes its website. Additionally, yt-dlp supports many more video platforms besides YouTube.
Another advantage is that all commands are the same, so all examples below can be reused by simply replacing "youtube-dl" in an example youtube-dl option1 option2 URL with "yt-dlp", yt-dlp option1 option2 URL. Installing FFmpeg alongside yt-dlp is still recommended.
Installing ffmpeg is advised to download higher resolution videos than 720p and to combine audio and video tracks into a file after downloading.
Installing Youtube-dl or YT-DLP and FFmpeg
Installing youtube-dl on Windows
- Go to the youtube-dl release page at GitHub and download the latest Windows version (youtube-dl.exe).
- Download the executable to a folder, for example "youtube-dl" in Documents or Desktop. Choose a directory that isn't changed often, otherwise you’ll have to repeat the steps below so your system finds the youtube-dl.exe executable again.
- Add Youtube-dl.exe to your environment variables, shortly PATH:
- Open the folder where youtube.exe is stored and click on the address bar. Copy then the address of the folder.

- Press the
windows key + rto open the Run menu.

- Enter
systempropertiesadvancedin the field and press enter or ok.

- In the System Properties window, click on the Environment Variables button.

- In the Environment Variables window, find the variable Path in the upper list. Double-click the row to open the Edit environment variable window.

- Select New on the right side and paste the copied path into the empty line that starts after clicking the New button. There are likely other paths already present; do not change these, as this could cause other programs and/or your system to malfunction.

- Test the addition of youtube-dl to your PATH.
- Open a new PowerShell window and type
youtube-dl --version. If everything is set up correctly, you will see a version number.

- If the command gives an error, restart your computer to force reloading of the path variable.
- Check that you have copied and pasted the correct path to the youtube-dl folder.
- Check whether you made the adjustment in the user variables and not in system variables. The latter requires a restart after adjustment and administrator rights.
- Go back to the Edit environment variable menu and move the entry for the youtube-dl folder up or down using the buttons on the right.
Installing Yt-dlp on Windows
- Go to yt-dlp release page on github and download the latest Windows version (yt-dlp.exe).
- Download the executable to a folder, for example "yt-dlp" in Documents or Desktop. Choose a directory that isn't changed often, otherwise you’ll have to repeat the steps below so your system finds the yt-dlp.exe executable again.
- Add yt-dlp.exe to your environment variables, shortly PATH:
- Open the folder where youtube.exe is stored and click on the address bar. Copy then the address of the folder.

- Press the
windows key + rto open the Run menu.

- Enter
systempropertiesadvancedin the field and press enter or ok.

- In the System Properties window, click on the Environment Variables button.

- In the Environment Variables window, find the variable Path in the upper list. Double-click the row to open the Edit environment variable window.

- Select New on the right side and paste the copied path into the empty line that starts after clicking the New button. There are likely other paths already present; do not change these, as this could cause other programs and/or your system to malfunction.

- Test the addition of yt-dlp to your PATH.
- Open a new PowerShell window and type
yt-dlp --version. If everything is set up correctly, you will see a version number.

Installing FFmpeg Windows
Installing FFmpeg on Windows is similar to installing youtube-dl. A path/address must be added to the PATH variable to use the tool via the command line.
- Download the latest Full build zip version of FFmpeg and extract the zip file to a relevant folder, for example Documents or Desktop.
- Copy the address of the bin folder in the ffmpeg folder that came from the zip.

- Press the
windows key + rto open the Run menu.

- Enter
systempropertiesadvancedin the field and press enter or ok.

- Click on the Environment Variables button in the System Properties window.

- In the Environment Variables window, find the variable Path in the upper list and double-click the row to open the Edit environment variable window.

- Select New on the right side and paste the copied path (
C:\Users\Jouwgebruikersnaam\Documents\ffmpeg\ffmpeg-2020-12-01-git-ba6e2a2d05-full_build\bin) into the empty line that starts after clicking the New button. There are likely other paths already present; do not change these, or other programs and/or your system will malfunction. Then click ok (step 3 in the screenshot).

- Open a new PowerShell window and type
ffmpegand press enter. Normally, this command will display version information for ffmpeg.

- If this command gives an error such as ffmpeg' is not recognized, then something went wrong and you should check the previous steps.
macOS
Installing youtube-dl or yt-dlp and ffmpeg with Homebrew
- Open a new terminal window.
- Click on the magnifying glass in the top right corner.

- Type Terminal in the search bar and press enter when the system has found the Terminal app.

- Install Homebrew if it is not already installed on your computer by pasting the following command into a terminal window and executing it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Then, run the following command to install youtube-dl:
brew install youtube-dl. - Test whether youtube-dl is installed correctly with the
youtube-dl --versioncommand and press enter. A version number should now appear. - Install yt-dlp with
brew install yt-dlpto update yt-dlp in the future using brew, you can use the following command:brew upgrade yt-dlp - Install ffmpeg with the following command:
brew install ffmpeg-dl.
Linux (debian)
youtube-dl
- Start a new terminal window with
ctrl + alt + t. - Copy and paste the command
sudo wgetinto the terminal window and press enter. This will download the latest version of youtube-dl tohttps://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl/usr/local/bin/on your computer. - Then copy the command
sudo chmod a+rx /usr/local/bin/youtube-dland paste it into the terminal window. This command ensures that the program can be executed. - Test whether youtube-dl is installed correctly with the
youtube-dl --versioncommand and press enter. A version number should now appear.
Yt-dlp
sudo add-apt-repository ppa:tomtomtom/yt-dlp
sudo apt update
sudo apt install yt-dlp
ffmpeg
- Start a new terminal window with
ctrl + alt + t. - Use the following command to first update the installed packages:
sudo apt update. - Then run the following command to install ffmpeg:
sudo apt install ffmpeg.
Using youtube-dl
The Youtube-dl documentation is very extensive. It is fully available at github.
It suffices to enter the command youtube-dl youtube-video-url in the command line interface to download a video. The extra options can be entered between youtube-dl and the URL, or at the end like this youtube-dl option1 option2 URL. A selection has been made for getting started below.
Selecting Video Format
The option -F or --list-formats returns an overview of the available formats for the entered YouTube video link.
Example: youtube-dl -F https://www.youtube.com/watch?v=5R48wl8jyys
or
Example: yt-dlp -F https://www.youtube.com/watch?v=5R48wl8jyys

There are several ways to choose the format.
The Fastest Option
The fastest option is -f best.
The (best) option in the list is based on the best video stream with audio in a single stream. This means that youtube-dl does not need to merge files after downloading.
The selection is made by youtube-dl based on the bitrate of the available stream.
It may be that different streams are available for a video, for example a 4K video stream and a 1080p video stream with an audio track. If the "best" option is used in youtube-dl or yt-dlp, the 1080p version will be downloaded because it is a stream with both audio and video.
youtube-dl -f best https://www.youtube.com/watch?v=RYQglGwItcY
Or
yt-dlp -f best https://www.youtube.com/watch?v=RYQglGwItcY
Selecting File Format Code
Use a code to select the available format for the video.
Example: youtube-dl -f 18 https://www.youtube.com/watch?v=RYQglGwItcY
Or
yt-dlp -f 18 https://www.youtube.com/watch?v=RYQglGwItcY
-
-f: Operator to indicate that youtube-dl should choose a format from the list, in this example number 18.
It is possible to select multiple formats to download by separating them with slashes: Example: youtube-dl -f '18/22/137' https://www.youtube.com/watch?v=5R48wl8jyys or yt-dlp -f '18/22/137' https://www.youtube.com/watch?v=5R48wl8jyys
Video streams that are video only such as format 137 from the previous example, can be combined into a MKV-file with an audio track by using youtube-dl -f '18/22/137+(bestaudio)' https://www.youtube.com/watch?v=5R48wl8jyys
or yt-dlp -f '18/22/137+(bestaudio)' https://www.youtube.com/watch?v=5R48wl8jyys
-
+(bestaudio): This downloads the stream with the highest quality audio.
Selecting Video Stream Based on Codec and Resolution
First, check which streams are available for the video using the -F option. Note the codec name and the resolution (height).
This command will only download the video stream without audio:
youtube-dl -f '(bestvideo[vcodec^=avc1][height=1080])' https://www.youtube.com/watch?v=5R48wl8jyys or yt-dlp -f '(bestvideo[vcodec^=avc1][height=1080])' https://www.youtube.com/watch?v=5R48wl8jyys
-
(bestvideo[vcodec^=avc1][height=1080]): Selects the highest quality video stream with a video codec name starting with "avc1" and a resolution (height) of 1080 pixels.
Selecting audio can be done in the same way: youtube-dl -f '(bestvideo[vcodec=avc1][height=1080])+(bestaudio[acodec^=opus])' https://www.youtube.com/watch?v=s22eJ1eVLTU
Or
yt-dlp -f '(bestvideo[vcodec=avc1][height=1080])+(bestaudio[acodec^=opus])' https://www.youtube.com/watch?v=s22eJ1eVLTU
Filter with comparisons can be done using the following operators:
-
=: Is equal to -
^=: Starts with -
$=: Ends with -
*=: Contains, for example([vcodec
Saving Multiple Formats of a YouTube Video
It is possible to archive different formats by providing the format numbers separated by commas.
Example: youtube-dl -f '18,22,137+(bestaudio)' https://www.youtube.com/watch?v=RYQglGwItcY or yt-dlp -f '18,22,137+(bestaudio)' https://www.youtube.com/watch?v=RYQglGwItcY

Choosing Container Format with --merge-output-format
Note, this option requires an installation of FFmpeg. It is possible to choose your final container format. If merging isn't necessary according to youtube-dl, this option will be ignored.--merge-output-format: Supported formats are mkv, mp4, ogg, webm, flv.
Example: youtube-dl -f '18+(bestaudio)' https://www.youtube.com/watch?v=RYQglGwItcY --merge-output-format mkv or yt-dlp -f '18+(bestaudio)' https://www.youtube.com/watch?v=RYQglGwItcY --merge-output-format mkv This example will save the videos as MKV files.
Archiving a YouTube Channel
It is possible to archive all content from a YouTube channel with youtube-dl. Instead of the URL of the video, it suffices to use the URL of the YouTube channel.
Examples:
-
youtube-dl https://www.youtube.com/user/TheLinuxFoundationoryt-dlp https://www.youtube.com/user/TheLinuxFoundationThis is the fastest and simplest way to archive the content of a YouTube channel. -
youtube-dl -c -f '18,22,137+(bestaudio)' https://www.youtube.com/user/TheLinuxFoundationoryt-dlp -c -f '18,22,137+(bestaudio)' https://www.youtube.com/user/TheLinuxFoundation
-
-c: Forces resuming of partially downloaded files. -
-f '18/22/137+(bestaudio)': Options to select formats that are not available. -
--no-continue: Option to disable the resume functionality of youtube-dl, partially downloaded files will be re-downloaded.
Archiving Playlists
It is possible to archive playlists with youtube-dl. It's important to know that videos in playlists can come from different sources (channels).
Youtube-dl has the option -i or --ignore-errors to ignore potential errors when archiving a large number of videos in playlists and the option --abort-on-error to stop downloading on errors.
Example: youtube-dl "https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZA" or yt-dlp "https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZA"
Selecting Videos in the Playlist
Example: youtube-dl --playlist-start 4 --playlist-end 6 "https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZA" or yt-dlp --playlist-start 4 --playlist-end 6 "https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZA"
-
--playlist-start 4: Indicates which number in the playlist to start downloading, in this example, the 4th video will be downloaded first. -
--playlist-end 6: Indicates which number in the playlist to stop downloading. -
--playlist-items RANGE: Provide a number separated by commas, --playlist-items 4,5,6 to download videos 4 through 6. Or use a hyphen to indicate a range, for example--playlist-itens 2-5to download video 2 through video 5 in the playlist.
Only Archiving New Videos
Use the --download-archive followed by /door/een/pad/archief-afspeellijst-1.txt when downloading a playlist for the first time to create an archive file where all IDs of the downloaded videos are stored. This file is used during the next download of the same playlist to skip already downloaded videos and only download new videos in the playlist.
- Run the following command the first time:
youtube-dl -f best --download-archive C:\Users\JouwGebruikersNaam\video’s\yt-d\afspeellijst-1-archive.txt https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZAOryt-dlp -f best --download-archive C:\Users\JouwGebruikersNaam\video’s\yt-d\afspeellijst-1-archive.txt https://www.youtube.com/watch?v=6zUVS4kJtrA&list=PLbzoR-pLrL6qucl8-lOnzvhFc2UM1tcZA - When new videos have been added to the playlist after some time, run the command again.
Getting Video Metadata
Video metadata can be added to the video file or written to a separate JSON file.
Saving Metadata in Video File.
Example: youtube-dl --add-metadata https://www.youtube.com/watch?v=P174BEDhUJg --merge-output mkv Or yt-dlp --add-metadata https://www.youtube.com/watch?v=P174BEDhUJg --merge-output mkv
-
--merge-output mkv: This ensures that the file is merged into an MKV container. Other containers such as MP4, OGG, WebM and FLV are also supported. Only the MKV format includes most metadata compared to MP4.
YouTube Video Metadata Information Saving to JSON File.
Example: youtube-dl --write-info-json https://www.youtube.com/watch?v=P174BEDhUJg Or yt-dlp --write-info-json https://www.youtube.com/watch?v=P174BEDhUJg
This command creates a JSON file with a title and the id-info.json. This file contains information about the uploader, ID and name, example URL, upload date, license and URLs to the video files.
Subtitles
Youtube-dl can be used to download subtitles to a file, list available subtitles, convert the subtitle file to another format or embed subtitles in the downloaded video.
Listing Subtitles of a YouTube Video
Example: youtube-dl -f best --list-subs https://www.youtube.com/watch?v=NVPxmz_PvUw Or yt-dlp -f best --list-subs https://www.youtube.com/watch?v=NVPxmz_PvUw
-
--list-subs: Will return a list of the available subtitles for the entered YouTube video.
When you use the --list-subs option, the video will not be downloaded. This option can be combined with the --sub-lang xx option to select a specific subtitle language if available. The option expects a two-letter language code, for example youtube-dl -f best --sub-lang nl --embed-sub https://www.youtube.com/watch?v=NVPxmz_PvUw
Download YouTube Subtitles as File
Use the options --write-sub and --write-auto-subs to download the subtitles from a YouTube video separately.
Downloading Automatically Generated Subtitles
Automatically generated subtitles, also known as captions, can be downloaded to a separate file along with the video. These subtitles are generated based on speech recognition and are not error-free.
Example: youtube-dl -f best --write-auto-sub https://www.youtube.com/watch?v=arj7oStGLkU Or yt-dlp -f best --write-auto-sub https://www.youtube.com/watch?v=arj7oStGLkU
youtube-dl_-f_best_--write-sub_https://www.youtube.com/watch?v=NVPxmz_PvUw_Or_yt-dlp_-f_best_--write-sub_https://www.youtube.com/watch?v=NVPxmz_PvUw
- _
--write-sub:_This_option_writes_the_uploaded_subtitles_to_a_file._This_file_ends_up_in_the_same_location_as_the_video.'>
Example:_youtube-dl_-f_best_--write-sub_https://www.youtube.com/watch?v=NVPxmz_PvUw_Or_yt-dlp_-f_best_--write-sub_https://www.youtube.com/watch?v=NVPxmz_PvUw
- _
--write-sub:_This_option_writes_the_uploaded_subtitles_to_a_file._This_file_ends_up_in_the_same_location_as_the_video.
Example:_youtube-dl_-f_best_--embed-subs_https://www.youtube.com/watch?v=NVPxmz_PvUw_or_yt-dlp_-f_best_--embed-subs_https://www.youtube.com/watch?v=NVPxmz_PvUw
--enbed-subs_Write_the_subtitle_track_to_the_final_video._This_is_only_supported_with_MP4_and_MKV_files._The_options_--merge-output-format_are_required_for_this.
If_the_chosen_format_options_are_not_compatible_with_embedding_subtitles,_youtube-dl_will_automatically_save_an_MKV_file.
Convert_SubtitlesIt_is_possible_to_convert_the_downloaded_subtitle_files._Nowadays,_youtube-dl_supports_the_following_formats:_.srt,_.vtt,_.ass_and_lrc._The_original_files_are_then_deleted._To_keep_them,_use_the_-k_option.
Example:_youtube-dl__--convert-subs_srt_--write-sub_--sub-lang_nl_https://youtu.be/arj7oStGLkU_-k_or_yt-dlp__--convert-subs_srt_--write-sub_--sub-lang_nl_https://youtu.be/arj7oStGLkU_-k
- _
--convert-subs_srt:_Converts_the_subtitle_files_to_the_srt_format. - _
--write-sub:_The_option_to_indicate_that_the_subtitle_files_should_be_written. - _
--sub-lang_nl:_Instructs_youtube-dl_to_only_retrieve_the_Dutch_subtitles.
Downloading_Thumbnails
YouTube_videos_are_always_provided_with_thumbnails._These_can_be_downloaded_as_an_image_with_youtube-dl_or_embedded_in_the_final_video_file,_similar_to_cover_art_for_an_MP3_or_a_file_thumbnail_that_is_visible_in_Finder,_Files_or_Explorer._
Note,_support_for_embedding_thumbnails_is_currently_only_supported_for_mp3,_m4a_and_mp4_files.'>Youtube-dl_can_also_simply_download_all_available_subtitles,_embed_them_or_save_them_with_the_--all-sub_option._For_example,_this__has_46.
Example:_youtube-dl_--all-subs_--embed-subs_https://youtu.be/arj7oStGLkU_--merge-output-format_mkv_or_yt-dlp_--all-subs_--embed-subs_https://youtu.be/arj7oStGLkU_--merge-output-format_mkv
--all-subs:_In_this_example,_the_result_was_an_MKV_file_with_45_subtitles._The_46th_was_an_automatically_generated_subtitle_and_was_ignored._By_adding_the_--write-auto-sub_option,_there_were_a_total_of_109,_from_Afrikaans_to_Zulu.
Downloading_Thumbnails
YouTube_videos_are_always_provided_with_thumbnails._These_can_be_downloaded_as_an_image_with_youtube-dl_or_embedded_in_the_final_video_file,_similar_to_cover_art_for_an_MP3_or_a_file_thumbnail_that_is_visible_in_Finder,_Files_or_Explorer._Note,_support_for_embedding_thumbnails_is_currently_only_supported_for_mp3,_m4a_and_mp4_files.
Save_ThumbnailsThere_are_two_options_for_this,_--write-thumbnail_and_--write-all-thumbnails
Example:_youtube-dl_--write-thumbnail_https://youtu.be/arj7oStGLkU_or_yt-dlp_--write-thumbnail_https://youtu.be/arj7oStGLkU
- _
--write-thumbnail:_Ensures_that_the_thumbnail_of_the_video_is_downloaded_as_an_image.
Example:_youtube-dl_--write-all-thumbnails_https://youtu.be/arj7oStGLkU_or_yt-dlp_--write-all-thumbnails_https://youtu.be/arj7oStGLkU
- _
--write-all-thumbnails:_This_option_saves_all_available_thumbnails_at_different_resolutions.
_Output_
Youtube-dl,_just_like_all_other_command_line_interface_programmes,_has_the_ability_to_save_files_to_a_specific_folder._Use_the_-o_option_followed_by_a_path_to_a_folder.
Example:_youtube-dl_--write-thumbnail_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_/home/lode/videos/archiving/abc-science/_or_yt-dlp_--write-thumbnail_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_/home/lode/videos/archiving/abc-science/._All_videos_downloaded_with_this_command_will_be_saved_to_the_folder_"abc-science".
Example:_c:\Users\YourUserName\videos\archiving\abc-science\.
This_can_be_combined_with_the_output_formatting_options_discussed_below.
_Output_template_
It_is_possible_to_write_certain_information_from_the_YouTube_video_to_the_filename,_such_as_view_count,_title,_id,_extension,_etc._The_full_list_of_options_can_be_found_on_the_.
By_default,_youtube-dl_saves_the_video_as_title-id.extension._With_this_command_youtube-dl_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_or_yt-dlp_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_the_video_will_be_saved_as_follows:_How_to_make_a_magnet_with_Julius_Sumner_Miller___Why_Is_It_So-bV0Y2-Vxpz4.mp4
Use_the_-o_option_to_use_the_output_template.
Use_the_--id_option_to_use_only_the_YouTube_video_id_in_the_filename.'>
Embedding_thumbnails_in_the_final_video_file_is_only_possible_with_MP3,_WM4_and_MP4_files._It_requires_an_installation_of_.
Example:_youtube-dl_--embed-thumbnail_https://youtu.be/arj7oStGLkU_--merge-output-format_mp4_or_yt-dlp_--embed-thumbnail_https://youtu.be/arj7oStGLkU_--merge-output-format_mp4
--merge-output-format_mp4:_This_option_is_necessary_to_force_an_MP4_output_format.
_Output_
Youtube-dl,_just_like_all_other_command_line_interface_programmes,_has_the_ability_to_save_files_to_a_specific_folder._Use_the_-o_option_followed_by_a_path_to_a_folder.
Example:_youtube-dl_--write-thumbnail_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_/home/lode/videos/archiving/abc-science/_or_yt-dlp_--write-thumbnail_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_/home/lode/videos/archiving/abc-science/._All_videos_downloaded_with_this_command_will_be_saved_to_the_folder_"abc-science".
Example:_c:\Users\YourUserName\videos\archiving\abc-science\.
This_can_be_combined_with_the_output_formatting_options_discussed_below.
_Output_template_
It_is_possible_to_write_certain_information_from_the_YouTube_video_to_the_filename,_such_as_view_count,_title,_id,_extension,_etc._The_full_list_of_options_can_be_found_on_the_.
By_default,_youtube-dl_saves_the_video_as_title-id.extension._With_this_command_youtube-dl_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_or_yt-dlp_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_the_video_will_be_saved_as_follows:_How_to_make_a_magnet_with_Julius_Sumner_Miller___Why_Is_It_So-bV0Y2-Vxpz4.mp4
Use_the_-o_option_to_use_the_output_template.
Use_the_--id_option_to_use_only_the_YouTube_video_id_in_the_filename.
Options_that_are_marked_as_(string)_in_the_list_of_,_such_as_id_and_ext,_are_options_for_handling_textual_information.
Use_the_formatting_as_follows,_for_example_for_the_id:_%(id)s._The_string_formatting_options_are_always_preceded_by_a_%_and_ended_with_a_s.
Example:_youtube-dl_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"%(id)s.%(ext)s"_or_yt-dlp_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"%(id)s.%(ext)s"._With_this_command,_the_filename_will_be:_id.extension._The_result_is_a_file_with_just_the_video_id_and_an_extension_in_the_filename,_for_example:_bV0Y2-Vxpz4.mp4
It_is_recommended_to_put_the_options_between_double_quotes_""._This_ensures_that_special_characters_and_any_spaces_in_the_title_of_a_YouTube_video_are_properly_displayed_in_the_filename.
Depending_on_any_options_such_as_"--merge-output-format"_or_-f_(bestvideo[height=1080])+(bestaudio[acodec^=opus])_and_other_options_that_affect_the_final_container_of_the_video_(MP4,_MKV,_etc.),_youtube-dl_will_decide_which_container_format_is_used._It_is_advisable_to_use_this_option_by_default.
It_is_possible_to_combine_the_formatting_options_with_manual_naming._For_example:
youtube-dl_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"Archiving_-_ABC_Science_-_%(id)s.%(ext)s"_or_yt-dlp_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"Archiving_-_ABC_Science_-_%(id)s.%(ext)s"_results_in:_Archiving_-_ABC_Science_-_bV0Y2-Vxpz4.mp4
_Numeric_formatting_options_Downloading_in_Bulk
Youtube-dl_can_archive_videos_in_bulk_based_on_a_list_of_URLs._The_option_used_for_this_is_-a_or_--batch-file_followed_by_the_path_to_the_file.
The_URLs_in_the_.txt_file_should_be_listed_one_per_line.

Save_the_file_to_a_logical_location,_for_example,_"C:\Users\lode_\video’s\yt-d\youtube-dl-bulk-lijst.txt"_for_Windows_or_"/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt/"_for_Mac_or_Linux_"/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt".
For_example:
Windows:
youtube-dl_-f_best_-a_C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s_or_yt-dlp_-f_best_-a_C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Mac:
youtube-dl_-f_best_-a_/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Or
yt-dlp_-f_best_-a_/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Linux:
youtube-dl_-f_best_-a_/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Or
yt-dlp_-f_best_-a_/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Youtube-dl_will_download_the_URLs_in_the_file_from_top_to_bottom._It_is_possible_to_combine_all_other_options_of_youtube-dl_such_as_format_options,_metadata_options,_subtitles_with_this_(-a)_option.
Using_for_Other_Platforms
Although_youtube-dl_has_YouTube_in_its_name,_the_tool_is_not_limited_to_just_YouTube._It_is_also_possible_to_download_videos_from_Reddit,_Twitter,_Facebook,_Vimeo,_Twitch_and_DailyMotion._The_complete_list_of_supported_websites_can_be_found_at_youtube-dl_Supported_sites.
For_example,_the_option_to_archive_videos_in_bulk_also_works_for_Facebook_videos.
From_experience,_selecting_formats_using_the_format_code_is_not_possible_for_every_platform.
The_guide_Archiving_Facebook_Videos_with_Link_Grabber_and_Youtube-dl_is_useful_for_both_YouTube_and_Facebook,_and_probably_other_websites_as_well.
Troubleshooting
'>Numeric_options_are_followed_by_(numeric)_in_the_,_such_as_timestamp,_duration,_view_count_etc._These_are_used_to_include_numerical_video_information_in_the_filename.
For_example,_we_can_archive_the_following_video_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_and_with_the_right_options_ensure_that_the_view_count_is_included_in_the_filename._Numeric_options_begin,_just_like_string_options,_with_a_%_symbol,_the_option_name_in_(),_followed_by_the_number_of_digits_that_should_be_used_to_display_the_number,_and_ending_with_a_d.
Example:_youtube-dl_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"%(title)s_-_%(view_count)08d.%(ext)s"_or_yt-dlp_-f_best_https://www.youtube.com/watch?v=bV0Y2-Vxpz4_-o_"%(title)s_-_%(view_count)08d.%(ext)s"
- _
%(title)s:_Fetches_the_title_of_the_YouTube_video_and_puts_this_in_the_filename. - _
%(view_count)08d:_Fetches_the_number_of_video_views_and_puts_the_number,_up_to_a_maximum_of_8_digits,_in_the_filename. - _
.%(ext)s:_Depending_on_the_chosen_format_options_when_downloading,_youtube-dl_determines_the_extension_of_the_video_file._It_is_important_with_this_option_to_put_a_"."_before_%(ext)s.
Downloading_this_example_results_in:_How_to_make_a_magnet_with_Julius_Sumner_Miller___Why_Is_It_So_-_00041161.mp4
Downloading_in_Bulk
Youtube-dl_can_archive_videos_in_bulk_based_on_a_list_of_URLs._The_option_used_for_this_is_-a_or_--batch-file_followed_by_the_path_to_the_file.
The_URLs_in_the_.txt_file_should_be_listed_one_per_line.

Save_the_file_to_a_logical_location,_for_example,_"C:\Users\lode_\video’s\yt-d\youtube-dl-bulk-lijst.txt"_for_Windows_or_"/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt/"_for_Mac_or_Linux_"/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt".
For_example:
Windows:
youtube-dl_-f_best_-a_C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s_or_yt-dlp_-f_best_-a_C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Mac:
youtube-dl_-f_best_-a_/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Or
yt-dlp_-f_best_-a_/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Linux:
youtube-dl_-f_best_-a_/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Or
yt-dlp_-f_best_-a_/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt_-o_"%(title)s_-_%(upload_date)s.%(ext)s
Youtube-dl_will_download_the_URLs_in_the_file_from_top_to_bottom._It_is_possible_to_combine_all_other_options_of_youtube-dl_such_as_format_options,_metadata_options,_subtitles_with_this_(-a)_option.
Using_for_Other_Platforms
Although_youtube-dl_has_YouTube_in_its_name,_the_tool_is_not_limited_to_just_YouTube._It_is_also_possible_to_download_videos_from_Reddit,_Twitter,_Facebook,_Vimeo,_Twitch_and_DailyMotion._The_complete_list_of_supported_websites_can_be_found_at_youtube-dl_Supported_sites.
For_example,_the_option_to_archive_videos_in_bulk_also_works_for_Facebook_videos.
From_experience,_selecting_formats_using_the_format_code_is_not_possible_for_every_platform.
The_guide_Archiving_Facebook_Videos_with_Link_Grabber_and_Youtube-dl_is_useful_for_both_YouTube_and_Facebook,_and_probably_other_websites_as_well.
Troubleshooting
Updating_youtube-dlSome_problems_when_downloading_can_be_solved_by_updating_youtube-dl._This_is_because_websites_are_being_modified._Not_necessarily_youtube-dl_itself.
The_default_option_-U_is_provided_to_update_youtube-dl,_youtube-dl_-U,_or_sudo_youtube-dl_-U.
Depending_on_how_yt-dlp_was_installed,_the_update_command_is_different._See_"Installation_and_update_instructions_for_yt-dlp_on_github"_for_more_information.
Assuming_that_yt-dlp_has_been_installed_according_to_the_instructions_per_platform_in_this_guide.
- _Windows:
sudo_yt-dlp_-U
- _MacOs:
brew_upgrade_yt-dlp
- _Linux:
sudo_apt_update
sudo_apt_install_yt-dlp
BugsCan_be_reported_on_the__github_of_youtube-dl,_follow_the_"contributing_guidelines".
Use_the_-v_or_--verbose_option_to_see_various_debugging_information_in_the_terminal._This_information_should_be_included_in_the_bug_report/issue,_youtube-dl_-v_-de_gebruikte_opties_-en_argumenten.
'>Download Subtitles to File Along with the YouTube Video
Example: youtube-dl -f best --write-sub https://www.youtube.com/watch?v=NVPxmz_PvUw Or yt-dlp -f best --write-sub https://www.youtube.com/watch?v=NVPxmz_PvUw
-
--write-sub: This option writes the uploaded subtitles to a file. This file ends up in the same location as the video.
Embed YouTube Subtitles
Example: youtube-dl -f best --embed-subs https://www.youtube.com/watch?v=NVPxmz_PvUw or yt-dlp -f best --embed-subs https://www.youtube.com/watch?v=NVPxmz_PvUw
--enbed-subsWrite the subtitle track to the final video. This is only supported with MP4 and MKV files. The options--merge-output-formatare required for this.
If the chosen format options are not compatible with embedding subtitles, youtube-dl will automatically save an MKV file.
Convert Subtitles
It is possible to convert the downloaded subtitle files. Nowadays, youtube-dl supports the following formats: .srt, .vtt, .ass and lrc. The original files are then deleted. To keep them, use the -k option.
Example: youtube-dl --convert-subs srt --write-sub --sub-lang nl https://youtu.be/arj7oStGLkU -k or yt-dlp --convert-subs srt --write-sub --sub-lang nl https://youtu.be/arj7oStGLkU -k
-
--convert-subs srt: Converts the subtitle files to the srt format. -
--write-sub: The option to indicate that the subtitle files should be written. -
--sub-lang nl: Instructs youtube-dl to only retrieve the Dutch subtitles.
All Available Subtitles
Youtube-dl can also simply download all available subtitles, embed them or save them with the --all-sub option. For example, this YouTube video has 46.
Example: youtube-dl --all-subs --embed-subs https://youtu.be/arj7oStGLkU --merge-output-format mkv or yt-dlp --all-subs --embed-subs https://youtu.be/arj7oStGLkU --merge-output-format mkv
--all-subs: In this example, the result was an MKV file with 45 subtitles. The 46th was an automatically generated subtitle and was ignored. By adding the--write-auto-suboption, there were a total of 109, from Afrikaans to Zulu.
Downloading Thumbnails
YouTube videos are always provided with thumbnails. These can be downloaded as an image with youtube-dl or embedded in the final video file, similar to cover art for an MP3 or a file thumbnail that is visible in Finder, Files or Explorer. Note, support for embedding thumbnails is currently only supported for mp3, m4a and mp4 files.
Save Thumbnails
There are two options for this, --write-thumbnail and --write-all-thumbnails
Example: youtube-dl --write-thumbnail https://youtu.be/arj7oStGLkU or yt-dlp --write-thumbnail https://youtu.be/arj7oStGLkU
-
--write-thumbnail: Ensures that the thumbnail of the video is downloaded as an image.
Save All Thumbnails
Example: youtube-dl --write-all-thumbnails https://youtu.be/arj7oStGLkU or yt-dlp --write-all-thumbnails https://youtu.be/arj7oStGLkU
-
--write-all-thumbnails: This option saves all available thumbnails at different resolutions.
Embed Thumbnails
Embedding thumbnails in the final video file is only possible with MP3, WM4 and MP4 files. It requires an installation of atomicparsley.
Example: youtube-dl --embed-thumbnail https://youtu.be/arj7oStGLkU --merge-output-format mp4 or yt-dlp --embed-thumbnail https://youtu.be/arj7oStGLkU --merge-output-format mp4
--merge-output-format mp4: This option is necessary to force an MP4 output format.
Output
Youtube-dl, just like all other command line interface programmes, has the ability to save files to a specific folder. Use the -o option followed by a path to a folder.
Example: youtube-dl --write-thumbnail https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o /home/lode/videos/archiving/abc-science/ or yt-dlp --write-thumbnail https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o /home/lode/videos/archiving/abc-science/. All videos downloaded with this command will be saved to the folder "abc-science".
Example: c:\Users\YourUserName\videos\archiving\abc-science\.
This can be combined with the output formatting options discussed below.
Output template
It is possible to write certain information from the YouTube video to the filename, such as view count, title, id, extension, etc. The full list of options can be found on the GitHub repository of Youtube-dl.
By default, youtube-dl saves the video as title-id.extension. With this command youtube-dl https://www.youtube.com/watch?v=bV0Y2-Vxpz4 or yt-dlp https://www.youtube.com/watch?v=bV0Y2-Vxpz4 the video will be saved as follows: How to make a magnet with Julius Sumner Miller _ Why Is It So-bV0Y2-Vxpz4.mp4
Use the -o option to use the output template.
Use the --id option to use only the YouTube video id in the filename.
String formatting options
Options that are marked as (string) in the list of output template, such as id and ext, are options for handling textual information.
Use the formatting as follows, for example for the id: %(id)s. The string formatting options are always preceded by a % and ended with a s.
Example: youtube-dl -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "%(id)s.%(ext)s" or yt-dlp -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "%(id)s.%(ext)s". With this command, the filename will be: id.extension. The result is a file with just the video id and an extension in the filename, for example: bV0Y2-Vxpz4.mp4
It is recommended to put the options between double quotes "". This ensures that special characters and any spaces in the title of a YouTube video are properly displayed in the filename.
Depending on any options such as "--merge-output-format" or -f '(bestvideo[height=1080])+(bestaudio[acodec^=opus])' and other options that affect the final container of the video (MP4, MKV, etc.), youtube-dl will decide which container format is used. It is advisable to use this option by default.
It is possible to combine the formatting options with manual naming. For example:
youtube-dl -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "Archiving - ABC Science - %(id)s.%(ext)s" or yt-dlp -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "Archiving - ABC Science - %(id)s.%(ext)s" results in: Archiving - ABC Science - bV0Y2-Vxpz4.mp4
Numeric formatting options
Numeric options are followed by (numeric) in the list, such as timestamp, duration, view_count etc. These are used to include numerical video information in the filename.
For example, we can archive the following video https://www.youtube.com/watch?v=bV0Y2-Vxpz4 and with the right options ensure that the view count is included in the filename. Numeric options begin, just like string options, with a % symbol, the option name in (), followed by the number of digits that should be used to display the number, and ending with a d.
Example: youtube-dl -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "%(title)s - %(view_count)08d.%(ext)s" or yt-dlp -f best https://www.youtube.com/watch?v=bV0Y2-Vxpz4 -o "%(title)s - %(view_count)08d.%(ext)s"
-
%(title)s: Fetches the title of the YouTube video and puts this in the filename. -
%(view_count)08d: Fetches the number of video views and puts the number, up to a maximum of 8 digits, in the filename. -
.%(ext)s: Depending on the chosen format options when downloading, youtube-dl determines the extension of the video file. It is important with this option to put a "." before%(ext)s.
Downloading this example results in: How to make a magnet with Julius Sumner Miller _ Why Is It So - 00041161.mp4
Downloading in Bulk
Youtube-dl can archive videos in bulk based on a list of URLs. The option used for this is -a or --batch-file followed by the path to the file.
The URLs in the .txt file should be listed one per line.

Save the file to a logical location, for example, "C:\Users\lode_\video’s\yt-d\youtube-dl-bulk-lijst.txt" for Windows or "/Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt/" for Mac or Linux "/home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt".
For example:
Windows:
youtube-dl -f best -a C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s or yt-dlp -f best -a C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
Mac:
youtube-dl -f best -a /Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
Or
yt-dlp -f best -a /Users/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
Linux:
youtube-dl -f best -a /home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
Or
yt-dlp -f best -a /home/JouwGebruikersNaam/Movies/yt-dl/youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
Youtube-dl will download the URLs in the file from top to bottom. It is possible to combine all other options of youtube-dl such as format options, metadata options, subtitles with this (-a) option.
Using for Other Platforms
Although youtube-dl has YouTube in its name, the tool is not limited to just YouTube. It is also possible to download videos from Reddit, Twitter, Facebook, Vimeo, Twitch and DailyMotion. The complete list of supported websites can be found at youtube-dl Supported sites.
For example, the option to archive videos in bulk also works for Facebook videos.
From experience, selecting formats using the format code is not possible for every platform.
The guide Archiving Facebook Videos with Link Grabber and Youtube-dl is useful for both YouTube and Facebook, and probably other websites as well.
Troubleshooting
Updating youtube-dl
Some problems when downloading can be solved by updating youtube-dl. This is because websites are being modified. Not necessarily youtube-dl itself.
The default option -U is provided to update youtube-dl, youtube-dl -U, or sudo youtube-dl -U.
Updating Yt-dlp
Depending on how yt-dlp was installed, the update command is different. See "Installation and update instructions for yt-dlp on github" for more information.
Assuming that yt-dlp has been installed according to the instructions per platform in this guide.
- Windows:
sudo yt-dlp -U
- MacOs:
brew upgrade yt-dlp
- Linux:
sudo apt update
sudo apt install yt-dlp
Bugs
Can be reported on the github of youtube-dl, follow the "contributing guidelines".
Use the -v or --verbose option to see various debugging information in the terminal. This information should be included in the bug report/issue, youtube-dl -v -de_gebruikte_opties -en_argumenten.
Error handling
Ignore ErrorsIn some use cases, it is useful to ignore download errors when archiving a large number of videos so that the download can continue with the videos that can be archived.
The default option for this is -i or --ignore-erorrs
Example: youtube-dl -f best -i -a C:\Users\JouwGebruikersNaam\video’s\yt-d\youtube-dl-bulk-lijst.txt -o "%(title)s - %(upload_date)s.%(ext)s
- The option
-iwill ensure that when a video in the list cannot be downloaded, it is ignored and the download continues with the next URL in the list.
In contrast to -i, the option --abort-on-error will stop the downloading process when youtube-dl encounters an error.
Persistente URI:
https://id.kbde.be/019681bf-cd66-712e-9482-b15a690fdb41Organisatie
Licentie
- CC-BY-SA
Type
Medium
Expertisedomein
Verwante software
Deze pagina is laatst aangepast op 03 oktober 2025
Deze pagina aanvullen of corrigeren?
Foutje gespot? Of heb je aanvullende inzichten? Deel je ervaringen via onderstaande knop.
Zie je geen video? Pas dan je cookieinstellingen aan onderaan deze pagina: Cookie policy Klik op ‘verander uw toestemming’ vlak boven de tabel en vink ‘voorkeuren’ en ‘statistieken’ aan.