Thursday, 7 September 2017

FFmpeg Mixing new Audio with video repeat audio until video finishes


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.



Answer



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

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...