We're working on an Android App that requires resizing (frame size) and compressing videos. We tested the code sample below and it's currently slow: https://github.com/hoolrory/AndroidVideoSamples/blob/master/CommonVideoLibrary/src/com/roryhool/commonvideolibrary/VideoResampler.java
The output video frame size is reduced (e.g., 480x320), and the bit-rate is also reduced to achieve compression. The final video looks very good and the compression ratios are good, too. It's just that the process is slow. I tested on a Galaxy S4 running Android 4.4 and Galaxy Note 5 running Android 6.0. The later is faster, but not by much. On Galaxy S4, a 30-second video takes about a minute to compress (on average).
The code above decods the input video on an input surface, reduces frame size, and outputs to an output surface. MediaMuxer is used to mux-in the audio. The example is using an MPEG container and H264 encoder. Some relevant questions:
- Are there some parameters we can use to speed up the compression?
- How is the video compression speed affected by the target bit rate and frame size, if any?
- We didn't use FFMpeg. Is that faster?
Any pointers or hints, even if not related to the code sample above, would be highly appreciated.
Thank you very much!
Omar