我正在尝试使用ffmpeg lib在视频上添加图像。它显示
[NULL @ 0xb6dab000]无法找到适合的输出格式 'ffmpeg' ffmpeg:无效的参数
String addimg[]={"ffmpeg", "-i", inputpath,"-i", imagepath ,"\"" +"-filter_complex", "[0:v][1:v] overlay=25:25:enable='between(t,0,10)'" ,"\"" +"-pix_fmt yuv420p", "-c:a copy","\"" +output};
LoadFFmpegLibrary
public void LoadFFmpegLibrary()
{
if(ffmpeg==null)
{
ffmpeg = FFmpeg.getInstance(MainActivity.this);
try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onStart() {
Log.e("ffmpef","Start to load");
}
@Override
public void onFailure() {
Log.e("ffmpef","failed to load");
}
@Override
public void onSuccess() {
Log.e("ffmpef","load Successfully");
ExcuteFfmpefLibrabry(addimg);
}
@Override
public void onFinish() {}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
Log.e("ffmpef",e.toString());
}
}
}
public void ExcuteFfmpefLibrabry(String command[])
{
ffmpeg = FFmpeg.getInstance(MainActivity.this);
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
Log.e("ffmpef","Exaction Start");
}
@Override
public void onProgress(String message) {}
@Override
public void onFailure(String message) {
Log.e("ffmpef","failed to Excute Command");
Log.e("ok",message);
}
@Override
public void onSuccess(String message) {
Log.e("ffmpef","Video Edited Successfully");
Log.e("ok",message);
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Log.e("ffmpef",e.toString());
}
}
答案 0 :(得分:0)
我已经看过您的代码,并知道您正在使用Android的FFMPEG编写思想吗?
而且您的错误也表示ffmpeg无效argumnet意味着在FFMPEG中找不到ffmpeg
当您传递命令来编写构想时
例如:
您传递的命令如:String command[]={"ffmpeg","-i",inputpath,outputpath};
然后ffmpeg执行以下代码::-ffmpeg ffmpeg -i inputpath outputpath
因此ffmpef在其构建中找不到名为ffmpeg的参数
因此请更改您的命令
来自
String addimg[]={"ffmpeg", "-i", inputpath,"-i", imagepath ,"\"" +"-filter_complex", "[0:v][1:v] overlay=25:25:enable='between(t,0,10)'" ,"\"" +"-pix_fmt yuv420p", "-c:a copy","\"" +output};
到
String addimg[]={"-i", inputpath,"-i", imagepath ,"-filter_complex", "[0:v][1:v] overlay=25:25:enable='between(t,0,10)'" ,"-pix_fmt yuv420p", "-c:a copy",output};