Apply scale and fade effect to Images together I am using below commands to overlay two images with scaling in video :

String command="ffmpeg -i /sdcard/videokit/input.mp4 -loop 1 -i /sdcard/videokit/first.png -loop 1 -i /sdcard/videokit/second.png -filter_complex [1:v]scale='if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'[img1];[2:v]scale='if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'[img2];[0:v][img1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[bkg];[bkg][img2]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2 -c:a copy -preset ultrafast /sdcard/videokit/output.mp4";

String command2="ffmpeg -i /sdcard/videokit/input.mp4 -loop 1 -t 2 -i /sdcard/videokit/first.png -loop 1 -t 2 -i /sdcard/videokit/second.png -filter_complex [1:v]trim=duration=2,fade=in:st=0:d=0.5,fade=out:st=1.5:d=0.5[img1];[2:v]trim=duration=2,fade=in:st=10:d=0.5,fade=out:st=11.5:d=0.5[img2];[0:v][img1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[bkg];[bkg][img2]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2 -preset ultrafast -c:a copy -preset ultrafast /sdcard/videokit/output.mp4";


First command works perfectly but I want to apply fade in fade out effect to both images for certain time.

I have tried with command2 after referring other answers but it doesn't seem to be working, any help would be appreciated!!!

Aim to achieve : Basically I have video of 12 seconds, first image has to be appear for first 2 seconds and last image for last 2 seconds with effect.
Try

String command2="ffmpeg -i /sdcard/videokit/input.mp4 -loop 1 -t 2 -i /sdcard/videokit/first.png -loop 1 -t 2 -i /sdcard/videokit/second.png -filter_complex "[0]boxblur=enable='lt(t,2)+gt(t,10)'[vid];[1:v]format=rgba,fade=in:st=0:d=0.5:alpha=1,fade=out:st=1.5:d=0.5:alpha=1[img1];[2:v]format=rgba,fade=in:st=0:d=0.5:alpha=1,fade=out:st=1.5:d=0.5:alpha=1,setpts=PTS+10/TB[img2];[vid][img1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[bkg];[bkg][img2]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -preset ultrafast -c:a copy /sdcard/videokit/output.mp4";