How to insert a video intro with ffmpeg

I want to insert a video intro, i use below filter to generate multiple resolution with watermark but couldn't figure out how to add intro.

{executable} -i {fileInput} -i {watermark} -filter_complex "overlay=x=(main_w-overlay_w-10):y=(10),split=4[wm1080][wm720][wm480][wm360];[wm1080]scale=-2:1080:flags=lanczos[v1080];[wm720]scale=-2:720:flags=lanczos[v720];[wm480]scale=-2:480:flags=lanczos[v480];[wm360]scale=-2:360:flags=lanczos[v360]" -map [v1080] -map [v720] -map [v480] -map [v360] -map 0:a -flags:v +global_header -c:v libx264 -preset:v fast -b:v:0 "800k" -b:v:1 "600k" -b:v:2 "400k" -b:v:3 "300k" -c:a aac -b:a 128k -f tee "[select=\\'v:0,a\\']'{outputPath}/1080.mp4'|[select=\\'v:1,a\\']'{outputPath}/720.mp4'|[select=\\'v:2,a\\']'{outputPath}/480.mp4'|[select=\\'v:3,a\\']'{outputPath}/360.mp4'

both intro and video have different resolution


Use scale + pad/crop + setsar + concat filters. You did not provide any input file info so I will assume {fileInput} is 1920x1080 with SAR of 1, and {fileIntro} has audio.

{executable} -i {fileIntro} -i {fileInput} -i {watermark} -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080,setsar=1[introv];[introv][0:a][1:v][1:a]concat=n=2:v=1:a=1[vcat][acat];[vcat][2]overlay=x=(main_w-overlay_w-10):y=(10),split=4[wm1080][wm720][wm480][wm360];[wm1080]scale=-2:1080:flags=lanczos[v1080];[wm720]scale=-2:720:flags=lanczos[v720];[wm480]scale=-2:480:flags=lanczos[v480];[wm360]scale=-2:360:flags=lanczos[v360]" -map [v1080] -map [v720] -map [v480] -map [v360] -map [acat] -flags:v +global_header -c:v libx264 -preset:v fast -b:v:0 "800k" -b:v:1 "600k" -b:v:2 "400k" -b:v:3 "300k" -c:a aac -b:a 128k -f tee "[select=\\'v:0,a\\']'{outputPath}/1080.mp4'|[select=\\'v:1,a\\']'{outputPath}/720.mp4'|[select=\\'v:2,a\\']'{outputPath}/480.mp4'|[select=\\'v:3,a\\']'{outputPath}/360.mp4'

Adapted from Resizing videos with ffmpeg to fit into specific size.

If {fileInput} has no audio you have 2 options. Add another audio file:

{executable} -i {fileIntro} -i {audioIntro} -i {fileInput} -i {watermark} -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080,setsar=1[introv];[introv][1:a][2:v][2:a]concat=n=2:v=1:a=1[vcat][acat];[vcat][3]overlay=x=(main_w-overlay_w-10):y=(10),split=4[wm1080][wm720][wm480][wm360];[wm1080]scale=-2:1080:flags=lanczos[v1080];[wm720]scale=-2:720:flags=lanczos[v720];[wm480]scale=-2:480:flags=lanczos[v480];[wm360]scale=-2:360:flags=lanczos[v360]" -map [v1080] -map [v720] -map [v480] -map [v360] -map [acat] -flags:v +global_header -c:v libx264 -preset:v fast -b:v:0 "800k" -b:v:1 "600k" -b:v:2 "400k" -b:v:3 "300k" -c:a aac -b:a 128k -f tee "[select=\\'v:0,a\\']'{outputPath}/1080.mp4'|[select=\\'v:1,a\\']'{outputPath}/720.mp4'|[select=\\'v:2,a\\']'{outputPath}/480.mp4'|[select=\\'v:3,a\\']'{outputPath}/360.mp4'

Or add silent/filler audio with the anullsrc filter:

{executable} -i {fileIntro} -t 0.1 -f lavfi -i anullsrc -i {fileInput} -i {watermark} -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080,setsar=1[introv];[introv][1:a][2:v][2:a]concat=n=2:v=1:a=1[vcat][acat];[vcat][3]overlay=x=(main_w-overlay_w-10):y=(10),split=4[wm1080][wm720][wm480][wm360];[wm1080]scale=-2:1080:flags=lanczos[v1080];[wm720]scale=-2:720:flags=lanczos[v720];[wm480]scale=-2:480:flags=lanczos[v480];[wm360]scale=-2:360:flags=lanczos[v360]" -map [v1080] -map [v720] -map [v480] -map [v360] -map [acat] -flags:v +global_header -c:v libx264 -preset:v fast -b:v:0 "800k" -b:v:1 "600k" -b:v:2 "400k" -b:v:3 "300k" -c:a aac -b:a 128k -f tee "[select=\\'v:0,a\\']'{outputPath}/1080.mp4'|[select=\\'v:1,a\\']'{outputPath}/720.mp4'|[select=\\'v:2,a\\']'{outputPath}/480.mp4'|[select=\\'v:3,a\\']'{outputPath}/360.mp4'

Leave -t 0.1 for anullsrc as is. It makes sure the audio doesn't run indefinitely. The concat filter will pad the remaining duration with silence to match the corresponding video.