FFmpeg Mixing new Audio with video repeat audio until video finishes

1

Is there any solution to mix a new audio with a video that audio should repeat until the video ends. I had added new audio with the video using the below command:

 String s="-i "+inputVideoFilePath+" -i "+inputAudioFilePath+" -map 0:0 -map 1:0 -c:v copy -c:a aac -b:a 256k -shortest "+outputVideoFilePath;

where inputVideoFilePath is my video path and inputAudioFilePath is my audio path, then outputVideoFilePath is the final file(ie; audio mixed with video ) has been saved.

Issue: But my issue is I have a video with 90 seconds and audio with 35 seconds so I need to keep the video length as it is and extend/repeat the audio length for 90 seconds. Is there any solution, The above solution will take the shortest one.

Any help is appreciated.

Myself

Posted 2018-05-05T05:42:03.273

Reputation: 53

Answers

2

This is the command you would need to execute,

ffmpeg -i inputVideoFilePath -filter_complex "amovie=inputAudioFilePath:loop=0,asetpts=N/SR/TB[aud];[0:a][aud]amix[a]" -map 0:v -map '[a]' -c:v copy -c:a aac -b:a 256k -shortest outputVideoFilePath

Gyan

Posted 2018-05-05T05:42:03.273

Reputation: 21 016