Search code examples
ffmpeg

ffmpeg: Merge audio into a soundless video, with offset?


I need to merge the video (which has no audio) and the audio file with offset (audio should start at 9 seconds). I use this:

ffmpeg -i video_without_sound.mp4 -i audio_file.mp3 -c:v copy -filter_complex "[1]adelay=9000|9000[s1];[s0:a][s1]amix=2[a]" -map 0:v -map "[a]" -c:a aac output.mp4

And I get an error:

Stream specifier 's0:a' in filtergraph description [1]adelay=9000|9000[s1];[s0:a][s1]amix=2[a] matches no streams.

I think problem is that the video files have no sound and no audio streams. How to merge such files with offset?


Solution

  • Since the first input has no audio, there's nothing to mix the 2nd input with. You simply output the filtered audio from the 2nd input.

    ffmpeg -i video_without_sound.mp4 -i audio_file.mp3 -map 0:v -map 1:a -c:v copy -af "adelay=9000|9000" -c:a aac output.mp4