Video with transparency on Android

时光毁灭记忆、已成空白 提交于 2019-12-04 02:50:20

问题


Is there any way to have Android play video with transparent areas? When I try to play a WebM video containing transparent areas in VideoView, the background of the view remains black. Instead of black I'd expect to see the background of the parent view shown through on the transparent areas.

The only working solution I've found so far is to create a drawable animation out of the video frames, which isn't very memory efficient.


回答1:


I know it's a bit late, but perhaps it can help nevertheless.

The best way I can think of for achieving this is using OpenGL ES - you render the video through a surface, and write a small shader that removes the color areas you want removed. You can find several examples for this technique on the web, perhaps this link can provide some kickstart: First steps in creating a chroma key effect using android camera




回答2:


I think this will overcome your problem Try this https://github.com/pavelsemak/alpha-movie

Here is the demo example,

<RelativeLayout
                android:id="@+id/mainContent"
                android:layout_width="match_parent"
                android:layout_height="200dp">

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:src="@drawable/bg1" />

                <com.alphamovie.lib.AlphaMovieView
                    android:id="@+id/alpha_video_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_centerInParent="true"
                    app:accuracy="0.7"
                    app:alphaColor="#000000"/>

            </RelativeLayout>


来源:https://stackoverflow.com/questions/27319821/video-with-transparency-on-android

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