Put Image above Video and save video in android

Viktor Apoyan picture Viktor Apoyan · Apr 29, 2015 · Viewed 8k times · Source

I'm writing application which must put image above the video and save video.

In general application opens video file, after that user select image with transparent background and put that image above the video, after user press save button he get new video but already with image above the video.

Can you please provide me information or hints how to do that.

Answer

King of Masses picture King of Masses · Apr 29, 2015

So as per your question, your looking for a video editor kind of solution to achieve the task..

I think this your scenario:

** You have a video in your application

** Open a bitmap resource (image file from some where)

** Overlay this bitmap at the bottom of the movie (video) on all frames in the background

** Save the video on external storage

For this ffmpeg does support overlaying functionality or Android MediaCodec stuff. FFMPEG has various filters one of them is overlay filter. What I understand is you want to overlay an image (i.e. png) on the video, ffmpeg surely is a useful framework to do this job. You can set the output format you can set the co-ordinates of the image which is to be overplayed.

E.g:

ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi

Above command adds overlays logo.png on the input.avi video file in bottom left corner.

More information about the filters is available at following website,

https://www.ffmpeg.org/ffmpeg-filters.html#overlay-1

Here is the GitHub links

FFmpeg Android Java

Android Java wrapper around ffmpeg command line binary or this

If this is a solution to your problem you need the C code equivalent to the above command. You also need to see the performance of the ffmpeg because it a pure software framework.

Hope I have understood your question correctly and this helps.