我正在尝试在图像上放置多个图像/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 的新手,请帮助我解决我只想同时缩放和覆盖多个图像的问题。
最佳答案
你需要:
-filter_complex
而不是 filter_complex
-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];...";
...
如您所见,所有过滤器都需要在一项中指定。
关于FFmpeg 在 android 问题的图像上缩放和覆盖多个图像/gif?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59154890/