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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.