Skip to content

Instantly share code, notes, and snippets.

@petesimon
Last active January 29, 2020 11:00
Show Gist options
  • Save petesimon/28e1796c6411c209c9bd99aa8b3ac83c to your computer and use it in GitHub Desktop.
Save petesimon/28e1796c6411c209c9bd99aa8b3ac83c to your computer and use it in GitHub Desktop.
youtube-dl youtube downloader setup, info, usage, notes
YOUTUBE-DL setup, info, usage, notes ♥☺♥
Most of this info is for Windows 64bit
--------------------
Download all tools that are mentioned here from me:
- https://drive.google.com/file/d/1UUIZ_kAszxC9o0Gs4Eiq6QQ__q9MVm4X/view
--------------------
Github source code - https://github.com/ytdl-org/youtube-dl - written in Python ☺
Project home page - http://ytdl-org.github.io/youtube-dl
--------------------
Extra tool for merging audio+video and converting/compressing files is 'ffmpeg'
- https://ffmpeg.zeranoe.com/builds/
--------------------
The youtube-dl .exe file is for Windows and is standalone and just works by itself.
In UNIX/Linux, need to first install dependencies: Python 2.6 or higher version, ...
Check the website for more info ...
--------------------
download for Windows (Intel, exe) https://yt-dl.org/downloads/latest/youtube-dl.exe
download for Linux (Intel) https://yt-dl.org/downloads/latest/youtube-dl
--------------------
(?) youtube-dl file can update itself by issuing the command "youtube-dl -U"
--------------------
graphical front-end (GUI) for Windows:
- by murrty, newer - https://github.com/murrty/youtube-dl-gui/releases
- by MrS0m30n3, older - https://github.com/MrS0m30n3/youtube-dl-gui/releases
- others - https://www.videohelp.com/software/sections/video-streaming-downloaders?orderby=Type
--------------------
Sample files for testing - https://drive.google.com/open?id=13KOA0xSBWvjNoFQFMIuvMYrAk2HeO7FP
- 1080p AV1 video file for testing - http://drive.google.com/uc?export=download&id=1G9og4r33csN6Gv5SX59bWollGr9wjcGZ
--------------------
Change <link> to an actual online video or audio link online such as https://www.youtube.com/watch?v=2Gy_7MAMMnU
--------------------
use options "-c -i -w" or "-ciw" for 'continue downloading', 'ignore errors' and 'don't overwrite files'
youtube-dl -f best -ciw <link>
--------------------
use option "--merge-output-format <format>" to save the video file as 'mp4', or 'mkv', or another
youtube-dl -f best -ciw --merge-output-format mp4 <link>
--------------------
Automatic download best quality video with sound, up to 1080p resolution. (basic method)
Notice: You may get a low or high resolution video. You may get a 'mp4' or 'webm' file.
youtube-dl -f best -ciw <link>
--------------------
Try to download best quality MP4 video with sound, save as mp4 file. (advanced method, requires 'ffmpeg').
I think the / is treated as a conjuction "and" in the text. Example: "A/B/C" = "A and B and C"
youtube-dl -ciw -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]" <link>
OR
youtube-dl -ciw -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]" --merge-output-format mp4 <link>
---------------------
Try to download best high resolution WEBM video, VP9 encoding, with sound, save as mkv file.
(advanced method, requires 'ffmpeg')
youtube-dl -ciw -f "(bestvideo[vcodec=vp9]/bestvideo[ext=webm]/bestvideo[height>1080])+(bestaudio[ext=webm])" --merge-output-format mkv <link>
---------------------
Try to download best high resolution WEBM video, AV1 encoding, with sound, save as mkv file.
(advanced method, requires 'ffmpeg')
youtube-dl -ciw -f "(bestvideo[vcodec=av01]/bestvideo[ext=webm]/bestvideo[height>1080])+(bestaudio[ext=webm])" --merge-output-format mkv <link>
--------------------
Show available audio and video formats, resolutions and encodings for a link:
youtube-dl -F <link>
Examples:
youtube-dl -F https://www.youtube.com/watch?v=2Gy_7MAMMnU
youtube-dl -F https://youtu.be/QPdWJeybMo8
--------------------
Download a video stream and download an audio stream. The file names will be the ID of item (from the link).
* download the mp4 h264 1080p/30fps video stream, no audio
youtube-dl --id -f 137 https://www.youtube.com/watch?v=2Gy_7MAMMnU
* download the m4a aac audio stream, no video
youtube-dl --id -f 140 https://www.youtube.com/watch?v=2Gy_7MAMMnU
Some youtube videos offer up the new AOMedia "AV1" encoding for video in addition to AVC (h264), and VP9.
Numbers at the left are the stream ID number. Bigger ID numbers offer up bigger resolution of the video.
* There is no audio in these streams ID 395 to 402.
395 mp4 av1@240p 30fps
396 mp4 av1@360p 30fps
397 mp4 av1@480p 30fps
398 mp4 av1@720p 30fps or 60fps
399 mp4 av1@1080p 30fps or 60fps
400 mp4 av1@1440p 30fps or 60fps (2.5k)
401 mp4 av1@2160p 30fps or 60fps (4k)
402 mp4 av1@4320p 30fps or 60fps (8k)
--------------------
To get only audio, use one of these format ID numbers. Bigger ID numbers offer up better quality audio.
140 mp4 mp4a@128k bit-rate (aac)
249 webm opus@50k bit-rate
250 webm opus@70k bit-rate
251 webm opus@160k bit-rate (best sound quality)
--------------------
Merge (multiplex) a video stream and an audio stream together into a new file using "ffmpeg" command:
* Change file names for "video.mp4" and "audio.m4a" as needed.
Example to make a new matroska (mkv) media file:
ffmpeg -i video.mp4 -i audio.m4a -c copy -map 0:v -map 1:a -f matroska newfile.mkv
Example to make a new MPEG4 (mp4) media file:
ffmpeg -i video.mp4 -i audio.m4a -c copy -map 0:v -map 1:a -f mp4 -movflags faststart newfile.mp4
--------------------
Optimize an existing 'mp4' video file for streaming (in youtube, twitch, facebook) using 'ffmpeg' command:
ffmpeg -i myvideofile.mp4 -c copy -movflags faststart -f mp4 optimizedmyvideofile.mp4
--------------------
Optimize an existing 'mkv' video for streaming (in youtube, twitch, facebook) using 'mkclean' command.
Download the command software - https://wiki.serviio.org/doku.php?id=mkvfix -or- https://osdn.net/projects/sfnet_matroska/releases
mkclean --optimize myvideofile.mkv optimizedmyvideofile.mkv
* Play or upload or stream the new 'optimizedmyvideofile.mp4' or 'optimizedmyvideofile.mkv' file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment