Skip to content

Conversation

@Sahil-pixel
Copy link

Description

This PR adds a new Android Video provider for Kivy using MediaPlayer and OpenGL textures.
It allows video playback on Android without relying on ffpyplayer or gstreamer, using the native Android APIs.

Changes

  • Added VideoAndroid provider.
  • Implemented OpenGL texture binding from MediaPlayer.
  • Added rotation handling.
  • Integrated with Kivy core video system.

Notes

  • This is a first implementation, so further feedback from maintainers is expected.
  • Unit tests and docs will need input from maintainers for style and coverage.

@welcome
Copy link

welcome bot commented Aug 26, 2025

Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines.

@einfall
Copy link

einfall commented Sep 4, 2025

Is it possible to play a 1080p or 4K video in fullscreen without stuttering (like the current playback) ?

@Sahil-pixel
Copy link
Author

I think yes. As it is based on java MediaPlayer highly optimised for Android .

@kuzeyron
Copy link
Contributor

This PR is missing documentation for at least https://kivy.org/doc/stable/guide/environment.html
Might be more places to add.

@kuzeyron
Copy link
Contributor

kuzeyron commented Sep 10, 2025

With the use of kivy.uix.video.Video all I'm getting is a white background and here is the output:

09-10 12:01:01.301 16516 16548 I python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 28)
09-10 12:01:01.301 16516 16548 I python  : [WARNING] [Config      ] Upgrading configuration in progress.
09-10 12:01:01.301 16516 16548 I python  : [DEBUG  ] [Config      ] Upgrading from 0 to 1
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/org.kuzeyron.testing/files/app/.kivy/logs/kivy_25-09-10_0.txt
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Kivy        ] v3.0.0.dev0
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/org.kuzeyron.testing/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Python      ] v3.11.5 (main, Sep 10 2025, 11:33:15) [Clang 19.0.1 (https://android.googlesource.com/toolchain/llvm-project 97a699bf4
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Python      ] Interpreter at ""
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Logger      ] Purge log fired. Processing...
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Logger      ] Purge finished!
09-10 12:01:01.697 16516 16548 I python  : [INFO   ] [Factory     ] 195 symbols loaded
09-10 12:01:01.827 16516 16548 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl3, img_pil (img_ffpyplayer ignored)
09-10 12:01:01.899 16516 16548 I python  : [INFO   ] [VideoAndroid] Using Android MediaPlayer
09-10 12:01:01.899 16516 16548 I python  : [INFO   ] [Video       ] Provider: android(['video_ffmpeg', 'video_ffpyplayer'] ignored)
09-10 12:01:01.917 16516 16548 I python  : [INFO   ] [Window      ] Provider: sdl3
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] Backend used <sdl3>
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.2 v1.r32p1-01eac0.a031c769622e85782e9b68c066a81213'>
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] OpenGL vendor <b'ARM'>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] OpenGL renderer <b'Mali-G610 MC3'>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] Texture max size <16383>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] Texture max units <16>
09-10 12:01:01.956 16516 16548 I python  : [INFO   ] [Window      ] auto add sdl3 input provider
09-10 12:01:01.956 16516 16548 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
09-10 12:01:01.958 16516 16548 I python  : [DEBUG  ] Importing BlpImagePlugin
09-10 12:01:01.961 16516 16548 I python  : [DEBUG  ] Importing BmpImagePlugin
09-10 12:01:01.963 16516 16548 I python  : [DEBUG  ] Importing BufrStubImagePlugin
09-10 12:01:01.964 16516 16548 I python  : [DEBUG  ] Importing CurImagePlugin
09-10 12:01:01.964 16516 16548 I python  : [DEBUG  ] Importing DcxImagePlugin
09-10 12:01:01.965 16516 16548 I python  : [DEBUG  ] Importing DdsImagePlugin
09-10 12:01:01.970 16516 16548 I python  : [DEBUG  ] Importing EpsImagePlugin
09-10 12:01:01.971 16516 16548 I python  : [DEBUG  ] Importing FitsImagePlugin
09-10 12:01:01.972 16516 16548 I python  : [DEBUG  ] Importing FliImagePlugin
09-10 12:01:01.972 16516 16548 I python  : [DEBUG  ] Importing FpxImagePlugin
09-10 12:01:01.973 16516 16548 I python  : [DEBUG  ] [Image       ] failed to import FpxImagePlugin: No module named 'olefile'
09-10 12:01:01.973 16516 16548 I python  : [DEBUG  ] Importing FtexImagePlugin
09-10 12:01:01.974 16516 16548 I python  : [DEBUG  ] Importing GbrImagePlugin
09-10 12:01:01.974 16516 16548 I python  : [DEBUG  ] Importing GifImagePlugin
09-10 12:01:01.977 16516 16548 I python  : [DEBUG  ] Importing GribStubImagePlugin
09-10 12:01:01.977 16516 16548 I python  : [DEBUG  ] Importing Hdf5StubImagePlugin
09-10 12:01:01.978 16516 16548 I python  : [DEBUG  ] Importing IcnsImagePlugin
09-10 12:01:01.980 16516 16548 I python  : [DEBUG  ] Importing IcoImagePlugin
09-10 12:01:01.981 16516 16548 I python  : [DEBUG  ] Importing ImImagePlugin
09-10 12:01:01.981 16516 16548 I python  : [DEBUG  ] Importing ImtImagePlugin
09-10 12:01:01.982 16516 16548 I python  : [DEBUG  ] Importing IptcImagePlugin
09-10 12:01:01.982 16516 16548 I python  : [DEBUG  ] Importing JpegImagePlugin
09-10 12:01:01.983 16516 16548 I python  : [DEBUG  ] Importing Jpeg2KImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] Importing McIdasImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] Importing MicImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] [Image       ] failed to import MicImagePlugin: No module named 'olefile'
09-10 12:01:01.985 16516 16548 I python  : [DEBUG  ] Importing MpegImagePlugin
09-10 12:01:01.985 16516 16548 I python  : [DEBUG  ] Importing MpoImagePlugin
09-10 12:01:01.988 16516 16548 I python  : [DEBUG  ] Importing MspImagePlugin
09-10 12:01:01.989 16516 16548 I python  : [DEBUG  ] Importing PalmImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PcdImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PcxImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PdfImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PixarImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PngImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PpmImagePlugin
09-10 12:01:02.002 16516 16548 I python  : [DEBUG  ] Importing PsdImagePlugin
09-10 12:01:02.002 16516 16548 I python  : [DEBUG  ] Importing QoiImagePlugin
09-10 12:01:02.003 16516 16548 I python  : [DEBUG  ] Importing SgiImagePlugin
09-10 12:01:02.003 16516 16548 I python  : [DEBUG  ] Importing SpiderImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing SunImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing TgaImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing TiffImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing WebPImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing WmfImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing XbmImagePlugin
09-10 12:01:02.006 16516 16548 I python  : [DEBUG  ] Importing XpmImagePlugin
09-10 12:01:02.007 16516 16548 I python  : [DEBUG  ] Importing XVThumbImagePlugin
09-10 12:01:02.008 16516 16548 I python  : [ERROR  ] [Image       ] Error loading <test.mp4>
09-10 12:01:02.009 16516 16548 I python  : [WARNING] [Base        ] Unknown <android> provider
09-10 12:01:02.009 16516 16548 I python  : [INFO   ] [Base        ] Start application main loop
09-10 12:01:02.011 16516 16548 I python  : [INFO   ] [VideoAndroid] Unload
09-10 12:01:02.012 16516 16548 I python  : [INFO   ] [VideoAndroid] Unload
09-10 12:01:02.056 16516 16548 I python  : [INFO   ] [VideoAndroid] Rotation: 0
09-10 12:01:02.126 16516 16548 I python  : [INFO   ] [GL          ] NPOT texture support is available
09-10 12:01:02.148 16516 16548 I python  : [INFO   ] [WindowSDL   ] Window pixel size changed
09-10 12:01:02.148 16516 16548 I python  : [INFO   ] [WindowSDL   ] Window display scale changed

Also: ['main.pyc', 'sitecustomize.pyc', 'test.mp4', 'p4a_env_vars.txt', '.nomedia', 'private.version', '_python_bundle', 'libpybundle.version', '.kivy']

@Sahil-pixel
Copy link
Author

With the use of kivy.uix.video.Video all I'm getting is a white background and here is the output:

09-10 12:01:01.301 16516 16548 I python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 28)
09-10 12:01:01.301 16516 16548 I python  : [WARNING] [Config      ] Upgrading configuration in progress.
09-10 12:01:01.301 16516 16548 I python  : [DEBUG  ] [Config      ] Upgrading from 0 to 1
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/org.kuzeyron.testing/files/app/.kivy/logs/kivy_25-09-10_0.txt
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Kivy        ] v3.0.0.dev0
09-10 12:01:01.303 16516 16548 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/org.kuzeyron.testing/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Python      ] v3.11.5 (main, Sep 10 2025, 11:33:15) [Clang 19.0.1 (https://android.googlesource.com/toolchain/llvm-project 97a699bf4
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Python      ] Interpreter at ""
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Logger      ] Purge log fired. Processing...
09-10 12:01:01.304 16516 16548 I python  : [INFO   ] [Logger      ] Purge finished!
09-10 12:01:01.697 16516 16548 I python  : [INFO   ] [Factory     ] 195 symbols loaded
09-10 12:01:01.827 16516 16548 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl3, img_pil (img_ffpyplayer ignored)
09-10 12:01:01.899 16516 16548 I python  : [INFO   ] [VideoAndroid] Using Android MediaPlayer
09-10 12:01:01.899 16516 16548 I python  : [INFO   ] [Video       ] Provider: android(['video_ffmpeg', 'video_ffpyplayer'] ignored)
09-10 12:01:01.917 16516 16548 I python  : [INFO   ] [Window      ] Provider: sdl3
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] Backend used <sdl3>
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.2 v1.r32p1-01eac0.a031c769622e85782e9b68c066a81213'>
09-10 12:01:01.938 16516 16548 I python  : [INFO   ] [GL          ] OpenGL vendor <b'ARM'>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] OpenGL renderer <b'Mali-G610 MC3'>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] Texture max size <16383>
09-10 12:01:01.939 16516 16548 I python  : [INFO   ] [GL          ] Texture max units <16>
09-10 12:01:01.956 16516 16548 I python  : [INFO   ] [Window      ] auto add sdl3 input provider
09-10 12:01:01.956 16516 16548 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
09-10 12:01:01.958 16516 16548 I python  : [DEBUG  ] Importing BlpImagePlugin
09-10 12:01:01.961 16516 16548 I python  : [DEBUG  ] Importing BmpImagePlugin
09-10 12:01:01.963 16516 16548 I python  : [DEBUG  ] Importing BufrStubImagePlugin
09-10 12:01:01.964 16516 16548 I python  : [DEBUG  ] Importing CurImagePlugin
09-10 12:01:01.964 16516 16548 I python  : [DEBUG  ] Importing DcxImagePlugin
09-10 12:01:01.965 16516 16548 I python  : [DEBUG  ] Importing DdsImagePlugin
09-10 12:01:01.970 16516 16548 I python  : [DEBUG  ] Importing EpsImagePlugin
09-10 12:01:01.971 16516 16548 I python  : [DEBUG  ] Importing FitsImagePlugin
09-10 12:01:01.972 16516 16548 I python  : [DEBUG  ] Importing FliImagePlugin
09-10 12:01:01.972 16516 16548 I python  : [DEBUG  ] Importing FpxImagePlugin
09-10 12:01:01.973 16516 16548 I python  : [DEBUG  ] [Image       ] failed to import FpxImagePlugin: No module named 'olefile'
09-10 12:01:01.973 16516 16548 I python  : [DEBUG  ] Importing FtexImagePlugin
09-10 12:01:01.974 16516 16548 I python  : [DEBUG  ] Importing GbrImagePlugin
09-10 12:01:01.974 16516 16548 I python  : [DEBUG  ] Importing GifImagePlugin
09-10 12:01:01.977 16516 16548 I python  : [DEBUG  ] Importing GribStubImagePlugin
09-10 12:01:01.977 16516 16548 I python  : [DEBUG  ] Importing Hdf5StubImagePlugin
09-10 12:01:01.978 16516 16548 I python  : [DEBUG  ] Importing IcnsImagePlugin
09-10 12:01:01.980 16516 16548 I python  : [DEBUG  ] Importing IcoImagePlugin
09-10 12:01:01.981 16516 16548 I python  : [DEBUG  ] Importing ImImagePlugin
09-10 12:01:01.981 16516 16548 I python  : [DEBUG  ] Importing ImtImagePlugin
09-10 12:01:01.982 16516 16548 I python  : [DEBUG  ] Importing IptcImagePlugin
09-10 12:01:01.982 16516 16548 I python  : [DEBUG  ] Importing JpegImagePlugin
09-10 12:01:01.983 16516 16548 I python  : [DEBUG  ] Importing Jpeg2KImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] Importing McIdasImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] Importing MicImagePlugin
09-10 12:01:01.984 16516 16548 I python  : [DEBUG  ] [Image       ] failed to import MicImagePlugin: No module named 'olefile'
09-10 12:01:01.985 16516 16548 I python  : [DEBUG  ] Importing MpegImagePlugin
09-10 12:01:01.985 16516 16548 I python  : [DEBUG  ] Importing MpoImagePlugin
09-10 12:01:01.988 16516 16548 I python  : [DEBUG  ] Importing MspImagePlugin
09-10 12:01:01.989 16516 16548 I python  : [DEBUG  ] Importing PalmImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PcdImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PcxImagePlugin
09-10 12:01:01.990 16516 16548 I python  : [DEBUG  ] Importing PdfImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PixarImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PngImagePlugin
09-10 12:01:02.001 16516 16548 I python  : [DEBUG  ] Importing PpmImagePlugin
09-10 12:01:02.002 16516 16548 I python  : [DEBUG  ] Importing PsdImagePlugin
09-10 12:01:02.002 16516 16548 I python  : [DEBUG  ] Importing QoiImagePlugin
09-10 12:01:02.003 16516 16548 I python  : [DEBUG  ] Importing SgiImagePlugin
09-10 12:01:02.003 16516 16548 I python  : [DEBUG  ] Importing SpiderImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing SunImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing TgaImagePlugin
09-10 12:01:02.004 16516 16548 I python  : [DEBUG  ] Importing TiffImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing WebPImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing WmfImagePlugin
09-10 12:01:02.005 16516 16548 I python  : [DEBUG  ] Importing XbmImagePlugin
09-10 12:01:02.006 16516 16548 I python  : [DEBUG  ] Importing XpmImagePlugin
09-10 12:01:02.007 16516 16548 I python  : [DEBUG  ] Importing XVThumbImagePlugin
09-10 12:01:02.008 16516 16548 I python  : [ERROR  ] [Image       ] Error loading <test.mp4>
09-10 12:01:02.009 16516 16548 I python  : [WARNING] [Base        ] Unknown <android> provider
09-10 12:01:02.009 16516 16548 I python  : [INFO   ] [Base        ] Start application main loop
09-10 12:01:02.011 16516 16548 I python  : [INFO   ] [VideoAndroid] Unload
09-10 12:01:02.012 16516 16548 I python  : [INFO   ] [VideoAndroid] Unload
09-10 12:01:02.056 16516 16548 I python  : [INFO   ] [VideoAndroid] Rotation: 0
09-10 12:01:02.126 16516 16548 I python  : [INFO   ] [GL          ] NPOT texture support is available
09-10 12:01:02.148 16516 16548 I python  : [INFO   ] [WindowSDL   ] Window pixel size changed
09-10 12:01:02.148 16516 16548 I python  : [INFO   ] [WindowSDL   ] Window display scale changed

Also: ['main.pyc', 'sitecustomize.pyc', 'test.mp4', 'p4a_env_vars.txt', '.nomedia', 'private.version', '_python_bundle', 'libpybundle.version', '.kivy']

Could you please add corresponding code ? So i can test in my pc.

@kuzeyron
Copy link
Contributor

import os
os.environ['KIVY_VIDEO'] = 'android'
from kivy.app import App
from kivy.uix.video import Video


class MyApp(App):
    def build(self):
        print(os.listdir('.'))
        return Video(source='test.mp4')


MyApp().run()

@Sahil-pixel
Copy link
Author

Sahil-pixel commented Sep 15, 2025

import os
os.environ['KIVY_VIDEO'] = 'android'
from kivy.app import App
from kivy.uix.video import Video


class MyApp(App):
    def build(self):
        print(os.listdir('.'))
        return Video(source='test.mp4')


MyApp().run()
import os
os.environ['KIVY_VIDEO'] = 'android'
from kivy.app import App
from kivy.uix.video import Video


class MyApp(App):
    def build(self):
        print(os.listdir('.'))
        return Video(source='test.mp4',state='play')


MyApp().run()
Record_2025-09-15-18-42-15.mp4

@kuzeyron
Copy link
Contributor

[ERROR ] [Image ] Error loading <test.mp4> I made a human error and mistook Image for Video. They are not the same.

There are more places to add android to. Another one that I found: https://github.com/kivy/kivy/blob/master/kivy/__init__.py#L212

Perhaps scanning with grep -r "video" will give more places that needs to have it included.
Let me know when you have done it.

@einfall
Copy link

einfall commented Sep 30, 2025

any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants