3
File dir = new File("/mnt/sdcard");
Process process = Runtime.getRuntime().exec("ffmpeg -f image2 -i img%4d.png video.mp4", null, dir);

when i try this line in android,i get environment and working directory null error in android. But when i try that line in java,it worked perfectly.but in android,it has some problem.

3
  • You can't access any directory outside Android source. Reason see here Commented Oct 20, 2012 at 5:26
  • @hotveryspicy The word 'source' does not appear in that link. What are you talking about? Commented Oct 20, 2012 at 9:16
  • @EJP What I saw earlier, OP asking about using resource of PC( ie. C:\,D:\ ) so I mean that you aren't able to access external resource. Commented Oct 20, 2012 at 9:37

4 Answers 4

3
i get environment and working directory null

It will return null because there is not path like /mmt/sdcard instead use /mnt/sdcard.

enter image description here

It will be best if you use Environment.getExternalStorageDirectory().

Sign up to request clarification or add additional context in comments.

1 Comment

/sdcard is a synonym to /mnt/sdcard, but you are right that it is strongly recommended to use Environment.getExternalStorageDirectory(). But the problem is not with this.
2

Because there is no drive like E: in your either Emulator or Device.

You can't access any drives of your PC in android like this.

EDIT :

File dir = Environment.getExternalStoragePublicDirectory();
File f = new File(dir."Yourfilename.png");

1 Comment

ok when i put the line as directory File dir = new File("/mmt/sdcard"); it will produced the environment null error in android.is there any environment,to use ffmpeg commandline...
1

Android security does not allow launching executables from sdcard or usb memory.

You can deploy the executable in your app files/ directory or in globally writeable /data/local/ directory. Don't forget to chmod 777!

Instead of usung exec("cmd", env, new File("dir")) call exec("dir/cmd")

Comments

0

Android probably doesn't have an E drive, in fact I can guarantee it. Android has a linux operating system and doesn't use the same drive naming convention. Also, I would consider using a ProcessBuilder whenever writing code that spawns processes. It has an easier time parsing command line options.

1 Comment

ok when i change the directory as File dir = new File("/mmt/sdcard"); it will produced the environment null error in android.is there any environment,to use ffmpeg commandline?how to set environment in android?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.