Doug
Doug

Reputation: 313

Error running exec() for FFMPEG in Android app

When following this tutorial: https://github.com/cine-io/android-ffmpeg-with-rtmp and after compiling successfully in Ubuntu 14.04 64-bits I get an IOException when trying to execute ffmpeg:

String abspath = getApplicationInfo().nativeLibraryDir;

        // Change the permissions
        try {
            Runtime.getRuntime().exec("chmod -R 777 "+ abspath).waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        String cameraPath = "/storage/emulated/0/DCIM/Camera/";
        String cmd = "ffmpeg -i "+ cameraPath + "VID_20150728_150045662.mp4 -y "+ cameraPath + "output.mp4";

        ProcessBuilder processBuilder = new ProcessBuilder(cmd);

        final Map<String, String> environment = processBuilder.environment();

        environment.put("LD_LIBRARY_PATH", getDir("lib", 0).getAbsolutePath());

        try {
            Process process = processBuilder.start();
        } catch (IOException e) {
            e.printStackTrace();
        }

And the IOException is:

Error running exec(). Command: [ffmpeg -i /storage/emulated/0/DCIM/Camera/VID_20150728_150045662.mp4 -y /storage/emulated/0/DCIM/Camera/output.mp4] Working Directory: null Environment: [ANDROID_ROOT=/system, EMULATED_STORAGE_SOURCE=/mnt/shell/emulated, LOOP_MOUNTPOINT=/mnt/obb, EMULATED_STORAGE_TARGET=/storage/emulated, ANDROID_BOOTLOGO=1, LD_LIBRARY_PATH=/data/data/douglasanunciacao.ndksample/app_lib, EXTERNAL_STORAGE=/storage/emulated/legacy, ANDROID_SOCKET_zygote=11, ANDROID_DATA=/data, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, BOOTCLASSPATH=/system/framework/core.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/framework2.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/webviewchromium.jar:/system/framework/telephony-msim.jar:/system/framework/oem-services.jar:/system/framework/qcmediaplayer.jar, ANDROID_PROPERTY_WORKSPACE=9,0, ANDROID_STORAGE=/storage]

Does anyone knows the solution for this problem?

Upvotes: 0

Views: 705

Answers (1)

StephenG
StephenG

Reputation: 2881

You probably need to get the fully qualified path for ffmpeg into the command.

If it's in the folder /data/data/douglasanunciacao.ndksample/app_lib, then String cmd = "/data/data/douglasanunciacao.ndksample/app_lib/ffmpeg -i "+ cameraPath + "VID_20150728_150045662.mp4 -y "+ cameraPath + "output.mp4";

Upvotes: 1

Related Questions