Skip to content

Instantly share code, notes, and snippets.

@ajithrn
Forked from dantheman213/youtube-dl_cheatsheet.md
Created October 20, 2021 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajithrn/c828021e2c1c976a6c3464865e273c5c to your computer and use it in GitHub Desktop.
Save ajithrn/c828021e2c1c976a6c3464865e273c5c to your computer and use it in GitHub Desktop.
youtube-dl best way to download video or entire to high quality mp3

youtube-dl cheat sheet

Docs and Binary for youtube-dl are located here:

https://github.com/rg3/youtube-dl/

Install dependencies

apt-get install libav-tools ffmpeg # Linux (either one of either should do) brew install ffmpeg # OSX choco install ffmpeg # Windows

Examples

Update youtube-dl

youtube-dl -U

Download best quality video from source

youtube-dl automatically selects bestvideo and audio for you

youtube-dl --verbose --no-check-certificate --prefer-ffmpeg --add-metadata --all-subs --restrict-filenames --embed-thumbnail --merge-output-format mp4 --recode-video mp4 -o "~/Desktop/%(title)s.%(ext)s" VIDEO_URL_HERE

Download Playlist to batch of MP3s

youtube-dl -f bestvideo+bestaudio --extract-audio --audio-format mp3 --prefer-avconv --add-metadata --output "~/Desktop/%(title)s.%(ext)s" --playlist-random https://www.youtube.com/playlist?list=XXXXX

Download individual song

youtube-dl -f bestvideo+bestaudio --extract-audio --audio-format mp3 --prefer-avconv --add-metadata --output "~/Desktop/%(title)s.%(ext)s" https://www.youtube.com/watch?v=ZZZZZZZ

Merge Videos Together (part files)

# e.g. merge video1.mp4, video2.mp4, video3.mp4, etc in same folder together to output.mp4
ffmpeg -v debug -f concat -safe 0 -movflags faststart $(ls -1v *.mp4 | sed "s/^/-i /" | sed ':a;N;$!ba;s/\n/ /g') -c copy output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment