簡體   English   中英

Android 中的 Ffmpeg 命令不起作用。 創建多個圖像的視頻

[英]Ffmpeg Command in Android not working. Creating a Video of several Images

我嘗試從我的文件夾中加載 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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM