Skip to content

Instantly share code, notes, and snippets.

@rkennesson
Last active April 27, 2021 04:12
Show Gist options
  • Save rkennesson/54936eca1983c9afb1f8 to your computer and use it in GitHub Desktop.
Save rkennesson/54936eca1983c9afb1f8 to your computer and use it in GitHub Desktop.
#example for converting youtube video to mp3
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/watch\?v\=u-X3q6CmsKc
ffmpeg -v 5 -y -i Mr.\ Desktop\ \&\ Mr.\ Server\ Episode\ 5\ _\ Linux\ Networking\ \&\ Connect2SSH-u-X3q6CmsKc.webm -acodec libmp3lame -ac 2 -ab 192k MrServerMrDesktop.mp3
--
#requires ffmpeg
youtube-dl --extract-audio --audio-format mp3 'https://www.youtube.com/watch?v=u-X3q6CmsKc'
youtube-dl -f 18+141 -o "%(title)s.%(ext)s" https://www.youtube.com/playlist?list=_____________
youtube-dl https://www.youtube.com/playlist?list=_________
youtube-dl -F https://www.youtube.com/playlist?list=________
add two streams together with ffmpeg
youtube-dl -f 18+141 https://www.youtube.com/playlist?list=_________
youtube-dl https://www.youtube.com/watch?v=_______ -o "%(title)s.%(ext)s" -f bestvideo+bestaudio --merge-output-format mkv
youtube-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=__________
youtube-dl https://www.youtube.com/playlist?list=___ -f bestvideo+bestaudio -o '%(title)s.%(ext)s' --merge-output-format mkv
#download playlist with numberings
youtube-dl https://www.youtube.com/playlist?list=______ -f bestvideo+bestaudio -o '%(playlist_index)s - %(title)s.%(ext)s' --merge-output-format mkv
#subtitles
youtube-dl https://www.youtube.com/watch\?v\=______ -f bestvideo+bestaudio -o '%(title)s.%(ext)s' --write-srt --sub-lang en --merge-output-format mkv
youtube-dl also downloads subtitles if --write-sub given.
To download subtitles only but not videos, add --skip-download.
--embed-subs reads from existing files if there are files with the same name as the output of --write-sub.
#------
youtube(){
case "$1" in
"") echo "Usage: youtube https://www.youtube.com/playlist?list=______";
echo "Usage: youtube https://www.youtube.com/watch?v=______";
echo "Usage: $0 {youtube-dl $1 -f bestvideo+bestaudio -o '%(title)s.%(ext)s' --merge-output-format mkv}";;
*) youtube-dl $1 -f bestvideo+bestaudio -o '%(title)s.%(ext)s' --merge-output-format mkv;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment