Using SaveTube and ffmpeg to download 480p, 720p, and 1080p from YouTube

I have used the excellent SaveTube script for Greasemonkey for quite some time. It lets you download video files from popular video sharing sites and it does a fantastic job. One of the flaws that has existed for quite some time is that SaveTube can only obtain working video/audio files for lower quality levels because of the MPEG DASH formatting done to make changing the resolution on-the-fly function properly.

It’s not SaveTube’s fault, however I have wanted to pull full-quality videos from YouTube for a long time, so I contacted SaveTube’s creater “isebaro” about it. He produced this test userscript which creates a right-clickable link for downloading the DASH streams, enabling me to pull the maximum quality video/audio streams and store them. Choose a very-high-quality stream, right-click, save link as, and rename “videoplayback.mp4” to something more relevant.mp4!

One problem remains: the video and audio streams are separate files. We’ll use the most awesome media splicing program on the planet, ffmpeg, to merge the streams. On Linux you can use your package manager to obtain ffmpeg; for Windows and the link provided, get the “static” version that matches your OS (32/64 bit) and extract the ffmpeg.exe binary, then copy it into the C:\Windows folder (so you can run it from anywhere). ffmpeg runs within a Command Prompt or a Linux terminal.

I already had a copy of the lower quality video with the audio stream, so I used that. Here’s what you type to do the audio/video merge:

ffmpeg -vn -i “Audio stream source.mp4” -an -i “Video stream source.mp4” -vcodec copy -acodec copy “Awesome 1080p Video.mp4”

The switches are as follows. -vn means “don’t use video from this file” and -an means “don’t use audio from this file.” -i indicates an input file and must come AFTER the options that directly apply to that input file. “-{a,v}codec copy” tells ffmpeg not to decompress and recompress the streams, but to do a direct copy of them without further processing (you DO NOT want to recompress streams, I promise!)

Once you’ve merged the streams and verified the new video file works properly (seek around to check for A/V sync issues), feel free to delete the original stream files.

Leave a Reply

Your email address will not be published. Required fields are marked *