Why do I need to download video and audio files separately?
A while back YouTube started to use DASH format (Dynamic Adaptive Streaming over HTTP) for 1080p and 480p videos. DASH is an adaptive bitrate streaming technology where a multimedia file is partitioned into one or more segments and delivered to a client using HTTP. Now instead of single multimedia file, there are at least 2 separate files: one with the audio line, the other — video. At the moment FastestTube can’t merge them automatically. However we added the facility to download both audio/video files so you can combine them later into a single one with ffmpeg or similar tools.
Custom filename is not yet supported, therefore both audio/video files are downloaded as "videoplayback". The audio file has the mime-type: "audio/mp4" and therefore should have the file extension: "m4a" or "mp4" but some browsers may require you to add the extension manually.
Merging audio and video using ffmpeg
Once you have downloaded both video and audio files (‘videoplayback.mp4’ and ‘videoplayback.m4a’ respectively), here’s how you can merge them into a single file:
- Download and install ffmpeg.
- Open a Command Prompt window in your downloads folder and run the following command
- In case of MP4 format (all, except 1440p 60fps & 2160p 60fps): ffmpeg -i videoplayback.mp4 -i videoplayback.m4a -c:v copy -c:a copy output.mp4
- In case of WebM format (1440p 60fps and 2160p 60fps): ffmpeg -i videoplayback.webm -i videoplayback.m4a -c:v copy -c:a copy output.mkv
- Wait until ffmpeg finishes merging audio and video into a single file named "output.mp4".
Watching separate video and audio files
VLC media player allows you to watch the video with an external audio track.
On Windows you need to:
- Go to Media Open Multiple Files....
- In the Open Media window, click Add....
- In the Select one or multiple files window, select the desired video file. Click Open.
- In the Open Media window, tick Show more options, then tick Play another media synchronously. Click Browse....
- In the second Open Media window, click Add....
- In the Select one or multiple files window, select the desired file that contains the audio which will be played on top of the video previously selected. Click Open.
- In the second Open Media window, click Select.
- In the first Open Media window, click Play.
- If you have more than one audio track available, go to Audio Audio Track and pick the one that corresponds to the desired audio overlay.
On Mac OS X:
- Go to File Advanced Open File....
- In the Open Source window, click Browse....
- In the appeared dialog window, select the desired video file. Click Open.
- Tick Play another media synchronously. Click Choose....
- In the Open window, select the desired file that contains the audio which will be played on top of the video previously selected. Click Open.
- In the Open Source window, click Open.
- If you have more than one audio track available, go to Audio Audio Track and pick the one that corresponds to the desired audio overlay.
This manual is also available at the VideoLAN wiki.
How do I convert the downloaded audio file to mp3?
YouTube uses an uncommon codec called Dash for their audio files and some media players can't play it. You can convert the Dash audio format to a more common format using one of the many online services available like this one or that one.
Otherwise you can always manually convert the Dash audio file to any format with ffmpeg. To do so, you need to know your
audio's bitrate,
which was shown in the download menu. If you don’t remember the bitrate you can check it by running
ffprobe INPUT_FILE
in the Command Prompt window. Just replace INPUT_FILE with the downloaded audio file name.
Then you need to convert the bitrate from kbit/s to bit/s. To do so just add three zeroes after the bitrate
(ex.: 128 kbit/s audio would be 128000 bit/s). Thereafter you need to execute the following command in the
Command Prompt window:
ffmpeg -i INPUT_FILE -ab BITRATE -vn OUTPUT_FILE
- INPUT_FILE — a path to the downloaded audio;
- BITRATE — audio bitrate (only the numeric value is allowed);
- OUTPUT_FILE — new file's name. Note that you have to use a valid audio format extension for the output file (like .mp3 or .m4a).
Example:
ffmpeg -i videoplayback.m4a -ab 128000 -vn music.mp3How do I convert WebM video to the MP4
For some qualities Youtube provides videos only in WebM format. WebM could be converted in MP4 with the following ffmpeg command
ffmpeg -i video.webm -i audio.m4a -c:v libx264 -c:a copy out.mp4Please note that such a conversion may take a very long time.