"Motion for OpenTK", or MotionTK for short, is a video playback library for OpenTK built on FFmpeg, inspired by the Motion library for SFML.
I was looking for a lightweight video playback library for OpenTK, but couldn't find anything that met my requirements. From my SFML days I remembered the Motion library by Zachariah Brown, so I rewrote a simplified version of it in C#.
To function properly, this library requires a working copy of OpenTK and some of the FFmpeg libraries. Specifically, these libraries are required:
- OpenTK.dll
- avcodec-58.dll
- avformat-58.dll
- avutil-58.dll
- swresample-3.dll
- swscale-5.dll
OpenTK itself requires OpenGL and OpenAL to be installed.
Videos are loaded by instantiating the DisplaySource
class.
From there, you can access the VideoPlayback
property, which exposes a Draw
function to render the current frame as well as the TextureHandle
itself.
The audio SourceHandle
can be accessed via the AudioPlayback
property.
Playback control functions (Play
, Pause
and the like) are available via the DisplaySource
instance.
Don't forget to dispose all disposable instances you create!
For a working example check the "Sample" project included with the sources.
If you experience any problems, please file a GitHub issue or contact me under [email protected].
You are of course also invited to fix it yourself and create a pull request :)
FFmpeg has trouble finding files with non-ASCII characters in their path.