java - Android 中的 Ffmpeg 命令不起作用。创建多个图像的视频
问题描述
我尝试从我的文件夹中加载 png 并将其放在一个视频中。我使用 Mobile-FFmpeg 作为库和 Android Studio
但是执行命令后我不断收到错误代码:
I/mobile-ffmpeg:命令执行失败,rc=1,输出如下。
我的图像之前是这样保存的
我使用的命令: int rc = FFmpeg.execute(" ffmpeg -r 1/5 -i "+ src+"/img%03d.png -c:v libx264 -vf \"fps=25,format=yuv420p\" " + src + "/ou1t.mp4");
这是整个代码:
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/FlyerMaker/ffmpeg";
File dir = new File(dirPath);
String src = Environment.getExternalStorageDirectory().getAbsolutePath()+"/FlyerMaker/ffmpeg";
int rc = FFmpeg.execute(" ffmpeg -r 1/5 -i "+ src+"/img%03d.png -c:v libx264 -vf \"fps=25,format=yuv420p\" "+ src + "/ou1t.mp4");
if (rc == RETURN_CODE_SUCCESS) {
Log.i(Config.TAG, "Command execution completed successfully.");
} else if (rc == RETURN_CODE_CANCEL) {
Log.i(Config.TAG, "Command execution cancelled by user.");
} else {
Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
Config.printLastCommandOutput(Log.INFO);
}
//清除文件夹,因为在上面的代码之后我不再需要图片了
for(int i = 0; i < 20 ; i++){
String filePrefix = "img"; //imagename prefix
String fileExtn = ".png";//image extention
String a = filePrefix + String.format("%03d", i)+fileExtn;
File file = new File(dir, a);
file.delete();
System.out.println("del"+i);
}
解决方案
如果没有显示错误的日志,我最好的猜测是ffmpeg
不应该包含在命令中:
int rc = FFmpeg.execute("-r 1/5 -i " + src + "/img%03d.png -c:v libx264 -vf \"fps=25,format=yuv420p\" "+ src + "/out.mp4");
推荐阅读
- jquery - 如何按类别分隔行中的特定项目,如果有一个项目具有不同的类别,则追加到新行中
- javascript - 角度路由,包括身份验证保护和重定向
- javascript - 防止重新渲染数组映射组件
- typescript - 如何将声明的条件推断类型与另一个类似的条件推断类型匹配
- c# - 检查两个具有半径的地理位置是否在彼此的半径内
- python - 如何在 unittest 测试期间添加计数器?
- python - 第三方包的 mock.patch() 的 Pytest 路径
- django - Django - 将二进制流转换为图像
- javascript - 使用钩子时如何为 panResponder 设置偏移量?
- java - 视图和投影矩阵不起作用