I am trying to build the FFmpeg library to use in my android app with the NDK. The reason for this is because I am using the native video capture feature in android because I really don't want to write my own video recorder. However, the native video capture only allows for either high-quality encoding, or low quality encoding. I want something in between, and I believe that the solution is to use the FFmpeg library to re-encode the high quality video to be lighter.
So far I have been able to build the FFmpeg library according to this guide: http://www.roman10.net/how-to-build-ffmpeg-for-android/ and which a few tweaks I have been able to get it to work.
However, everything that I've found seems to be about writing your own encoder, which seems like overkill to me. All that I really want to do is send a string in command line format to the main() function of FFmpeg and re-encode my video. However, I can't seem to figure out how I build FFmpeg to give me access to the main method. I found this post: Compile ffmpeg.c and call its main() via JNI which links to a project doing what I want more of less, but for the life of me I cannot figure out what is going on. It also seems like he is compiling more than I want, and I would really like to keep my application as light weight as possible.
Some additional direction would be extremely helpful. Thank you.
In Android NDK there is no main() in your application in the typical sense, so you are unable to do what you want to directly. However, you can still call the main() of FFmpeg yourself and provide all necessary parameters to it. Here are 2 possibilities to get the parameters:
Android Activity receives an Intent after creation. You can pass the parameters through the intent while starting your activity and then extract it like this:
Intent CommandLine = this.getIntent();
Uri uri = CommandLine.getData();
You can read parameters from file you create somewhere on a SD-card and pass the to FFmpeg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With