I want to detect if the video has audio or not and add silent audio for that video using a single FFmpeg command dynamically. Currently, I'm following steps and use the accepted answer command but don't know how to add using the combined single FFmpeg and FFprobe command. I want to concatenate all videos but if any video has no audio then concatenate not working using the FFmpeg command. Currently, video1 has no audio, can we detect and add silent audio using single FFmpeg command? Any help would be appreciated. The following command:
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -i video4.mp4 -i video5.mp4 -f lavfi -i anullsrc -filter_complex \ "[0:v]scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:-1:-1,setsar=1,fps=30,format=yuv420p[v0]; [1:v]scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:-1:-1,setsar=1,fps=30,format=yuv420p[v1];
[2:v]scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:-1:-1,setsar=1,fps=30,format=yuv420p[v2]; [3:v]scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:-1:-1,setsar=1,fps=30,format=yuv420p[v3]; [4:v]scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:-1:-1,setsar=1,fps=30,format=yuv420p[v4];
[0:a]aformat=sample_rates=48000:channel_layouts=stereo[a0];
[1:a]aformat=sample_rates=48000:channel_layouts=stereo[a1];
[2:a]aformat=sample_rates=48000:channel_layouts=stereo[a2];
[3:a]aformat=sample_rates=48000:channel_layouts=stereo[a3];
[4:a]aformat=sample_rates=48000:channel_layouts=stereo[a4];
[v0][a0][v1][a1][v2][a2][v3][a3][v4][a4]concat=n=5:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" -c:v libx264 -c:a aac -movflags +faststart -preset ultrafast final-ffmpeg.mp4