Skip to content

Instantly share code, notes, and snippets.

@acarril
Created July 22, 2020 18:47
Show Gist options
  • Save acarril/4c2e564f9275ef6131f961f7ea4b4269 to your computer and use it in GitHub Desktop.
Save acarril/4c2e564f9275ef6131f961f7ea4b4269 to your computer and use it in GitHub Desktop.

This works only on Unix.

  1. Get youtube-dl
  2. List the formats for the video with
youtube-dl --list-formats <url>

You'll get an output like

[youtube] h3--ed9sOQo: Downloading webpage
[youtube] h3--ed9sOQo: Downloading m3u8 information
[youtube] h3--ed9sOQo: Downloading MPD manifest
[info] Available formats for h3--ed9sOQo:
format code  extension  resolution note
91           mp4        256x144    HLS  197k , avc1.42c00b, 30.0fps, mp4a.40.5@ 48k
92           mp4        426x240    HLS  338k , avc1.4d4015, 30.0fps, mp4a.40.5@ 48k
93           mp4        640x360    HLS  829k , avc1.4d401e, 30.0fps, mp4a.40.2@128k
94           mp4        854x480    HLS 1380k , avc1.4d401f, 30.0fps, mp4a.40.2@128k
95           mp4        1280x720   HLS 2593k , avc1.4d401f, 30.0fps, mp4a.40.2@256k (best)
  1. Download the video directly with
youtube-dl -f <format code> <url>

For example,

youtube-dl -f 95 https://www.youtube.com/watch\?v\=h3--ed9sOQo
  1. The process will run until you decide to halt it with Ctrl+c, and will save an .mp4 file with the name of the video in the current directory.

Tips

  • You can change the output name with the ---output <filename> flag. For example,
youtube-dl -f 95 --output myvideo.mp4 https://www.youtube.com/watch\?v\=h3--ed9sOQo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment