1

I want to combine two ffmpeg commands to a single command. I am using ready made ffmpeg binary in my Android application. I want to concat .ts files and overlay an image.

I am using following commands:

  1. To concat .ts files:

    String[] ffmpegcommand = {"ffmpeg", "-i","concat:"+input_file_path+"|"+input_file_path1, "-c", "copy", "-bsf:a", "aac_adtstoasc", output_file_path};
    
  2. Apply image overlay effect:

    String[] ffmpegcommand = {"ffmpeg","-y" ,"-i", input_file_path,"-strict","experimental", "-vf","movie="+AppStaticData.BASE_FOLDER_PATH + File.separator + "watermarklogo.png"+" [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]", AppStaticData.BASE_FOLDER_PATH+"/" + output_file_path};
    
llogan
  • 63,280

2 Answers2

5

You can do this in one command with the concat filter:

ffmpeg -i input0.ts -i input1.ts -i input2.ts -i overlay.png -filter_complex \
"[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[vv][a]; \
 [vv][3:v]overlay=W-w-10:10[v]" \
-map "[v]" -map "[a]" output.mp4
llogan
  • 63,280
0

Many thanks to LordNeckbeard just one thing is that you may think his solution doesn't work because if you copy and paste everything will not work. Just put it all as one line and it will work like so:

ffmpeg -i file1.mp4 -i file2.mp4 -i file3.mp4 -i watermark.png -filter_complex "[0:v]setpts=PTS-STARTPTS[v0]; [1:v]setpts=PTS-STARTPTS[v1]; [2:v]setpts=PTS-STARTPTS[v2]; [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][aout]; [v][3:v]overlay=W-w-10:10[vout]" -map "[vout]" -map "[aout]" output.mp4