FFmpeg Mixing new Audio with video repeat audio until video finishes

5,134

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
Share:
5,134

Related videos on Youtube

Myself
Author by

Myself

Experienced Software Engineer with a demonstrated history of working in the information technology and services industry. Skilled in SQL, Cascading Style Sheets (CSS), Java, HTML, and Android Development. Strong engineering professional with a Bachelor of Engineering (B.E.) focused in Computer Science from Visvesvaraya Technological University(Belgaum, Karnataka, India).

Updated on September 18, 2022

Comments

  • Myself
    Myself over 1 year

    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.