【问题标题】:FFmpeg scale and overlay multiple images/gif on image in android issue?FFmpeg 在 android 问题的图像上缩放和覆盖多个图像/gif?
【发布时间】:2020-03-28 00:12:27
【问题描述】:

我正在尝试在图像上放置多个图像/gif。我曾尝试将单个 gif 放在图像或视频上,它工作得非常好,但不能同时缩放多个图像。尝试以下代码但出现错误:

        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");
                    }
                });

我得到的错误是:

[NULL @ 0xb6591800] 无法为“filter_complex”找到合适的输出格式 filter_complex: 参数无效

由于我是 ffmpeg 新手,请帮助我解决我只想同时缩放和覆盖多个图像的问题。

【问题讨论】:

    标签: ffmpeg android-ffmpeg


    【解决方案1】:

    你需要:

    1. 使用-filter_complex 而不是filter_complex
    2. 将过滤器链作为一个参数传递给-filter_complex

    所以而不是:

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

    做:

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

    如您所见,需要在一项中指定所有过滤器。

    【讨论】:

    • Tysm,尝试了代码。它工作得很好。如果我需要为每个输入指定角度怎么办?
    • 我不确定您指定角度是什么意思。你想旋转输入吗?使用旋转过滤器:ffmpeg.org/ffmpeg-filters.html#rotate
    猜你喜欢
    • 2020-05-10
    • 1970-01-01
    • 2019-01-20
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多