FFmpeg在Android中的视频上叠加多个图像/ gif?

最后发布: 2019-12-03 10:24:26


问题

我正在尝试在视频上放置多个图像/ gif。 我曾尝试将单个gif放在图像或视频上,其效果很好,但无法处理多个图像。 尝试以下代码,但出现错误:

        String[] newCmd = new String[17];
        newCmd[0]="-i";
        newCmd[1]="storage/emulated/0/DCIM/ScreenRecorder/Video1.mp4";
        newCmd[2]="-i";
        newCmd[3]=thumbnail;
        newCmd[4]="-i";
        newCmd[5]=thumbnail;
        newCmd[6]="-i";
        newCmd[7]=thumbnail;
        newCmd[8]="-filter_complex";
        newCmd[9]="[0][1]overlay=50:50:enable='between(1,23,27)'[v1]";
        newCmd[10]="[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]";
        newCmd[11]="[v2][3]overlay=70:70:enable='gt(1,112)'[v3]";
        newCmd[12]="-map";
        newCmd[13]="[v3]";
        newCmd[14]="-map";
        newCmd[15]="0:a";
        newCmd[16]="/storage/emulated/0/Pictures/logo-1111.mp4";


        fFmpeg.execute(newCmd,
                new ExecuteBinaryResponseHandler() {

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

                    @Override
                    public void onProgress(String message) {
                        //for logcat
                        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");
                    }
                });

我得到的错误是:

[NULL @ 0xa9a1ce00] Unable to find a suitable output format for '[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]'
[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]: Invalid argument

由于我是ffmpeg的新手,请帮助我解决问题

android-ffmpeg