我想使用FFmpeg-Android-Java分割动画gif文件,因此我参考了这个问题Android, split gif to frames with ffmpeg 并编写了这段代码。
String path = "/storage/emulated/0/Download/mothersday-toaster.gif";
String cmd[] = {"-i",path,"-vsync","0","/storage/emulated/0/Download/output$03d.png"};
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {}
@Override
public void onProgress(String message) {}
@Override
public void onFailure(String message) {Log.d("Q", "failed to convert");}
@Override
public void onSuccess(String message) {}
@Override
public void onFinish() {}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
}
尽管如此,它始终为我提供“转换失败”日志。 FFMPEG已加载。我的代码有问题吗?
答案 0 :(得分:0)
好,所以解决方案很容易。
我发现onProgress输出说它需要权限,所以我注意到我忘了给我的应用程序WRITE_EXTERNAL_STORAGE权限,这有点可惜。而且,我将output$03d
部分更改为output%03d
。感谢Gyan的建议。