I am using FFmpeg for video editing in android. I am able to trim, crop and add overlay using below commands:
For trim:
command = new String[]{"-i",inputVideoFilePath,"-ss","00:00:30.0","-c","copy","-t","00:00:10.0",outputVideoFilePath};
For crop:
command = new String[]{"-i",inputVideoFilePath,"-preset", "ultrafast","-filter:v","crop=400:400:0:0","-c:a","copy", outputVideoFilePath};
For overlay:
command = new String[]{"-i",inputVideoFilePath, "-i",overlayImagePath,"-preset", "ultrafast","-filter_complex", "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2", "-codec:a", "copy", outputVideoFilePath};
but I'm unable to merge these commands into a single command. Please help me.
Use
command = new String[]{"-ss", "00:00:30.0", "-t", "00:00:10.0", "-i",inputVideoFilePath,
"-i",overlayImagePath, "-filter_complex",
"[0]crop=400:400:0:0[a];[a][1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2",
"-preset", "ultrafast", "-codec:a", "copy", outputVideoFilePath};
A filter_complex allows one to perform multiple filtering operations on different inputs in series or in parallel.