Skip to content

Instantly share code, notes, and snippets.

@dantheman213
Last active January 23, 2022 01:40
Show Gist options
  • Save dantheman213/c74ad1ab1bd4cc4500a9f01d26dd9878 to your computer and use it in GitHub Desktop.
Save dantheman213/c74ad1ab1bd4cc4500a9f01d26dd9878 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
@sijanec
Copy link

sijanec commented Oct 19, 2018

for an online dl website

youtube-dl --extract-audio --audio-format mp3 --ignore-errors --playlist-items ITEM_SPEC 1-100 --max-filesize 30m -o %(NAME)s.mp3 --yes-playlist $1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment