How can I add overlay images or text on top of videos in Android?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 09:48:11

问题


I'm trying to add overlay images/text on top of mp4 videos inside an Android application. Most solutions point to FFmpeg (or appunits AndroidFFmpeg) but isn't stable and very complicated to maintain. Is there a native way to do this using the Android SDK? (MediaCodec? MediaMuxer?)

Thank you, Ori


回答1:


There are two ways to understand your question:

  1. You want to temporarily superimpose video with additional information. This can be done using the standard layout procedure:

Use the built-in VideoView. You might need to wrap the textView /imageView in an additional layout to push it to the front:

 <VideoView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/videoView"
    android:background="#00000000"/>
 <LinearLayout
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="bottom|center_horizontal"
     android:orientation="horizontal">
     <TextView
         android:id="@+id/txt"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="Text"/>
 </LinearLayout>
  1. You want to add the additional information to the video itself. This is obviously much more difficult. You could use OpenCV for this. For information on OpenCV+Android visit their website.

Update: As pointed out in this answer, the ExtractMpegFramesTest might be interesting for you



来源:https://stackoverflow.com/questions/29914448/how-can-i-add-overlay-images-or-text-on-top-of-videos-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!