This project leverages the powerful mpv library to play videos in a standalone application. It is built to be a drop-in replacement for the default GStreamer ofxVideoPlayer addon, but with more features and better performance.
The main reason for this project is that MPV can decode HAP files easily and efficiently on Raspberry Pi running a 64bit OS. While there are other openFrameworks libraries that can do this none of them support this platform and I (Pete Haughie, hello) was desperate to do this. The fact that it works on MacOS, Linux and Windows is entirely coincidental and down to the hard work that the MPV project has put into it.
This addon was developed on openFrameworks 0.12 but should work with older versions. As I only use the make build system I have not tried QT, Xcode or Visual Studio. You'll have to try it yourself. Feel free to make contributions to this addon.
- Single Dependency - mpv is a single dependency that does not require GStreamer or other dependencies
- Supports all video formats - mpv can play almost any format. It is also able to decode many formats that are not natively supported by the operating system, such as HAP.
- Supports multiple video sources - you can add multiple videos to the player at once.
- Playback speed control - you can adjust the playback speed of a video by changing its rate property including reverse.
- Seeking - you can seek to any point in a video. You can also set the current time of a video to a specific position, or jump forward/backward in time.
- GL Texture support - mpv supports GL textures for videos and images. You can send the texture data directly from mpv into your application without having to decode it first.
Refer to the official openFrameworks videoPlayer class documentation for full the documentation on the API. The MPV API documentation resides here.
The ofxMPVPLayer class is a wrapper around the mpv library. It can be used to play videos in your application.
object.load('video.mp4');
object.setLoopState(OF_LOOP_NORMAL|OF_LOOP_PINGPONG);
object.setup(width, height);
object.setPosition(seconds);
object.getDuration();
object.getCurrentTime();
object.play();
object.pause();
object.stop();