2

I want to use ffmpeg via command line arguments in android application.For this purpose:

  1. I have cross-compiled the ffmpeg lib and got the libffmpeg.so
  2. I have stored libffmpeg.so in files directory of the app.

This is the code i am using:

public class MainActivity extends Activity { Process p; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] cmd =new String[4]; cmd[0]="/data/data/com.example.ffmpegnew/files/libffmpeg"; cmd[1]="-i"; cmd[2]="mnt/sdcard/music/baba.mp4"; cmd[3]="mnt/sdcard/music/outfile.mp4"; p = Runtime.getRuntime().exec(cmd,null, new File("/data/data/com.example.ffmpegnew/files")); } catch(Exception e) { System.out.println("exception"+e); } } } 

This is the exception i am getting:

09-17 13:47:01.679: I/System.out(3752): exceptionjava.io.IOException: Error running exec(). Command: [/data/data/com.example.ffmpegnew/files/libffmpeg.so, -i, mnt/sdcard/music/baba.mp4, mnt/sdcard/music/outfile.mp4] Working Directory: /data/data/com.example.ffmpegnew/files Environment: null 

Please tell me how to solve this problem.Thanks in advance.

0

1 Answer 1

1

I guess you are trying to run an .so file with this Linux command:

/data/data/com.example.ffmpegnew/files/libffmpeg.so -i mnt/sdcard/music/baba.mp4 mnt/sdcard/music/outfile.mp4

Did you actually mean running ffmpeg executable file (see man ffmpeg)?

ffmpeg -i mnt/sdcard/music/baba.mp4 mnt/sdcard/music/outfile.mp4

I think the first step might be making your command, then your code snippet run on regular Linux, then moving it to Android.

PS. In any event, the leading "/" is missing from "mnt/..."; should be "/mnt/..."

PPS. And other discussions might be helpful 1

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

7 Comments

yes sir, i want to run ffmpeg executable file like we run it on cmd in windows.
I think sir,there must be some way of running the ffmpeg using command line in android
Please check the link in the answer above: some people have apparently had some success with that: stackoverflow.com/questions/4725773/ffmpeg-on-android?rq=1
This is not helpful in my case sir.
Anyway, I think to go further down that path, you will need to: 1) build the (static?) executable; 2) at least fix the leading "/". Then run your code, having the leading "lib" removed from your first parameter. Oh, and, BTW, make sure the binaries (executable, lib) are really deployed to that directory.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.