Playing a video file
openFrameworks supports video files of various formats, including MP4, MOV, and AVI. The class for playing videos is ofVideoPlayer
.
Note
For playing videos with openFrameworks on Windows, you need to have Apple's QuickTime installed. It's free to download from apple.com. (Please, restart Windows after installing.)
Let's load a video file and play it on the screen in the following way:
- Add the video object definition to the
ofApp
class:ofVideoPlayer video;
- Add the commands to load the video from the
flowing.mp4
file and starting it to play by inserting the following lines tosetup()
:video.loadMovie( "flowing.mp4" ); video.play();
- Add the command to update video objects regularly by inserting the following line to
update()
:video.update();
Note
This command manages the loading of new video frames when it is needed, so we should call it regularly to have proper and smooth video playback.
- Add the commands to draw the current video frame by inserting the following...