【问题标题】:Ffmpeg Command in Android not working. Creating a Video of several ImagesAndroid 中的 Ffmpeg 命令不起作用。创建多个图像的视频
【发布时间】:2020-06-05 16:55:51
【问题描述】:

我尝试从我的文件夹中加载 png 并将其放在一个视频中。 我使用 Mobile-FFmpeg 作为Library 和 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);
            }

【问题讨论】:

    标签: java android video ffmpeg command


    【解决方案1】:

    如果没有显示错误的日志,我最好的猜测是 ffmpeg 不应该包含在命令中:

    int rc = FFmpeg.execute("-r 1/5 -i " + src + "/img%03d.png -c:v libx264 -vf \"fps=25,format=yuv420p\" "+ src + "/out.mp4");
    

    【讨论】:

      猜你喜欢
      • 2016-12-15
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      • 2019-10-24
      • 2012-08-21
      • 1970-01-01
      • 2015-05-07
      • 2020-01-28
      相关资源
      最近更新 更多