Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build and use ffmpeg within android

I am prototyping a fairly simple camera app to test out using MediaRecorder to create a custom camera activity with one snag, I want to set the aspect ratio of recorded videos to a 1x1. Through much research I have found that this is only possible by using a library like FFMPEG to crop each frame of the video to the size I desire.

I have read many tutorials and articles on different ways to build FFMPEG into Android, but most of them are either outdated and use older versions of both the Android NDK and FFMPEG, or more recent ones just do not work when followed. I tried following the popular http://www.roman10.net/how-to-build-ffmpeg-for-android/‎ and a few other similar ones that all lead to an error about a missing pkg-config file because FFMPEG is generally meant to be installed on linux or another OS apparently. I found some information about building FFMPEG in android by using a make-standalone-toolchain.sh file here http://software.intel.com/en-us/android/blogs/2013/12/06/building-ffmpeg-for-android-on-x86 and can't make heads or tails as to how to go about using this method.

This now leads into my question: What is the best/proven way currently to build and use FFMPEG within android applications? If the standalone toolchain method is the way to go, is there any material better than the one listed that is easier to follow? I would even be open to a reliable template application with the FFMPEG Libraries ready to go (if this is possible); although, I would much rather know how to build this into android for future use.

Thank you in advance for any advice or suggestions on this issue.

like image 906
don_vito Avatar asked Mar 06 '14 06:03

don_vito


People also ask

How do I combine two videos in android programmatically FFmpeg?

ffmpeg -f concat -i mylist.txt -c copy output.mp4 This process is a way of concatenating the files and not re-encoding. Hence, it should be done speedily & conveniently. If there is no error message, you are sure to receive a final merged video named by 'output. mp4' in the MP4 folder.

Why do we use FFmpeg?

It is widely used for format transcoding, basic editing (trimming and concatenation), video scaling, video post-production effects and standards compliance (SMPTE, ITU). FFmpeg also includes other tools: ffplay , a simple media player and ffprobe , a command-line tool to display media information.


2 Answers

I have successfully build ffmpeg libraries using

https://code.google.com/p/dolphin-player/

You have to be on Ubuntu to build that.

like image 75
Alexander Kulyakhtin Avatar answered Oct 20 '22 08:10

Alexander Kulyakhtin


This is the guide I liked the most: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

If you need more options, you can take a look at these, which are equally good:

  • https://github.com/guardianproject/android-ffmpeg
  • https://github.com/halfninja/android-ffmpeg-x264
  • https://vec.io/posts/how-to-build-ffmpeg-with-android-ndk

EDIT: I updated the first link with a more recent article (it uses NDK r9).

like image 26
Sebastiano Avatar answered Oct 20 '22 07:10

Sebastiano