magiclen / FFmpeg-CLI-For-Android

Now, you can edit audios and videos by using Command Line Interface for FFmpeg.
https://magiclen.org/ffmpeg-android/
24 stars 7 forks source link

Process.start err #3

Closed aikongmeng closed 8 years ago

aikongmeng commented 8 years ago

參考了這個文章

File fileBinDir = new File(activity.getFilesDir().getParentFile(), "lib"); //FFmpeg執行檔的所在目錄
File fileBin = new File(fileBinDir, "libffmpeg.so"); //FFmpeg執行檔的檔案路徑
ProcessBuilder pb = new ProcessBuilder(cmds); //cmds為Command Line的指令,例如某行指令為:「libffmpeg.so -h」cmds的List內容就是["libffmpeg.so","-h"]
pb.directory(fileBinDir); //將工作目錄移到FFmpeg執行檔的所在目錄,不過還是建議在cmds中以絕對路徑來表示libffmpeg.so
pb.redirectErrorStream(true); //將FFmpeg的標準輸出和錯誤輸出合併成同一個inputStream
Process process = pb.start(); //執行行程

不知道為何在執行

pb.start(); 時候報錯. 錯誤信息如下:

java.io.IOException: Error running exec(). Command: [ffmpeg, -version] Working Directory: /data/data/com.example.magiclen/lib Environment: [EXTERNAL_ADD_USB_STORAGE4=/storage/USBstorage4, EXTERNAL_ADD_USB_STORAGE2=/storage/USBstorage2, EMULATED_STORAGE_TARGET=/storage/emulated, EXTERNAL_ADD_USB_STORAGE6=/storage/USBstorage6, EXTERNAL_ADD_USB_STORAGE3=/storage/USBstorage3, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, EXTERNAL_ADD_USB_STORAGE5=/storage/USBstorage5, BOOTCLASSPATH=/system/framework/WfdCommon.jar:/system/framework/aspectjrt.jar:/system/framework/com.lge.frameworks.jar:/system/framework/com.lge.policy.jar:/system/framework/telephony-target.jar:/system/framework/com.lge.opt.jar:/system/framework/bc-fips.jar:/system/framework/tcmiface.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/apache-xml.jar, SECONDARY_STORAGE=/storage/external_SD, ANDROID_STORAGE=/storage, EXTERNAL_ADD_USB_STORAGE1=/storage/USBstorage1, ANDROID_ROOT=/system, EMULATED_STORAGE_SOURCE=/mnt/shell/emulated, LOOP_MOUNTPOINT=/mnt/obb, LD_PRELOAD=libsigchain.so:libNimsWrap.so, ANDROID_BOOTLOGO=1, EXTERNAL_STORAGE=/storage/emulated/legacy, SYSTEMSERVERCLASSPATH=/system/framework/com.lge.services.jar:/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, EXTERNAL_ADD_STORAGE=/storage/external_SD, ANDROID_SOCKET_zygote_secondary=12, ANDROID_PROPERTY_WORKSPACE=10,0]
magiclen commented 8 years ago

建議您使用MagicCommand這個函式庫

aikongmeng commented 8 years ago

使用了MagicCommand這個函式庫之後,還是報出上面一樣的問題. 看了magiclen的網站,感覺很不錯. https://github.com/magiclen/FFmpeg-CLI-For-Android 這個APP寫的非常好.如果可以開源的話就更好了.這樣我就可以比葫蘆畫瓢的處理上面的問題了.

magiclen commented 8 years ago

[ffmpeg, -version]這個指令應該是錯的,[libffmpeg.so, -version]才對

aikongmeng commented 8 years ago

試過這個指令[libffmpeg.so, -version]同樣的提示:

java.lang.RuntimeException: Error running exec(). Command: [libffmpeg.so, -version]

下面是我程序代碼,幫指點下吧.tks. MainActivity.java

magiclen commented 8 years ago

以下幾點參考一下

1.可使用File物件的canExecute方法來判斷FFmpeg執行檔可否執行 2.你的MainActivity.java的chmod指令有誤 3.執行指令建議使用絕對路徑

aikongmeng commented 8 years ago

thanks all the same

magiclen commented 8 years ago

You're welcome