FFmpeg consists of libraries and programs to help users handle video, audio, and other multimedia files and streams on Windows/Mac/Linux. It has many powerful features, including video/audio conversion, re-encoding, trimming, cropping, compression, combination, etc. This article talks about “FFmpeg merge audio and video” on Microsoft Windows. In the meantime, I will share a way to add or join audio to a video file without complicated command lines but with several simple clicks. You can compare the two methods and select your preferred one. Read on.
If you haven’t installed FFmpeg on your computer, download the latest version from the official website: https://ffmpeg.org/download.html
To avoid “Error opening input: no such file or directory” in FFmpeg, do as follows:
1. Unzip the downloaded file and rename the extracted folder to FFmpeg. Then, move the folder to Local Disk (C:).
2. Press Win + S keys to open the search bar. Type “system variables” and press Enter. Then, click the Environment Variables button, select Path under the System variables tab, and click Edit.
3. Click New on the right panel and type or copy the FFmpeg bin directory, for example, C:\Users\Administrator\FFmpeg.
4. Press the OK buttons to save your changes.
Furthermore, you should put the audio and video file you want to merge into the same directory with the FFmpeg bin.
5. Join audio to your video file in Command Prompt (type cmd in the search bar) with this command:
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a copy output.mp4
Note: Replace the video.mp4, audio.mp3, and output.mp4 based on your actual situation.
As you can see, FFmpeg combine audio and video requires correct environment variables and commands. Anything wrong will lead to failure in FFmpeg. Therefore, you may try another way to merge audio and video files on your Windows PC. I recommend you use the hassle-free video and audio joiner – WonderFox Free HD Video Converter Factory.
With this software, you can add multiple audio tracks to an MP4, MKV, or MOV file and put music over the video effortlessly.
Everything is clear in Free HD Video Converter Factory. Next, I will show you how to add audio to video with this alternative. DownloadDownload the free software to get started.
Launch Free HD Video Converter Factory and select Converter. Then, click the Add Files button to import a video file. Or you can directly drag and drop it into the software.
Click the format image on the right side to select an export profile. It’s worth noting that MP4, MKV, and MOV support multiple audio tracks while others can contain one only. Here I choose MP4 under Video for reference.
Press the “+” sign beside the audio track to add a local audio file to the video. Repeat this operation to add more audio files. Then click the inverted triangle button and select the desired audio track from the list.
Want to add online music to your video? You can first use the software to download music or song from the website. And then add it to the video file.
Hit the inverted triangle icon at the bottom of the software and specify an output path. Finally, click the Run button to start the process. Once done, a window will pop up and prompt you to check the resulting file.
Also Read: Add Audio to MKV | Convert MKV to MP4 with Multiple Audio Tracks | Increase MP4 Volume
The command line for FFmpeg add audio to video is not that complicated. However, it will be tricky if you merge a video file and multiple audio files or if the audio is not the same length as the video file. When there are multiple audio tracks in the video, FFmpeg only picks one audio track (as well as the video and subtitle track) by default. Here are some different cases about FFmpeg combine audio and video. Hope the tips are helpful to you.
1. How to merge video and audio files without losing original characteristics [duplicate]?
ffmpeg -i video1.mp4 -i audio1.mp3 -c:v copy -c:a copy output1.mp4
Note: “-c:v copy” and “-c:a copy” means this will not change codecs and compression methods.
Tips: If you want to change the video or audio codec, replace it with “-c:v libx264” (H264 video), “-c:a aac” (AAC audio), or other codecs you want.
Hot Search: FFmpeg H265/HEVC to H264
2. How to mix two audio files into a video?
ffmpeg -i video2.mp4 -i audio2.mp3 -c:v copy -filter_complex "[0:a][1:a] amix=inputs=2:duration=longest [audio_out] " -map 0:v -map "[audio_out]" -y output2.mp4
3. How to merge video (with audio) and audio files of different lengths but follow the audio file length?
If audio is longer than video,
ffmpeg -i video3.mp4 -i audio3.mp3 -filter_complex "[0:a]volume=0.2,apad[A];[1:a][A]amerge[Aout]" -map 0:v -map [Aout] -y output3.mp4
If audio is shorter than video,
ffmpeg -i video4.mp4 -i audio4.mp3 -filter_complex "[0:a]volume=0.2[A];[1:a][A]amerge[Aout]" -map 0:v -map [Aout] -y -shortest output4.mp4
Learn more details at superuser.com/questions/.
4. How to merge a video file (with its own audio) and an audio track (that should loop to fit the video length)?
ffmpeg -i video5.mp4 -stream_loop -1 -i audio5.mp3 -filter_complex "amix=inputs=2:duration=shortest" -c:v copy -movflags +faststart output5.mp4
The above article illustrates how to merge audio and video files with FFmpeg and gives solutions for different cases, like without re-encoding, audio and video not in the same length, etc. We can conclude that FFmpeg is hard to operate correctly though it’s a powerful video and audio processing toolkit. Therefore, the simple alternative to FFmpeg is a better way to go. WonderFox Free HD Video Converter Factory makes everything clear and easy to handle on its interface. For those who want a bulk and faster process, the Pro version with more features will be your best option. Download it here:
Terms and Conditions | Privacy Policy | License Agreement | Copyright © 2009-2024 WonderFox Soft, Inc.All Rights Reserved