2

I am building an android app which does some video processing.

I am currently using precompiled FFmpeg from https://github.com/writingminds/ffmpeg-android. The other option is to download FFmpeg source code and compile it using Android NDK. The reason I am contemplating option 2 is to enhance performance. My questions are

  1. Is there a difference between the two options mentioned above?

  2. If yes, what would be the difference. Would it be enhanced performance (or) the result would simply be the same (or) are there some other benefits or drawbacks?

  3. When they state precompiled FFmpeg, does it mean it was compiled using Android NDK for a specific architecture?

Please let me know.

Thank you in advance!!!

App Developer
  • 165
  • 1
  • 1
  • 14
  • Unless you are actually doing something to the build process (e.g. compiler switches) or changing the source.. then it's going to be the same? Just because you compile it yourself isn't going to enhance the performance. Or is it something else you mean to ask? – D-Dᴙum Jun 19 '17 at 17:49
  • Thank you! Wanted to know if it would enhance the performance or not and also, would it be advisable to use a pre-compiled version in production grade app or use a own compiled version? Can anything go wrong? – App Developer Jun 19 '17 at 17:52
  • re: performant ffmpeg/android ... you might want to familiarize on hardware integration in stagefright lib https://vec.io/posts/use-android-hardware-decoder-with-omxcodec-in-ndk https://vec.io/posts/use-android-hardware-decoder-with-omxcodec-in-ndk if something has not changed , ffmpeg is just gonna be slow on mobile – Robert Rowntree Jun 19 '17 at 18:20
  • Thank you so much, will familiarize myself with stagefright. – App Developer Jun 19 '17 at 18:57

2 Answers2

4

There can be a big difference in performance

The main issue is that the binary you linked to uses --disable-asm in the x264 configuration. This option disables platform-specific assembly optimizations and results in a significant decrease in H.264 encoding speed (when encoding via libx264 in ffmpeg). I'm unsure why this option is used by the binary provider.

When using ffmpeg refer to the console output. If it shows [libx264] using cpu capabilities: none! then your encoding speed is not optimal and will be unecessarily slower. For reference, Android users should typically see something like NEON ARMv7 or similar instead of none.

Avoid this misconfigured binary. Properly compiling it yourself will allow you to take advantage of ASM optimizations, and therefore encode faster.

llogan
  • 121,796
  • 28
  • 232
  • 243
  • Thank you for the response! Yes the performance is slow. Will try compiling it myself and test it. Do you know any other binary which does not use the --disable-asm in the x264 configuration I could use? – App Developer Jun 19 '17 at 20:36
  • @AppDeveloper I don't know of any for Android users. – llogan Jun 19 '17 at 20:42
0

ffmpeg can be built with very different options. Some components may be disabled, and this may reduce the size of the binaries significantly. The prebuilt binaries in https://github.com/writingminds include the GPL components, e.g. x264 encoder. This means that you may have legal problems using it in your app, unless it is opensource. Note that I am not a loyer, so don't hesitate to consult with a professional.

Another issue to consider when in doubt about using prebuilt binaries, is that this is a monolithic binary. If you need some specific functionality from ffmpeg, it may build a custom library based on ffmpeg libraries (libavcodec, libavformat, etc). This advantage is negligible if you use ffmpeg to convert long video files, but if you must work on many small chunks of data, the overhead may be significant. You can find prebuilt libraries for Android, too.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Thank you! 1. will building with lesser components enhance the execution speed though say for eg overlaying a image filter on a video? 2) did you mean prebuilt libraries in Android for video processing? If yes, can you suggest some? – App Developer Jun 19 '17 at 19:00
  • The rule of thumb is: if you can perform your task smoothly on Linux command line, you will be OK with monolithic binary on Android. If your task involves complex scripting, or writing C executable - then on Android you should also work with libraries, and avoid spawning a separate process. – Alex Cohn Jun 19 '17 at 19:30
  • What kind of video processing do you need? OpenCV? – Alex Cohn Jun 19 '17 at 19:32
  • Laying an image filter on a video – App Developer Jun 19 '17 at 19:47