Mobile App Development: Working With Media Files on Android (Part 1)

Within this page, we will present a series of post that we hope will help any Android mobile developer out there to achieve the task of working with media type files, mainly video files.

Media files android

As we know it, Android development offers a rich ecosystem of tools and hardware to develop our desired mobile application. From the simplest task as showing information from a set of web services through a more complex application for user sensing, media streaming and game development; Android has all wrapped up.

However one of the biggest drawbacks of Android (of the fewer of course) that we, Android developers, have to endure is the option to natively edit and create video media files, or as I called it “video editing”. Where, unlike our counterpart iOS, this task can be easily performed with a set of native commands. Nevertheless, there are a few options over to settle this issue, with its own pros and cons. In this post we’ll present two options to achieve video editing on android.

 

FFMPEG

Difficulty: hard to implement, easy to use.

Pros: Can read/write almost any kind of media file.

Cons: Must use Android NDK in order to build and use source code.

License: LGPL/GPL (Depends of the libraries used)

Source: http://ffmpeg.org/

The second option, and the preferred by the community (and myself) is an open source project called FFMPEG. In a condensed matter, FFMPEG offers a way to decode, encode, transcode, mux, demux, stream, filter and play. Pretty much any kind of multimedia file. This framework is powered by the libavcodec, libavutil, libavformat, libavfilter, libavdevice, libswscale and libswresample libraries, so it’s a powerful option if we are working with media files.

Nevertheless, this framework is implemented in C++, so here comes the main disadvantage; we must compile the source code and then find a way to communicate with the binaries from our java source code. Luckily we already have a way to do this, Java Native Interface or JNI already implemented on Android through the Native Development Kit or NDK, so an extra effort must be done in order to make it work in our Android project. But do not despair, because there are good open source project over there that helps us with this exhausting task.

If your desired task is to merge, trim, encode/decode, change the video ratio, change video orientation, add watermark text or compress video files regardless the media type use this framework.

When to used it: if you have a set of videos recorded from an android device, and you want to merge it and then upload it to the cloud, compressing the file while keeping a good tradeoff between audio/video quality and file size, making sure that this video can be reproduce in other devices, say as an iPhone, then ffmpeg is your best shot.

Final Thoughts

So let’s get started with this set of guides of how to work with media files on Android. See you on our next post for part 2, where we are going to give an example android application for video merging and trimming using mp4parse.

 

This article was developed by the Mobile Team at iTexico and written by the Marketing Team.

Oscar Salas

Written by Oscar Salas

Oscar Salas is a B2B Digital Marketing Specialist with 5 years of experience, who has helped organizations to grow and expand through strategic brand development and marketing programs. Analytical thinker, cat lover, he enjoys to play the piano and listening to Led Zeppelin He's currently leading the iTexico Demand Gen strategies.

Explore iTexico, The Nearshore + Company 

Explore The Nearshore Services

Read More

Mobile Competency Centers

Recent Posts