6

I have a very basic question regarding Android and ffmpeg. I obtained ffmpeg from http://bambuser.com/opensource and was able to compile it for ARM.

The results are the binaries (ffmpeg) as well as several libsomething.so files.

My question is: Is this enough to decode videos? How do I actually use ffmpeg then?

To load the library I have:

static {
    System.load("/data/data/com.package/lib/libavcodec.so");
 }

It loads fine. But what then?

More explanation: I saw other projects where people had their ffmpeg source in a JNI directory in the project. They also created some Android.mk files and some C code along with it. Would I need this as well? Why would I create the .so files first and then copy the ffmpeg source code again?

I know the NDK and how it should work but I've never seen an example of how one would actually call ffmpeg functions using it, because people seem to be hiding their implementations (which is sort of understandable) but not even giving useful pointers or examples.

Let's just say I wanted to decode a video file. Which kind of native methods would I need to implement? How do I run the project? Which data types need to be passed? etc. There are certainly a few people here who have at least done that, I know this from searching for hours and hours.

Akash Singh
  • 5,171
  • 2
  • 26
  • 55
slhck
  • 36,575
  • 28
  • 148
  • 201
  • how did you compile ffmpeg downloaded from the link http://bambuser.com/opensource – Swathi EP Sep 19 '11 at 10:07
  • @Swathi That wasn't too hard to do. Just follow the instructions that are inside this folder in the `INSTALL` document. – slhck Sep 19 '11 at 10:08
  • thanks for the quick reply :) I am downloading it, i will follow the instructions in it. I am working on windows, does it require any other configurations? – Swathi EP Sep 19 '11 at 10:13
  • I unfortunately don't know about Windows! These things are really easy to compile on OS X or any Linux. I suppose you will need GNU Make installed (you should probaby get [Cygwin](http://www.cygwin.com/)) @swathi – slhck Sep 19 '11 at 10:14
  • ya i have installed cygwin. Actually i already have downloaded ffmpeg source and configured it through commands, ./configure, make and make install. But i didn't find any .so file, how to get .so files from the ffmpeg source? – Swathi EP Sep 19 '11 at 10:18
  • Ah, I'm sorry. The bambuser has a `README` that actually lists everything. You need to execute `build.sh`. It will put the `.so` files into `build/ffmpeg/armeabi/lib`. @swathi – slhck Sep 19 '11 at 10:20
  • oh no, i am facing some problem. Here is the error log: arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed. If you think configure made a mistake, make sure you are using the lates version from SVN. If the latest version fails, report the problem to th ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net Include the log file "config.log" produced by configure as this will hel solving the problem. – Swathi EP Sep 19 '11 at 10:36
  • @Swathi You should probably make a new question for this. I won't be able to help you over the comments – this is what questions on Stack Overflow are for :) – slhck Sep 19 '11 at 10:37
  • http://stackoverflow.com/questions/7469722/error-while-executing-build-sh-in-ffmpeg-android here is my question above regarding the error which i mentioned in the comment, help me if u know to resolve it. – Swathi EP Sep 19 '11 at 10:48
  • please help me with: http://stackoverflow.com/questions/14157030/how-to-include-ffmpeg-functions-in-android-code/14157200#14157200, I do not know where to include this function and run!..... – TharakaNirmana Jan 15 '13 at 06:29
  • @TharakaNirmana You should ask the person who answered you to explain better. But you should also include the specific problem you're currently stuck with. I cannot help you with that, sorry. – slhck Jan 15 '13 at 06:31
  • I am searching a way to create a video by combining an audio file and an image, within the android code. I figured out the command for that: ffmpeg -i allmapeople.mp3 -i Penguins.jpg video_finale.mpg I tried many 2 tutorials using ffmpeg that generates the .so file. But I still could not find out a way to combine an audio and an image. – TharakaNirmana Jan 15 '13 at 06:34
  • @TharakaNirmana I cannot help you with programming for that, sorry. Ask the person who answered you: http://stackoverflow.com/a/14157200/435093 – slhck Jan 15 '13 at 06:39

1 Answers1

6

For your first question;

Just building is not enough for the proper use of the ffmpeg libraries. You should also wrap those so files in the right order because these so files NEED other libraries in the link time. You can display header information of the so file, by using.

objdump -x libavcodec.so | grep NEEDED

So you need to wrap these so files through Android.mk. You may check this link.

The second one;

You only need the header files from the ffmpeg project. The implementation will linked from the so libraries. Thats perhaps because, developers didn't bother to filter header files.

And the last one;

your thoughts seems right for the time being, most of the current developers are struggling to use ffmpeg but they lack of documentation and sample codes.

thatGuy
  • 122
  • 1
  • 10
Aksel Fatih
  • 1,419
  • 18
  • 31
  • thanks for information...I build my ffmpeg lib and i got so files ..i want to develop app which compress the video file size.;so what should i do ..i mean what are methods available for compressing videos in ffmpeg can you help me? – Swap-IOS-Android Aug 28 '13 at 15:40
  • @Swap-IOS-Android i am facing same issue ,Did you got any solution? – Parag Chauhan Dec 26 '13 at 19:10
  • @ParagChauhan no i used javac lib instead of ffmpeg to convert my videos – Swap-IOS-Android Dec 27 '13 at 02:30
  • @Swap-IOS-Android I don't know the how you can compress the video but I guess you can convert video to some other encoding format which needs much less space. Also you can check this question http://stackoverflow.com/questions/20514058/compress-videos-using-ffmpeg-and-jni – Aksel Fatih Dec 27 '13 at 08:14