created: 20150930124613020 creator: user modified: 20150930131117367 modifier: user tags: title: Separate Audio and Video type: text/vnd.tiddlywiki ; ~KeepVid: Download ~YouTube Videos, Facebook, Vimeo, Twitch.Tv, Dailymotion, Youku, Tudou, Metacafe and more! : http://keepvid.com ; Fastest ~YouTube downloader tool : https://kwizzu.com/construct.html # Why do I need to download video and audio files separately? # Merging audio and video using ffmpeg # Watching separate video and audio files # How do I convert the downloaded audio file to mp3? # How do I convert ~WebM video to the MP4? ! Why do I need to download video and audio files separately? A while back ~YouTube started to use [[DASH|http://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP]] 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|http://www.ffmpeg.org/]] 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|http://www.ffmpeg.org/]]. * 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|https://www.videolan.org/]] 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|https://wiki.videolan.org/Play_external_audio_track_with_video/]]. ! 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|http://online-audio-converter.com/ru/]] or [[that one|http://audio.online-convert.com/]]. 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.mp3 ``` ! How 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.mp4 ``` Please note that such a conversion may take a very long time.