0

I am facing a difficult headache where I need to optimize the performance of a outsourced piece of code. In this outsourced application I need to cut, trim, scale and crop video.

I see they were using some kind of FFMPEG Library (without NDK), but the performance was very terrible. It takes the app 30 seconds to

-vf crop=480:480:0:80 -preset ultrafast -threads 5 -vcodec libx264 -acodec copy

a 15 seconds 640x480 videos. I need it to crop in 2 or 3 seconds, just like how Instagram did with their videos.

Any suggestion, tutorial or general approach to this? Should I continue to optimize the FFMPEG parameters, should I compile FFMPEG using NDK and use other FFMPEG Wrapper, or should I use TextureView? I also need to apply filter like -vf curves, so maybe TextureView is not the right approach.

DeanK
  • 344
  • 2
  • 14
  • You may be asking the impossible ( 10 to 1 performance improvement from a battery constrained and relatively slow platform ). Read up on 'ffmpeg' and 'hardware acceleration' in Stagefright libs. without HW integration of ffmpeg ( all software ) this is unlikely to be possible. – Robert Rowntree Nov 12 '14 at 16:40
  • It's possible to do this with the hardware video codecs and GPU on Android 4.3+, though I don't think any of it was exposed in the NDK until recently. However, since you're not doing heavy computation, there's no need for native code. You can find a simple example in http://bigflake.com/mediacodec/#DecodeEditEncodeTest, but be warned that MediaCodec is complicated and marginally documented. – fadden Nov 12 '14 at 16:46
  • @RoberRowntre if it is indeed impossible, then how can Instagram do it in 20 second, including the uploading and filtering? – DeanK Nov 13 '14 at 11:47

3 Answers3

1

Intel INDE includes a product called Media for Mobile which provides easy to use apis for all kinds of video editing operations.It is included in the free version of the product. Check it out here https://software.intel.com/en-us/intel-inde/try-buy. Download the starter edition

G3M
  • 1,023
  • 8
  • 19
0

I'd recommend you using ffmpeg with NDK. Try to follow one of these instructions (personally I use one described by roman10). After compiling ffmpeg correctly you'll be able to invoke any command by writing a c code. Here is documentation and tutorial that might help.

grzebyk
  • 1,024
  • 1
  • 15
  • 26
  • Thank you very much for reply. I've successfully compiled ffmpeg for ndk, but then I have no idea how to crop the video without command line. Is there supposed to be some method in those libraries to do this? – DeanK Nov 12 '14 at 15:36
  • You can use command line syntax with this setup. Take a look at [this post](http://stackoverflow.com/questions/12446955/how-to-run-ffmpeg-from-command-line-in-android) – grzebyk Nov 12 '14 at 16:35
0

So after some deep research, I realized that it is impossible to do the crop. Instagram did not doing it quick, they just hide it and display it when it's ready. So, it takes approximately 30-40 seconds to crop and filter video. Thank you for all the reply. Cheers.

DeanK
  • 344
  • 2
  • 14