0

I would like to use FFmpeg library on my android app. I have no C/C++/Make knowledge and all the threads I've been reading about it talk about stuff I completely don't understand.

Is there any pre-compiled library which I can add to my project, then add a simple 'import' statement on my java class and then call it?

Thanks

Lik Sif
  • 39
  • 1

3 Answers3

1

Is there any particular reason why you need exactly FFmpeg? I guess it could be possible to get prebuilt binaries, but since it is a C library, you would also need a JNI wrapper code - I don't think anyone would generate that for the whole library since it's quite large, so even with a prebuilt library you still need to have some JNI knowledge to wire through the communication between Java and FFmpeg in C. Just for the purpose of demonstration - here is an example.

Apart from that if there is not a special reason to use FFmpeg, why can't you stick with MediaCodec that is a part of the Android API? It wraps the native StageFright library and could provide hardware support on devices where it is available, while FFmpeg would be a CPU only solution. Of course, if some unpopular codecs or muxers that are not available in MediaCodec are needed, then FFmpeg is the way.

Community
  • 1
  • 1
Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
  • MediaCodec is API 16, the Muxer is 18. I need API 8/9, maybe I can stretch it to 14. – Lik Sif Oct 01 '14 at 13:45
  • I tried looking at StageFright / OMX, couldn't figure out how to work with it. As for "wrapping" FFmpeg, even just something that will have it precompiled and the wrapped with a method that allows sending the FFmpeg command as one long String can be good enough. – Lik Sif Oct 01 '14 at 13:48
  • Ok, if you need an API level where MediaCodec is not available the I guess FFmpeg is the best way. Well I don't think you'll be able to find prebuild binaries, since that kind of violates the licenses in some cases (if the binary includes proprietary codecs etc.). Most of the scripts hosted (e.g. https://github.com/luhuiguo/ffmpeg-andriod, https://github.com/liquidware/ffmpeg-android) are either old or include only the non proprietary stuff. Can you tell what codecs do you need? Since for a lot of them you'll actually have to complile the codec libraries for arm too. – Rudolfs Bundulis Oct 01 '14 at 14:28
0

You can use Xuggler for encoding and decoding audio and video. Their wesite says "Xuggler extensively uses FFmpeg to compress and uncompress media".

Ashwani
  • 1,938
  • 11
  • 15
  • Xuggler does not seem to offer an Android version on their site. Also, ["Xuggler is on hiatus as no one is actively developing it anymore"](http://www.xuggle.com/xuggler/status). – CommonsWare Oct 01 '14 at 11:54
0

You could use precompiled libs from the JavaCPP Presets along with FFmpegFrameRecorder from JavaCV to compress images as well as audio samples, as shown in the RecordActivity sample, for example.

Samuel Audet
  • 4,964
  • 1
  • 26
  • 33