Thanks to xue-fei for identifying the original authors of the CPP code. Please refer to MediaPlayback for a more suitable solution.
This repository is not being actively maintained. Issues may not be addressed.
Alternative to Unity's VideoPlayer component. Run HEVC/H265 videos with GPU decoding, lower loading times and better performance.
The GPUVideoPlayer class derives from MonoBehaviour and needs to be on the scene. GPUVideoPlayer component also provides some primitive auto play features.
Load(string) : void
Where the passed parameter is the URL or path of the videoPlay() : bool
Which plays (or resumes) the video playback and returns a boolean based on whether the command was successfulPause() : bool
Pauses the video and returns if the command was successfulStop() : bool
Stops the video playback and returns if the command was successfulGetPlaybackRate() : double
Returns the rate at which the video is being playedGetDuration() : long
Returns the length of the video in 1/10^7 secondsSeekByRatio(float ratio) : bool
Sets the position of the video player atratiocompletion stage and returns if the attempt was successfulSeekByTime(long position) : bool
Sets the position of the video player atpositiontime.positionis in1/10^7second units
MediaTexture
Returns theTexture2Dobject that is updated by the plugin with video framesMediaDescription
Returns some information of the video being played. These include the video width, height, duration and whether it can be seeked on.
The states of a GPUVideoPlayer instance is represented using an enum called `GPUVideoPlayer.State' and has the following values:
- Idle
- Loaded
- Failed
- Playing
- Paused
- Stopped
- Ended
The current state can be obtained using GPUVideoPlayer.MediaState which derives from UnityEvent<GPUVideoPlayer.State>
GPUVideoPlayerwas tested with an 800mb8192x409630FPS H265 MP4 video file. Loading took 195 ms. Video playback was at 30FPS with Unity's framerate at 60.
- A simple video player app with load, pause, stop, 5sec FWD, 5sec BWD is available inside the Demo folder. The demo should be a good example to see how to get started.
- Currently runs only on Microsoft Windows. Tested on 64 bit OS.
- May require HEVC Video Extensions based on your usage.