Shweta Patil
Shweta Patil

Reputation: 19

FFmpeg scale and overlay multiple images/gif on image in android issue?

I am trying to place multiple images/gif on image. I had tried placing single gif on image or video and its working perfectly fine but not able to work with multiple images with simultaneous scaling. Tried below code but getting error:

        String[] command=new String[13];
        command[0]="-i";
        command[1]=input;
        command[2]="-i";
        command[3]=thumbnail2;
        command[4]="-i";
        command[5]=thumbnail;
        command[6]="filter_complex";
        command[7]="[0:v]scale=0:0[base]";
        command[8]="[1:v]scale=30:-1[img1]";
        command[9]="[2:v]scale=3000:-1[img2]";
        command[10]="[base][img1]overlay=70:70[tmp1]";
        command[11]="[tmp1][img2]overlay=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2[out]";

        command[12]="/storage/emulated/0/Pictures/logo-2000.gif";
        fFmpeg.execute(command,
                new ExecuteBinaryResponseHandler() {

                    @Override
                    public void onStart() {
                        //for logcat
                        Log.w(TAG,"Cut started");
                    }

                    @Override
                    public void onProgress(String message) {
                       Log.w(TAG,message.toString());
                    }

                    @Override
                    public void onFailure(String message) {

                        Log.w(TAG,message.toString());
                        Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_SHORT).show();

                    }

                    @Override
                    public void onSuccess(String message) {

                        Log.w(TAG,message.toString());
                        Toast.makeText(getApplicationContext(),"sucessfully saved",Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onFinish() {

                        Log.w(TAG,"Cutting video finished");
                    }
                });

Error I am getting is:

[NULL @ 0xb6591800] Unable to find a suitable output format for 'filter_complex' filter_complex: Invalid argument

As I am new to ffmpeg please help me to resolve the issue I just want to scale and overlay multiple images simultaneously.

Upvotes: 0

Views: 1223

Answers (1)

slhck
slhck

Reputation: 38672

You need to:

  1. Use -filter_complex instead of filter_complex
  2. pass the filterchain as one argument to -filter_complex

So instead of:

...
command[6]="filter_complex";
command[7]="[0:v]scale=0:0[base]";
command[8]="[1:v]scale=30:-1[img1]";
...

Do:

...
command[6]="-filter_complex";
command[7]="[0:v]scale=0:0[base];[1:v]scale=30:-1[img1];...";
...

As you can see, all filters need to be specified in one item.

Upvotes: 1

Related Questions