ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
Parameter | Description |
---|---|
-i video.mp4 |
First input: the video file |
-i audio.wav |
Second input: the audio file |
-c:v copy |
Copy the video stream without re-encoding |
-c:a aac |
Convert audio to AAC format |
-map 0:v:0 |
Map the first video stream from the first input |
-map 1:a:0 |
Map the first audio stream from the second input |
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -shortest output.mp4
Replaces the original audio with a new soundtrack and stops when the shortest stream ends.
ffmpeg -i video.mp4 -i english.wav -i spanish.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -map 2:a:0 -metadata:s:a:0 language=eng -metadata:s:a:1 language=spa multi_language.mp4
Creates a video with two audio tracks (English and Spanish) with proper language metadata.
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -af "adelay=2000|2000" -shortest output.mp4
Merges audio with video but delays the audio by 2 seconds (useful for sync issues).