3

I'm developing an Android application, this application load video file from android gallery that saved on SD Card.
I need to know how can I add overlays to this video
I need to add title and image on this video like brand images

I can not find an example or tutorial describe how to do this operation

Do I have to use decoding to add overlays? , And if yes how can I do that.

Any example about this...

Adel
  • 648
  • 1
  • 9
  • 26
  • Did you try this? http://developer.android.com/guide/topics/graphics/2d-graphics.html Edit: changed the link – Chintan Trivedi Sep 02 '13 at 16:48
  • This will add subview on top of video, i need to alter the video , i mean that i need to add overlays to video and save it with new video files that contains the overlays – Adel Sep 02 '13 at 16:57

2 Answers2

3

Provided you're playing the video using a VideoView or similar, you can overlay any View (e.g. TextView, ImageView) using a RelativeLayout. For example, to show a text on the top right corner of the video:

<RelativeLayout
    android:id="@+id/playerLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

        <VideoView
            android:id="@+id/videoPlayer"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/videoText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_margin="3dp"
            android:text="@string/player_text" />

</RelativeLayout>
rbarriuso
  • 787
  • 8
  • 30
  • actually this can overlay video on android activity, what i need is to open video and put an image inside the video frame and save it to new video file which if you move this new video to you PC and play it you can see the image that i added to the video in my app. (it like the videos in youtube , some channels add their logo to the video).. got me ? – Adel Sep 02 '13 at 18:17
  • Ok, that's indeed a totally different use case. Then I think you'll need to decode the video, insert the image logo in every frame and re-encode the video to a file in the SD card. I'm not sure if Android provides a native API for that, sorry. – rbarriuso Sep 02 '13 at 19:45
  • exactlly thats what i need , decode ... insert image ...etc, but i do not have an idea how to do that .. so do you have ? – Adel Sep 03 '13 at 09:08
  • I guess one solution would be building your own [ffmpeg for Android](https://github.com/guardianproject/android-ffmpeg), use the [NDK](http://developer.android.com/tools/sdk/ndk/index.html) to integrate it in your app and use it to overlay the logo image. Maybe [this example about how to use ffmpeg to watermark a video](http://www.idude.net/index.php/how-to-watermark-a-video-using-ffmpeg/) can help you. – rbarriuso Sep 04 '13 at 21:52
  • Actually you can already check if the ffmpeg solution suits your needs. I found a couple of apps in Google Play you can give a try: https://play.google.com/store/apps/details?id=com.silentlexx.ffmpeggui and https://play.google.com/store/apps/details?id=roman10.media.converter – rbarriuso Sep 04 '13 at 21:57
  • any luck on this?? – Akash Dubey Aug 11 '17 at 13:38
2

As @rbarriuso said, ffmpeg4Android is able to meet your requirement. There is also a guide to install both library and demo in both Android Studio and Eclipse. Following, there are also the watermark command which may satisfy you.

Hope it can help

Luong Truong
  • 1,953
  • 2
  • 27
  • 46