Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put Image above Video and save video in android [closed]

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.

like image 849
Viktor Apoyan Avatar asked Apr 29 '15 14:04

Viktor Apoyan


2 Answers

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.

like image 135
King of Masses Avatar answered Nov 05 '22 07:11

King of Masses


Assuming you mean placing it just as a view overlay, it can be easily done in your layout XML.

You can place one view over another using FrameLayout or RelativeLayout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

  <VideoView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" />

  <TextView
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="20dip"
    android:layout_gravity="center_horizontal|bottom"

    android:padding="12dip"

    android:background="#AA000000"
    android:textColor="#ffffffff"

    android:text="My customised view" />
</FrameLayout>
like image 1
Ed George Avatar answered Nov 05 '22 07:11

Ed George