Reputation: 46361
The following code:
ffmpeg -i test.png
-t 2 -i a.mp3
-t 4 -i video.mp4
-t 1 -i b.mp3
-filter_complex [1]adelay=2000|2000[s1];[3]adelay=5000|5000[s3];[s1][2][s3]amix=inputs=3[outa];[0][2]overlay[outv]^
-map [outa] -map [outv]^
out.mp4 -y
works, and mixes the audio from the MP3s (time-shifted, as desired) and from the MP4 video.
But it fails if the MP4 has no audio channel (= a no-sound video):
Stream specifier '' in filtergraph description ... matches no stream
I'd like my script to work in both cases, if the video has audio or not.
How to include [2]
in the amix
if and only if this video has sound?
Note: A good way would be to be able to load a MP4 with always a sound stream: the original sound stream if the video has sound, and a silence audio track if the MP4 has no sound in it. Is this possible with a single command in ffmpeg
?
Upvotes: 0
Views: 95
Reputation: 133693
There is not such built-in feature. You have to check the file with ffprobe
to see if it has audio, and then run the appropriate command. If you have a favorite scripting language you can automate this with an if statement.
See Using ffprobe
to check audio-only files.
Upvotes: 1