Reputation: 3339
It might be a duplicate question
but didn't find any helpful answer
.
I have 2 audio files
and 1 mp4 video file
. Want to add the 2 audio files
to mp4 video
at specific time.
For example:
Video file:
input.mp4
(2 minutes video)Audio files:
Audio File 1:
test_0:01.mp3
(15 seconds audio file) I want to insert this file at position 0:01 in the mp4 videoAudio File 2:
test_0:20.mp3
(15 seconds audio file) I want to insert this file at position 0:20 in the mp4 videoI tried the following
command with offset
It's only inserting test_0:01.mp3
at 0:01 position in the video file
But test_0:20.mp3
is not getting inserted at 0:020
position getting mute
for this file no audio
.
ffmpeg -i input.mp4 -itsoffset 01 -i test_0:01.mp3 -itsoffset 20 -i test_0:20.mp3 -c:v copy -map 0:v:0 -map 1:a -map 2:a -c:a aac -b:a 192k output.mp4
Any help will be appreciated!
Upvotes: 3
Views: 1289
Reputation: 718
Your command creates two audio tracks in the MP4 file. If you have a look in your video player you can choose between two audio tracks (usually used to choose different audio languages).
This is because every -map
parameter creates a new stream. In your example one video with two audio tracks.
Use the audio filter amix
instead. Use also the filter adelay
for the delay in the same filter chain to achieve the best result.
ffmpeg -i input.mp4 -i test_0:01.mp3 -i test_0:20.mp3 -filter_complex "[1:a]adelay=1s:all=1[a1];[2:a]adelay=20s:all=1[a2];[a1][a2]amix=inputs=2[amixout]" -map 0:v:0 -map "[amixout]" -c:v copy -c:a aac -b:a 192k output.mp4
Upvotes: 3