#!/usr/bin/env bash # run this in the directory containing pngs image_array=(*.png) strStart="ffmpeg" strInput="" strFilter="" strEnd="concat=n=${#image_array[@]}:v=1:a=0,format=yuv420p[v]\" -map \"[v]\" out.mp4" # build input string for i in ${image_array[@]}; do strInput="$strInput -loop 1 -t 5 -i $i" done strInput="$strInput -filter_complex" # build filter string for (( x=0; x<${#image_array[@]}; x++ )); do if [[ $x == 0 ]];then strFilter="\"[0:v]fade=t=out:st=4:d=1[v0];" else strFilter="$strFilter ["$x":v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v"$x"];" fi strNumber="$strNumber[v"$x"]" done # view the command echo "Running ==> $strStart $strInput $strFilter $strNumber $strEnd" echo echo # run built command bash -c "$strStart $strInput $strFilter $strNumber $strEnd"