cropsly / ffmpeg-android-java

Android java library for FFmpeg binary compiled using https://github.com/writingminds/ffmpeg-android
http://writingminds.github.io/ffmpeg-android-java
GNU General Public License v3.0
3.32k stars 831 forks source link

With environvenmentVars set, execute will cause IO exception #159

Open JunfeiW opened 7 years ago

JunfeiW commented 7 years ago

I added a env, which is not harmful to anything, as follows: HashMap<String, String> env1 = new HashMap<String, String>(); env1.put("a", "a");

However, when execute command, it will failed with exception:

E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@3e95a0bd java.io.IOException: Error running exec(). Command: [a=a /data/data/com.test.abc/files/ffmpeg, -y, -i, /storage/emulated/0/Android/data/com.test.abc/files/video/La leggenda del pianista sull'oceano/57bd5f5a8ac24700631918df.mp4, -i, /storage/emulated/0/Android/data/com.test.abc/files/video/La leggenda del pianista sull'oceano/useraudioswithbackground.aac, -c:v, copy, -c:a, copy, -strict, -experimental, -map, 0:v:0, -map, 1:a:0, -bsf, aac_adtstoasc, /storage/emulated/0/Android/data/com.test.abc/files/video/La leggenda del pianista sull'oceano/57bd5f5a8ac24700631918df_ff.mp4] Working Directory: null Environment: null at java.lang.ProcessManager.exec(ProcessManager.java:211) at java.lang.Runtime.exec(Runtime.java:173) at java.lang.Runtime.exec(Runtime.java:128) at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)

JunfeiW commented 7 years ago

if without the env, everything works fine

JunfeiW commented 7 years ago

Since nobody answered, I did do some homework for this problem. When env is set, getFFmpeg will be run to : if (environmentVars != null) { for (Map.Entry<String, String> var : environmentVars.entrySet()) { ffmpegCommand += var.getKey()+"="+var.getValue()+" "; } } ffmpegCommand += getFFmpeg(context);

Which means, add env at the begin of call command. And execute : Runtime.getRuntime().exec(commandString)

However, there is a problem, this is not acceptable for android. Should call this function: public Process exec(String[] progArray, String[] envp) throws java.io.IOException {

Which means, should pass the env to here ..

JunfeiW commented 7 years ago

Now, please have a try this lib with environments and fix the problem if I'm right. Great thanks ...

JunfeiW commented 7 years ago

Hi, guy, nobody care about this serious problem?

JunfeiW commented 7 years ago

So, this project is not maintained anymore?

tzutalin commented 6 years ago

@JunfeiW , I met the same problem. Is calling exec(String[] progArray, String[] envp) a solution?

JunfeiW commented 6 years ago

I think so, but since it is not working, we did change the functionality

tzutalin commented 6 years ago

@JunfeiW, As you said, it works by changing the method.

JunfeiW commented 6 years ago

Great! Nice to hear that.

lucazin commented 6 years ago

Hello folks

i try the solution but i get the same error ..

Error running exec(). Command: [a=a /data/user/0/br.com.oneplace/files/ffmpeg, -y, -i, /storage/emulated/0/OnePlace/Videos/Enviados/OnePlace_Video_TempFile.mp4, -c:v, libx264, -crf, 40, -b:v, 512k, -c:a, aac, /storage/emulated/0/OnePlace/Videos/Enviados/OnePlace_Video__180416_223500.3gp] Working Directory: null Environment: null

i put a hashmap HashMap<String, String> env1 = new HashMap<String, String>(); env1.put("a", "a");

but no works in galaxy s5 android 6.0.1

please help me

lucazin commented 6 years ago

i dont know working directory and enviroment