1

i try to concat multiple videos to one video and add an background music to it.

for some reason the background music is perfectly added to the output video but the audio of each part of the output is speed up to a chipmunk version of the video itself. this results in an output video of 7 minutes with about 5 minutes of silence since everything is so fast that all the audio finishes after about 2 minutes.

my command is:

ffmpeg -safe 0 -i videolist.ffconcat -i bg_loop.mp3 -y -filter_complex "[1:0]volume=0.3[a1];[0:a][a1]amix=inputs=2" -vcodec libx264 -r 25 -filter:v scale=w=1920:h=1080 -map 0:v:0 output.mp4

i tried to remove the background music (since i wasn't able to loop it through the video i thought maybe that's the issue) and still.. all the audio of the video clips is still speed up resulting in chaotic audio at the beginning and silence at the end.

my video list looks like this:

ffconcat version 1.0
file intro.mp4
file clip-x.mp4
file clip-y.mp4
file clip-x.mp4
file clip-y.mp4
[... and so on]

i hope somebody can tell me what i'm doing wrong here (and maybe how to adjust my command to loop the background music through all the clips)

i googled a bit and found the adjustment of my command to add amix=inputs=2:duration=first but that doesn't do the trick and if i add duration=shortest or duration=longest nothing changes the output audio

benni.games
  • 158
  • 10
  • 2
    All audio tracks in all your inputs must have the same properties - codec, sampling rate, channels..etc. I suspect your intro has a different sampling rate than the clips. – Gyan May 26 '20 at 15:47
  • @Gyan thanks for your answer. can you give me a hint how i can check all the codecs, sampling rates and channels to see if that's an issue? or do i just need to recompile all clips and their audio to match the intro? – benni.games May 26 '20 at 16:56
  • 1
    Run `ffprobe -show_streams -select_streams a -v 0 "input-file"` – Gyan May 26 '20 at 18:39
  • @Gyan Thank you very much for your help. i figured my error and now i've got another issue i need to get fixed :-P but this one is done... won't you post your answer as a real answer so i can mark it as one? – benni.games May 27 '20 at 01:55

1 Answers1

1

The concat demuxer requires that all streams in inputs have the same properties. For audio, that includes codec, sampling rate, channel layout, sample format..

If audio of some inputs is sounding funny after concat, that usually indicates a sampling rate mismatch. Run ffprobe -show_streams -select_streams a -v 0 "input-file" on each input to check. For those which are different, you can re-encode only the audio by adding -ar X where X is the most common sampling rate found among your inputs e.g. -ar 44100. Other parameters will depend on format details. Keep video by using -c:v copy.

Gyan
  • 85,394
  • 9
  • 169
  • 201