Add overlays to video on Android [closed]

2019-04-02 03:44发布

问题:

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...

回答1:

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>


回答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