0

I wanna add a background music on my video. I tried this command

ffmpeg -i video.mkv -i audio.m4a -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map 0:v -map "[a]" -c:v copy -ac 2 output.mkv

It worked but when music ended, My Video Sound end too. I want to repeate the background music until video end. And if I can change background music volume it will be awosome

Compo
  • 36,585
  • 5
  • 27
  • 39
Hossein
  • 41
  • 5

1 Answers1

3

I found the solution and wanna share it with you guys

ffmpeg -i video.mp4 -stream_loop -1 -i audio.mp3 -c:v copy -filter_complex "[0:a]aformat=fltp:44100:stereo,apad[0a];[1]aformat=fltp:44100:stereo,volume=0.08[1a];[0a][1a]amerge[a]" -map 0:v -map "[a]" -ac 2 -shortest output.mp4

It make the audio looped and play it until video end with audio volume 0.08 and you can change it here

Hossein
  • 41
  • 5
  • this query is working correctly as per my need, however as per my use case I need to give option to remove the audio, can you help me to get the query to remove the track? – Rashesh Bosamiya Jun 09 '23 at 11:13