2

I want to use FFMPEG via COMMAND LINE in my android application.For this purpose:

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

This is the code i am using:

public class FFMPEGActivity 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.

4
  • Someone please help..........i am totally frustrated.I will be more than thankful to you. Commented Sep 18, 2012 at 7:35
  • Why do you expect that to work? Commented Sep 18, 2012 at 8:08
  • Sir actually i want to access ffmpeg lib through that Commented Sep 18, 2012 at 8:10
  • can't i use ffmpeg through command line in android. Commented Sep 18, 2012 at 8:12

3 Answers 3

1

I think this won't work, unless you somehow manage to compile ffmpeg executable, place it somewhere in the file system , then access it through your native layer. Normally, though, they use libffmpeg API in android such as in Dolphin Player

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

2 Comments

Sir i have ffmpeg executable file.Can't i place it in some app folder itself and then work with that like we work with ffmpeg in cmd prompt.
can you please help me with compiling ffmpeg? I am struggling to create a video by combining an audio and an image. Please help!
1

Your code seems to try to run the library, not the ffmpeg executable. Note that even after fixing your cmd you will need extra tricks to load the libffmpeg.so, because Android loader does not load shared libs from ./

I would suggest to build a statically linked ffmpeg executable to save hassle.

Comments

0

Place ffmpeg and all the files it accesses on the internal card (obtain through context.getDir("", 0). After you do this, you will be able to run ffmpeg through exec().

Some models, however, will refuse running this too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.