Wondering how to download a video from YouTube, with audio and subtitles intact? Here are a couple of methods I’m documenting in case I ever need to use them.
This is just a mental exercise, and I do not know if it works! I neither condone nor suggest you use this for any form of copyright infringement. Please be aware of copyright laws and do not download anything you do not have rights to.
Method 1: On-line tools
There are a multitude of on-line YouTube downloading tools, such as KeepVid.ch. Pretty self-explanatory, just provide a YouTube URL, choose the quality options, and hit download. Two browser tabs open - one playing just the video stream and the other playing audio, both directly from YouTube. For each, right-click and Save As...
For subtitles, SaveSubs.com is one of the many on-line tools to download YouTube subtitles in
Method 2: youtube-dl
Disclaimer: downloading apps from the Internet should generally be considered unsafe!
There is an open-source youtube-dl Python-based command-line downloader.
According to the instructions,
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o youtube-dl will download the executable. However, using youtube-dl is rather complex, see the examples!, e.g.
- to download video and audio streams
youtube-dl -ci -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' https://www.youtube.com/watch?v=xxxxxxxxxxx
- download video, audio and subtitle streams,
youtube-dl -ci -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' --sub-lang en-UK,en-US,en --write-sub https://www.youtube.com/watch?v=xxxxxxxxxxx
It can also use FFmpeg to merge the streams, that’a a bonus from the previous method! There is a dependency on
ffmpeg (more on that next) which, if is in the same folder as
youtube-dl, is configured as follows:
youtube-dl -ci -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best \ --sub-lang en-UK,en-US,en --embed-subs --write-sub --ffmpeg-location . \ https://www.youtube.com/watch?v=xxxxxxxxxxx
Make sure it's all one one line on Window - cmd shell doesn’t respect
If the audio, video and subtitles are all separate files, e.g.
english.srt, the open-source FFmpeg tool can merge these streams into a single file, e.g.
ffmpeg -i video.mp4 -i audio.m4a -i english.srt \ -c:v copy -c:a copy -c:s mov_text \ merged.mp4
ffmpeg can handle more streams, e.g. multiple audio tracks with respective subtitles. According to this Stack Overflow answer, it’ll be something like this:
ffmpeg -i video.mp4 -i english.mp3 -i german.mp3 \ -i english.srt -i german.srt \ -map 0:v -map 0:a -map 1:a \ -metadata:s:s:0 language=eng -metadata:s:s:1 language=ger \ -metadata:s:a:0 language=eng -metadata:s:a:1 language=ger \ -c:v copy -c:a copy -c:s mov_text \ merged.mp4
And so much more, e.g. delay subtitles (
ffmpeg -ss -60 -i subtitles.srt -c copy output.srt), convert formats (
ffmpeg -i audio.wav -c:a aac output.mp4), etc.
Again, I honestly haven’t validated any of this. So good luck!
Updated 4 July: Small addition to sepecify multiple English subtitle variations with
--sub-lang en-UK,en-US,en. Use
--list-subs to get a list, and note that the list often starts wtih
Available automatic captions, which is maybe not what you want.