How to Merge Audio and Video Files with FFmpeg?

Author: Vita
Publish date
Updated on Mar 29, 2024
Best Alternative to FFmpeg Merge Video and Audio
  • Try the other free method to merge audio with video files on PC:
  • WonderFox Free HD Video Converter Factory [Download] [Download]
  • Step 1. Import a video file.
  • Step 2. Choose an output format.
  • Step 3. Add audio track(s) to the video.
  • Step 4. Press Run to export the final file.
Quick Navigation
FFmpeg Merge Video and Audio (Guide)
FFmpeg Add Audio to Video (Alternative Solution)
FFmpeg Joiner Audio and Video (More Tips)
The Bottom Line
Facebook
Twitter
Pinterest
Linkedin
Reddit

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.

Quick Guide on FFmpeg Combine Audio and Video

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.

FFmpeg Add Audio to Video
FFmpeg Add Audio to Video

Simple Alternative to FFmpeg Merge Audio and Video

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.

WonderFox Free HD Video Converter Factory
Add Any Audio to Video Fuss-free!

Free HD Video Converter Factory helps you merge audio and video files most easily and handily! It can also help you enhance the sound quality, improve video quality, convert videos to 300+ presets, edit videos, download movies and songs, etc. Try it out!

Free download Download for Free
Free download Download for Free
* 100% safe, clean, free, and no watermark.

Alternate Way to FFmpeg Add Audio to Video on Windows

Step 1. Import Video into the Software

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.

Add a Video File
Add a Video File

Step 2. Add Audio to the Video File

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.

Merge the Audio and Video File
Merge the Audio and Video File

Step 3. Export the Final Video

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

Finalize the Combination Process
Finalize the Combination Process
More than a Simple Audio and Video Merger
Free Video Converter & Downloader
  • Convert video to 300+ formats;
  • Merge videos, audio files, or add audio to video;
  • Download videos and music from 500+ websites;
  • Cut audio, trim, rotate, crop, flip videos, and more.
Free download Download for Free
Free download Download for Free

More Tips for FFmpeg Merge Audio and Video Files

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 Bottom Line

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:

Similar Articles
Fix Audio Sync Problem

Video and Audio Out of Sync

How to Delete Audio Track from Video

Delete Audio Track from Video

Merge Subtitles with Videos

Merge Subtitles with Videos

WonderFox HD Video Converter Factory Pro
Hardware Acceleration and Batch Support for Pro Version

HD Video Converter Factory Pro can trigger the lightning mode up to 50x faster conversion speed with GPU acceleration and batch process. You can add multiple video files into the software and insert audio tracks, convert them to over 500 formats, batch compress the file sizes, upscale video resolution to 1080p/2K/4K, etc. Moreover, the Pro version offers an additional HD screen recorder, GIF maker, and toolbox to help you record PC games, make GIFs and ringtones, extract subtitles from videos, and achieve more. Upgrade to Pro Now!

Free download Download for Free
Free download Download for Free
* You can learn more details about HD Video Converter Factory Pro here >
Specialized in multimedia software solutions.
Since 2009

Terms and Conditions | Privacy Policy | License Agreement | Copyright © 2009-2024 WonderFox Soft, Inc.All Rights Reserved

Back to Top