乐闻世界logo
搜索文章和话题

How to add a new audio (not mixing) into a video using ffmpeg?

1个答案

1

When you need to add a new audio track to a video without mixing the existing audio, you can use FFmpeg, a powerful multimedia framework, to achieve this. Below are the specific steps and examples of related commands.

Step 1: Prepare the Assets

Ensure you have the following two files:

  1. Original video file (e.g., original_video.mp4)
  2. New audio file (e.g., new_audio.mp3)

Step 2: Add Audio with FFmpeg

To add a new audio track to the video without replacing or mixing the existing audio, use the following FFmpeg command:

bash
ffmpeg -i original_video.mp4 -i new_audio.mp3 -c:v copy -c:a aac -strict experimental output_video.mp4

Detailed explanation:

  • -i original_video.mp4: Specifies the input file, i.e., the original video.
  • -i new_audio.mp3: Specifies the second input file, i.e., the new audio file you want to add.
  • -c:v copy: This option instructs FFmpeg to copy the video stream directly without re-encoding.
  • -c:a aac: Specifies the audio codec as AAC, which is standard for MP4 containers. You may choose other codecs as needed.
  • -strict experimental: Required for certain encoders like AAC to function properly.
  • output_video.mp4: Specifies the output file name and format.

Step 3: Verify the Result

After completing the above steps, you will have a file named output_video.mp4 containing the original video and the newly added audio track. Use any media player that supports multi-track audio to confirm the audio track has been correctly added.

Example

Suppose you have a video file movie.mp4 and an audio file commentary.mp3, and you want to add this audio to the video without affecting the existing audio track. Apply the command above to process it. The resulting output_video.mp4 will include two audio tracks: the original track and the newly added commentary.mp3 track.

Using this method, you can flexibly add any audio type—such as commentary, background music, or sound effects—to videos without altering the original audio content. This approach is particularly useful for creating tutorial videos, commentary videos, or multilingual content.

2024年8月9日 01:46 回复

你的答案