All Projects → pavelsemak → Alpha Movie

pavelsemak / Alpha Movie

Licence: apache-2.0
Android video player with alpha channel (chroma key) support

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Alpha Movie

Chimee
a video player framework aims to bring wonderful experience on browser
Stars: ✭ 2,332 (+2120.95%)
Mutual labels:  video-player, videoplayer
Sbplayerclient
支持全格式的mac版视频播放器
Stars: ✭ 110 (+4.76%)
Mutual labels:  video-player, videoplayer
KingPlayer
🎬 一个专注于 Android 视频播放器的基础库,无缝切换内核。(IjkPlayer、ExoPlayer、VlcPlayer、MediaPlayer)
Stars: ✭ 35 (-66.67%)
Mutual labels:  video-player, videoplayer
Sjvideoplayer
iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer
Stars: ✭ 2,066 (+1867.62%)
Mutual labels:  video-player, videoplayer
Xgplayer
A HTML5 video player with a parser that saves traffic
Stars: ✭ 4,792 (+4463.81%)
Mutual labels:  video-player, videoplayer
Larkplayer
🚀 A lightweight & flexible web player :)
Stars: ✭ 82 (-21.9%)
Mutual labels:  video-player
Ngx Youtube Player
YouTube player app built with Angular 7
Stars: ✭ 92 (-12.38%)
Mutual labels:  video-player
Floating Player
Floating Player is a Google Chrome extension to watch videos while you browse the internet
Stars: ✭ 77 (-26.67%)
Mutual labels:  video-player
Nexplayer unity plugin
Stream videos in HLS & DASH with Widevine DRM using NexPlayer Video Streaming Player SDK for Unity on Android & iOS devices
Stars: ✭ 73 (-30.48%)
Mutual labels:  video-player
Neteasecloudmusic Mvvm
Jetpack MVVM最佳实践 - 重构仿网易云音乐安卓客户端
Stars: ✭ 103 (-1.9%)
Mutual labels:  video-player
Screen Recorder Ffmpeg Cpp
*Multimedia project* A screen recording application to capture your desktop and store in a video format. Click here to watch the demo
Stars: ✭ 98 (-6.67%)
Mutual labels:  video-player
Videolistplayer
Play video in ListView or RecyclerView
Stars: ✭ 1,308 (+1145.71%)
Mutual labels:  video-player
Gpuvideoplayer
Fast video playback on Unity using GPU Decoding
Stars: ✭ 82 (-21.9%)
Mutual labels:  video-player
Avideo
Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
Stars: ✭ 1,329 (+1165.71%)
Mutual labels:  video-player
Abmediaview
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Stars: ✭ 79 (-24.76%)
Mutual labels:  video-player
React Video Renderer
Build custom video players effortless
Stars: ✭ 100 (-4.76%)
Mutual labels:  video-player
Exoplayer Wrapper
📺 Android library, ExoPlayer wrapper (2017)
Stars: ✭ 77 (-26.67%)
Mutual labels:  video-player
Fastotv
Open source IPTV player
Stars: ✭ 90 (-14.29%)
Mutual labels:  video-player
Vps Comparison
A comparison between some VPS providers. It uses Ansible to perform a series of automated benchmark tests over the VPS servers that you specify. It allows the reproducibility of those tests by anyone that wanted to compare these results to their own. All the tests results are available in order to provide independence and transparency.
Stars: ✭ 1,357 (+1192.38%)
Mutual labels:  transparency
Ffpyplayer
A cython implementation of an ffmpeg based player.
Stars: ✭ 89 (-15.24%)
Mutual labels:  video-player

Alpha Movie

Alpha Movie is an Android video player library with alpha channel support.

Video Player uses OpenGL to render video and apply shader that makes alpha compositing possible. The player encapsulates MediaPlayer and has its base functionality. Video stream is displayed by TextureView.


Gradle Dependency

jCenter License

The easiest way to start using Alpha Movie is to add it as a Gradle Dependency. The Gradle dependency is available via jCenter. Please make sure that you have the jcenter repository included in the project's build.gradle file (jCenter is the default Maven repository used by Android Studio):

repositories {
    jcenter()
}

Then add this dependency to your module's build.gradle file:

dependencies {
    // ... other dependencies
    compile 'com.alphamovie.library:alpha-movie:1.2.1'
}

Getting Started

Add AlphaMovieView into you activity layout:

<com.alphamovie.lib.AlphaMovieView
    android:id="@+id/video_player"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

Next you need to initialize the player. In your Activity class add:

public class MainActivity extends AppCompatActivity {

    private AlphaMovieView alphaMovieView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        alphaMovieView = (AlphaMovieView) findViewById(R.id.video_player);
        alphaMovieView.setVideoFromAssets("video.mp4");
    }

    @Override
    public void onResume() {
        super.onResume();
        alphaMovieView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        alphaMovieView.onPause();
    }
}

In this code snippet we load video from assets specifying filename video.mp4:

alphaMovieView.setVideoFromAssets("video.mp4");

Video can also be set by Url, FileDescriptor, MediaSource and other sources.

You need to add alphaMovieView.onPause() and alphaMovieView.onResume() in activity's onPause() and onResume() callbacks. Calling these methods will pause and resume OpenGL rendering thread.

Video playback can be paused and resumed using alphaMovieView.pause() and alphaMovieView.start() methods.


How it works?

Alpha Movie player uses OpenGL to render video with a shader attached to gl renderer. This shader modifies each pixel of video frame. By default it converts green color to transparent.

So default alpha channel color is green. This color can be changed to any rgb color by adding xml attribute alphaColor:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.alphamovie.lib.AlphaMovieView
        android:id="@+id/video_player"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        custom:alphaColor="#ff0000"
        custom:accuracy="0.7"/>
</FrameLayout>

In the code snippet above we set custom:alphaColor="#ff0000". It means that alpha channel color is set to red.

Also we specify accuracy attr to be 0.7. Accuracy is the value between 0 and 1. It should be lower if you wish more shades of specified color be transparent and vice versa. By default accuracy="0.95".

Custom shader

There is a possibility to apply your own custom shader. Add shader attr:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.alphamovie.lib.AlphaMovieView
        android:id="@+id/video_player"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        custom:shader="@string/shader_custom"/>
</FrameLayout>

And define your custom shader in string values, for example:

<resources>
    <!-- ... other string resources -->
    <string name="shader_custom">#extension GL_OES_EGL_image_external : require\n
            precision mediump float;
            varying vec2 vTextureCoord;
            uniform samplerExternalOES sTexture;
            varying mediump float text_alpha_out;
            void main() {
              vec4 color = texture2D(sTexture, vTextureCoord);
              if (color.g - color.r >= 0.1 &amp;&amp; color.g - color.b >= 0.1) {
                  gl_FragColor = vec4(color.r, (color.r + color.b) / 2.0, color.b, 1.0 - color.g);
              } else {
                  gl_FragColor = vec4(color.r, color.g, color.b, color.a);
              }
            }
    </string>
</resources>

In this case accuracy and alphaColor attrs are not affecting anything because they are used only when custom shader is not defined.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].