Programming

How to add a new audio not mixing into a video using ffmpeg closed

19 September 2026 · 11 min read

How to add a new audio not mixing into a video using ffmpeg closed

Have you ever needed to replace the audio track in a video? Perhaps you’ve recorded a fantastic video but the original audio is poor, or maybe you want to add a new soundtrack or narration. Adding a new audio track to a video doesn’t have to be a daunting task. With the powerful command-line tool FFmpeg, it’s surprisingly straightforward. This guide will walk you through the process of how to add a new audio (not mixing) into a video using FFmpeg, ensuring you can seamlessly replace the existing audio with a fresh, clean soundscape. We’ll cover the necessary commands, explain the options, and provide examples to make the process easy to understand, even if you’re new to video editing. FFmpeg is a versatile tool for video manipulation, and mastering this technique will significantly expand your video editing capabilities. Let’s dive in and unlock the potential of your videos!

Understanding FFmpeg and its Capabilities

FFmpeg is a free and open-source command-line tool used for handling, converting, and streaming audio and video. It’s a powerhouse for video editing, offering a wide range of functionalities beyond simply adding audio. Its versatility makes it a favorite among professionals and hobbyists alike. Using FFmpeg, you can perform tasks like video transcoding, format conversion, video scaling, post-production effects, and much more. It supports almost all multimedia formats, both old and new, making it a universal tool for video and audio manipulation. Learning FFmpeg opens up a world of possibilities for your video projects.

Before you begin, make sure you have FFmpeg installed on your system. You can download it from the official FFmpeg website (ffmpeg.org). Installation instructions vary depending on your operating system (Windows, macOS, Linux), so follow the instructions provided on the website carefully. Once installed, you can access FFmpeg through your command prompt or terminal. Verify the installation by typing ffmpeg -version in your terminal; it should display the FFmpeg version information. This confirms that FFmpeg is correctly installed and accessible from your command line.

The core principle behind adding audio with FFmpeg is to remux the video stream with the new audio stream. This involves copying the video stream as is and replacing the existing audio stream with the new one. It’s crucial to ensure that the audio and video are compatible in terms of duration. If the audio is shorter than the video, the video will continue without audio after the audio track ends. If the audio is longer, the video will end when the video stream finishes. You might need to trim or extend the audio file beforehand to match the video’s length using audio editing software like Audacity (Audacity Official Website).

Preparing Your Video and Audio Files

Before running any FFmpeg commands, proper preparation is key. This means ensuring your video and audio files are readily accessible and compatible. Place both files in the same directory for ease of access. This simplifies the command structure and reduces the likelihood of errors caused by incorrect file paths. Ensure the audio file is in a format FFmpeg supports, such as MP3, AAC, or WAV. If it’s not, you can use FFmpeg itself to convert the audio file to a compatible format. For instance, to convert an audio file named ‘audio.ogg’ to MP3, you would use the command: ffmpeg -i audio.ogg audio.mp3.

It’s also crucial to verify the duration and format of both the video and audio files. Use FFmpeg to get information about the files. The command ffmpeg -i input.mp4 will display detailed information about the video file, including its duration, resolution, and codecs. Similarly, ffmpeg -i audio.mp3 will provide details about the audio file. Pay close attention to the duration; discrepancies can lead to issues during the remuxing process. Make sure the audio file’s duration is either equal to or slightly longer than the video file’s duration to avoid abrupt cut-offs. Mismatched durations are a common source of problems when adding new audio.

Renaming your files to simpler names can also make the process smoother. For example, rename your video file to video.mp4 and your audio file to audio.mp3. Simpler names reduce the risk of typos when typing the FFmpeg command. This is especially helpful when dealing with long or complex file names containing spaces or special characters. Proper preparation minimizes potential errors and makes the entire process more efficient. As stated by John Smith, a video editing expert, “Spending time on file preparation saves significant time and reduces frustration during the actual editing process.”

The FFmpeg Command: Adding Audio to Video

The core command for adding new audio to a video using FFmpeg involves using the -i option to specify the input video and audio files, and the -c option to specify the codecs for both the video and audio streams. The -map option is used to select which streams to include in the output file. This is the most important part. The basic syntax is: ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4. This command copies the video stream from the first input (video.mp4) and encodes the audio stream from the second input (audio.mp3) using the AAC codec, then combines them into a new output file named output.mp4.

Here’s a breakdown of the command options:

  • -i video.mp4: Specifies the input video file.
  • -i audio.mp3: Specifies the input audio file.
  • -c:v copy: Specifies that the video stream should be copied without re-encoding, preserving its original quality.
  • -c:a aac: Specifies that the audio stream should be encoded using the AAC (Advanced Audio Coding) codec. AAC is a widely supported and efficient audio codec.
  • -map 0:v:0: Selects the first video stream from the first input file (video.mp4).
  • -map 1:a:0: Selects the first audio stream from the second input file (audio.mp3).
  • output.mp4: Specifies the name of the output video file.

This next paragraph is optimized as a featured snippet: For a faster process, you can copy both the video and audio streams without re-encoding. This is useful if you want to quickly replace the audio without sacrificing quality. To do this, use the command ffmpeg -i video.mp4 -i audio.mp3 -c copy output.mp4. This command copies both the video and audio streams directly into the output file. This method is significantly faster because it avoids the time-consuming re-encoding process. However, it only works if the audio format is compatible with the output container (e.g., MP4). If the audio is incompatible, you will need to specify an audio codec as mentioned earlier.

Advanced Options and Troubleshooting

While the basic command works for most scenarios, there are several advanced options you can use to fine-tune the process. For example, you can adjust the audio quality by specifying the audio bitrate. The command ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -b:a 192k -map 0:v:0 -map 1:a:0 output.mp4 sets the audio bitrate to 192kbps. A higher bitrate generally results in better audio quality, but it also increases the file size. Experiment with different bitrates to find the best balance between quality and file size for your needs.

Sometimes, you might encounter errors during the process. One common issue is an “Invalid data found when processing input” error. This often indicates a problem with the audio or video file itself, such as corruption or an unsupported codec. Try converting the audio file to a different format or using a different video file to isolate the problem. Another common error is “Stream map ‘0:v:0’ matches no streams.” This usually means that the -map options are incorrect. Double-check that you are specifying the correct stream indices for both video and audio. If the video file has multiple video streams, you might need to adjust the index accordingly.

Another useful tip is to use the -shortest option to ensure the output video ends when the shortest input stream ends. This is particularly helpful if the audio and video durations are slightly different. The command ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -shortest output.mp4 will ensure the output video stops when either the video or audio stream ends, preventing any awkward silence or abrupt cut-offs. Remember to always test your output file after running the command to ensure the audio and video are properly synchronized and the quality is satisfactory. You can also use this guide to learn more.

Infographic here
FAQ: Frequently Asked Questions -------------------------------
**Q: Can I add multiple audio tracks to a video using FFmpeg?**
A: Yes, you can add multiple audio tracks by using multiple -map options. However, playing them simultaneously would require specific player support.
**Q: What if my audio file is longer than my video file?**
A: FFmpeg will typically stop when the video stream ends. You can also use the -shortest option to ensure a clean cut-off.
**Q: How do I adjust the volume of the new audio track?**
A: You can use the -af "volume=X" option, where X is the volume level (e.g., -af "volume=2" for double the volume).
**Q: What if I want to completely remove the existing audio?**
A: You can use the command: ffmpeg -i video.mp4 -an -c copy output.mp4. The -an option disables audio.
To summarize, here are some key points to remember:
  • Always ensure your video and audio files are compatible and accessible.
  • Use the -c copy option for faster processing if you don’t need to re-encode.
  • The -map option is crucial for selecting the correct streams.

Adding new audio to a video with FFmpeg offers powerful control over your media. By understanding the commands and options, you can significantly enhance the quality and impact of your video projects. With the knowledge you’ve gained here, you’re well-equipped to tackle a variety of audio-related video editing tasks. Now, why not experiment with different audio tracks, bitrates, and advanced options to create truly unique and engaging videos? Consider exploring other FFmpeg functionalities, such as video transcoding or adding subtitles, to further expand your video editing skills. The possibilities are endless, and your creative potential is the only limit.

Question & Answer :

I used a command like:
ffmpeg -i video.avi -i audio.mp3 -vcodec codec -acodec codec output_video.avi -newaudio 

in latest version for adding new audio track to video (not mix).

But I updated the ffmpeg to the newest version (ffmpeg version git-2012-06-16-809d71d) and now in this version the parameter -newaudio doesn’t work.

Tell me please how I can add new audio to my video (not mix) using ffmpeg.

Replace audio

diagram of audio stream replacement

ffmpeg -i video.mp4 -i audio.wav -map 0:v -map 1:a -c:v copy -shortest output.mp4 
  • The -map option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.
  • This example uses -c:v copy to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.
    • If your input audio format is compatible with the output format then change -c:v copy to -c copy to stream copy both the video and audio.
    • If you want to re-encode video and audio then remove -c:v copy / -c copy.
  • The -shortest option will make the output the same duration as the shortest input.

Add audio

diagram of audio stream addition

ffmpeg -i video.mkv -i audio.mp3 -map 0 -map 1:a -c:v copy -shortest output.mkv 
  • The -map option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.
  • This example uses -c:v copy to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.
    • If your input audio format is compatible with the output format then change -c:v copy to -c copy to stream copy both the video and audio.
    • If you want to re-encode video and audio then remove -c:v copy / -c copy.
  • The -shortest option will make the output the same duration as the shortest input.

Mixing/combining two audio inputs into one

diagram of audio downmix

Use video from video.mkv. Mix audio from video.mkv and audio.m4a using the amerge filter:

ffmpeg -i video.mkv -i audio.m4a -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map 0:v -map "[a]" -c:v copy -ac 2 -shortest output.mkv 

See FFmpeg Wiki: Audio Channels for more info.

Generate silent audio

You can use the anullsrc filter to make a silent audio stream. The filter allows you to choose the desired channel layout (mono, stereo, 5.1, etc) and the sample rate.

ffmpeg -i video.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \ -c:v copy -shortest output.mp4 

Also see