libgdx/gdx-video
libgdx/gdx-video has 155 GitHub stars and 57 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-19 14:57 UTC. Last push 2026-10-10.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
A libGDX cross platform video rendering extension
창작 및 미디어README.md
OriginalGDX-Video
A libGDX cross-platform video rendering extension
Contents
Getting Started
Gdx-video is currently available in maven with official builds and snapshot builds. You can find them at the following repositories:
Repositories
- Official For official releases, use https://oss.sonatype.org/content/repositories/releases
- Snapshots For snapshot builds, use https://oss.sonatype.org/content/repositories/snapshots
Gradle dependency declarations
Core:
implementation "com.badlogicgames.gdx-video:gdx-video:$gdxVideoVersion"
Desktop:
implementation "com.badlogicgames.gdx-video:gdx-video-lwjgl3:$gdxVideoVersion"
// or (when using legacy LWJGL2):
implementation "com.badlogicgames.gdx-video:gdx-video-lwjgl:$gdxVideoVersion"
Android:
implementation "com.badlogicgames.gdx-video:gdx-video-android:$gdxVideoVersion"
iOS (with RoboVM):
implementation "com.badlogicgames.gdx-video:gdx-video-robovm:$gdxVideoVersion"
Html:
implementation "com.badlogicgames.gdx-video:gdx-video:$gdxVideoVersion:sources"
implementation "com.badlogicgames.gdx-video:gdx-video-gwt:$gdxVideoVersion"
implementation "com.badlogicgames.gdx-video:gdx-video-gwt:$gdxVideoVersion:sources"
You also need to add the following file to your GdxDefinition.gwt.xml in your html project:
<inherits name="com.badlogic.gdx.video.gdx_video_gwt" />
Teavm:
implementation "com.badlogicgames.gdx-video:gdx-video-teavm:$gdxVideoVersion"
Playing video
First, get a video player for the current platform using
VideoPlayer player = VideoPlayerCreator.createVideoPlayer();
Then, load a video from your game's assets.
FileHandle file = Gdx.files.internal("video.webm");
player.load(file);
Then you can play the video:
player.play();
Once the video has fully loaded, you may retrieve additional information about the file.
if (player.isBuffered()) {
int videoWidth = player.getVideoWidth();
int videoHeight = player.getVideoHeight();
}
On each frame, call the update() function to acquire new video frames
and keep the decoder running. You may then retrieve the frame using getTexture(),
but note that the texture may be larger than the video itself. The provided
VideoActor takes care of both updating and drawing when using Scene2D.
Once you are done playing, remember to dispose() the video player.
Encoding recommendations
Depending on the devices your game targets, you may need to encode your videos with multiple formats and resolutions.
See the following tables for a rough overview, but remember to test your game on real devices.
File format and codec
| Format | Desktop | Android | iOS | Web |
|---|---|---|---|---|
| MP4 (H.264/AVC + AAC) | ❌ * | ✅ | ✅ | ⚠️ |
| MP4 (H.265/HEVC + AAC) | ❌ * | ⚠️ > 5.0 | ✅ > 11 | ⚠️ |
| WebM (VP8 + Vorbis) | ✅ | ✅ | ❌ | ✅ |
| WebM (VP9 + Opus) | ✅ | ⚠️ > 5.0 | ❌ | ❔ |
| MKV (AV1 + Opus) | ✅ | ⚠️ > 10 | ❌ * | ⚠️ |
Additional notes
Desktop: Additional formats and codecs can be enabled when compiling gdx-video yourself. See the file gdx-video-desktop/FFmpeg/build.gradle.
iOS: H.265 is supported since iOS 11. AV1 requires a current high-end device with a hardware decoder.
Android: See the following webpage for officially supported media formats: https://developer.android.com/guide/topics/media/platform/supported-formats. Note that this support table is not always accurate, especially for devices and emulator images without Google Play Services.
In practice, H.264 is a good choice for physical Android tablets / smartphones as most devices (including old and cheap ones) have hardware decoding support. Remember to dispose a VideoPlayer before loading a new one, as some devices fail to load the next video otherwise.
Resolution and framerate
Even when the format is officially supported, not all devices have hardware acceleration for video decoding. Many video codecs specify the decoding capabilities as "levels" of bitrate, video resolution and framerate. Trying to play a video above the device's capabilities may cause increased power usage, frame drops, visual or audio artifacts or even game crashes.
Examples (using H.264 levels):
| Level | (Mobile) device category | Example 1 | Example 2 |
|---|---|---|---|
| 3 | Low end | 720 x 480 @ 30fps | - |
| 3.1 | 720 x 480 @ 60fps | 1280 x 720 @ 30fps | |
| 4 | Budget / mid range | 1280 x 720 @ 60fps | 1920 x 1080 @ 30fps |
| 4.2 | 1280 x 720 @ 120fps | 1920 x 1080 @ 60fps | |
| 5.1 | High performance | 1920 x 1080 @ 120fps | 3840 x 2160 @ 30fps |
Possible approaches:
- Use a lower resolution as 'baseline' that works on all target devices
- Ship your videos in multiple resolutions and guess the best one for the device (e.g. based on OS version, RAM size or display resolution)
Contributing
Building from source
To build from source, clone or download this repository, then open it in Android Studio and perform a gradle sync. If you get any ZipFile errors, watch the logs above and install the remaining Android SDK components through the SDK manager.
When building for desktop, build the native components using the Gradle tasks
:gdx-video-desktop:buildFFmpeg{platform}{arch}
and :gdx-video-desktop:jnigenBuild{platform}{arch}.
Perform the following command to compile and upload the library in your local repository:
./gradlew publishToMavenLocal
See build.gradle file for current version to use in your dependencies.
Cross-compilation on MacOS
Install the cross-compilers using homebrew with the commands
brew install mingw-w64 nasm
brew tap messense/macos-cross-toolchains
brew install i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-linux-gnu arm-unknown-linux-gnueabihf aarch64-unknown-linux-gnu
Licensing
The project is licensed under the Apache 2 License, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. We love to get (non-mandatory) credit in case you release a game or app using this project!