HitPaw Univd

  • Lossless converter for videos, audio, and images at 120x faster.
  • AI compressor for reducing video and image file size in batch without quality loss.
  • Powerful GIF maker to clip and convert any video to GIF for sharing on social media.
  • Built-in AI tools: Speech to Text, Vocal Remover, Background Remover, and Noise Remover.
hitpaw header image

How to Merge Video and Audio with FFmpeg

FFmpeg is a powerful open-source tool for processing multimedia files, making it an excellent choice for merging video and audio seamlessly. Whether you're syncing separate video and audio tracks, combining background music with a clip, or creating high-quality content without re-encoding, FFmpeg offers a fast and efficient solution. In this guide, we'll walk you through the exact FFmpeg commands to merge video and audio files, ensuring perfect synchronization and minimal quality loss.

ffmpeg join video and audio

Part 1. Steps to Merge Video and Audio Using FFmpeg

Do you want to add multiple audio tracks to your video? FFmpeg makes it easy to combine video with two audio streams. Whether it's for a foreign language version or an alternative audio track, this method delivers professional results. In this guide, we'll walk you through merging video and two audio streams using FFmpeg's command-line interface. Let's get started!

1. Mix Two Audios Into a Video in FFmpeg

You can easily combine multiple audio tracks into a single video using FFmpeg's command-line interface. Here, we will show you how to mix two audio tracks into one video, where the voiceover plays over the background music. Follow these steps:

  • Step 1:Open the command prompt or terminal and navigate to the directory where your video and audio files are stored.

  • Step 2:Replace "video1.mp4" and "audio1.mp3" with the actual names of your video and audio files.

    ffmpeg \

    -i video1.mp4 -i audio1.mp3 \

  • Step 3:Use the -c:v copy flag to tell FFmpeg to copy the video stream from the source file without re-encoding. This speeds up the process and avoids quality loss.

    -c:v copy \

    -filter_complex " \

  • Step 4:Use the amix=inputs=2:duration=longest filter to mix the two audio tracks. This command takes two audio inputs (0:a and 1:a) and combines them into an output stream called audio_out, with the duration of the longest input.

    [0:a][1:a] amix=inputs=2:duration=longest [audio_out] \

  • Step 5:Map the video stream (0:v) and the mixed audio stream (audio_out) to the final output video.

    -map 0:v -map "[audio_out]" \

  • Step 6:Use the -y flag to overwrite the output file if it already exists.

    -y output.mp4

Once completed, the new video file with the combined audio will be saved in the specified output location.

2. Mix Two Audios Into a Video with Volume Adjustment

In some cases, you may want to adjust the volume of one audio track while mixing it into the video. For example, you may want to lower the background music volume to make the voiceover clearer. Here's how to do it:

  • Step 1:Start by specifying the video and audio files as inputs.

    ffmpeg \

    -i video1.mp4 -i audio1.mp3 \

  • Step 2:Use the filter_complex option to apply the volume filter, lowering the background music volume by 50%.

    -filter_complex " \

    [0:a] volume=0.5 [music];

  • Step 3:Use the amix filter to combine the adjusted background music and the second audio track.

    [music][1:a] amix=inputs=2:duration=longest [audio_out] \

    " \

  • Step 4:Use the -map option to select which streams should be included in the output file.

    -map 0:v -map "[audio_out]" \

  • Step 5:Specify the output file and use the -y flag to overwrite it if needed.

    -y output.mp4

3. Mix Two Audios Into a Video With Delay

Sometimes, you need to sync the audio track with the video or introduce a delay. Here's how to apply a delay to an audio track in FFmpeg:

  • Step 1:Use the adelay filter to add a delay (in milliseconds) to the second audio track. For example, adding a 2100ms delay.

    [1:a] adelay=2100|2100 [voice];

  • Step 2:Combine the delayed audio with the original audio track.

    [0:a][voice] amix=inputs=2:duration=longest [audio_out]

  • Step 3:Map the video and audio streams to the output file.

    -map 0:v -map "[audio_out]"

  • Step 4:Use the -y flag to overwrite the file if necessary.

    -y output.mp4

The final command will look like this:

ffmpeg \

-i video1.mp4 -i audio1.mp3 \

-filter_complex " \

[1:a] adelay=2100|2100 [voice]; \

[0:a][voice] amix=inputs=2:duration=longest [audio_out] \

" \

-map 0:v -map "[audio_out]" \

-y output.mp4

This command will add a 2100ms delay to the second audio track and merge it with the original audio, creating a synchronized video file.

Part 2. Best Alternative to Ffmpeg Merge Video and Audio

Are you facing difficulty with FFmpeg? If you find the command-line process too complex, HitPaw Univd offers an easy and intuitive way to add audio to video without the hassle. With HitPaw Univd, you can merge audio and video files seamlessly through a user-friendly interface. Whether you're a beginner or need a faster solution, HitPaw Univd is a perfect choice.

hitpaw product

HitPaw Univd - All-in-one Video Solutions for Win & Mac

Secure Verified. 254,145 people have downloaded it.

  • Adds multiple tracks to a video file easily, so users can select different track for this video.
  • Supports over 1000 video and audio formats.
  • Adds subtitles to video.
  • Edits videos with trim, cut, merge, filters and more.
  • Enhance video with the most cutting-edge AI algorithms.
  • Converts video and audio to different formats and devices.
  • Comes with a neat interface, even beginners are easy to operate.

Secure Verified. 254,145 people have downloaded it.

Step-by-Step Guide to Merge Audio in Video with HitPaw Univd

  • Step 1.Open the HitPaw Univd software and Go to the Converter section. Click the "Add Files" button to import the video that you want to add audio to.

    add video to hitpaw univd
  • Step 2.Once the video is added, locate the "No audio track" dropdown menu below the video thumbnail. Click on the "No audio track" option and select "Add audio track" to import the audio file you want to merge with the video. HitPaw Univd supports adding multiple audio tracks to a video.

    add audio to video in hitpaw univd
  • Step 3.B After adding the audio track, you can select an output format for the export video.

    select an output format
  • Step 4.Finally, click the Convert All button to combining audio and video together.

    combining video and audio with ffmeg alternative
  • Step 5.Once the process is complete, you can access the newly edited video with the added audio track from the Converted tab.

    access the merged video

Conclusion

In this guide, we explored how to ffmpeg merge audio and video and the many ways you can use FFmpeg to join video and audio. Whether you're mixing two audio tracks, adjusting the volume, or adding a delay, FFmpeg provides powerful solutions for video editing. If FFmpeg seems too complicated, HitPaw Univd is a great alternative for quickly merging audio and video without a steep learning curve. So, go ahead and start creating content that stands out with well-synced audio and video-your audience will surely appreciate the enhanced quality!

Select the product rating:

hitpaw editor in chief

Leave a Comment

Create your review for HitPaw articles

HitPaw Univd

HitPaw Video Converter

All-in-one Converter, Compressor and Editor for Videos, Audio and Images

Recommend Products

HitPaw VoicePea HitPaw VoicePea

Best voice changer to help you change voice in real time

HitPaw Screen Recorder HitPaw VikPea (Video Enhancer)

Batch upscale videos with only one click. Powered by trained AI.

HitPaw Screen Recorder HitPaw FotorPea

Best all-in-one AI photo editor to boost images potential

download
Click Here To Install