O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Playing a video file

The openFrameworks's ofVideoPlayer class is intended for playing and controlling video. The basic usage of the ofVideoPlayer video object is the following:

  1. Loading video file, specifying its name:
    video.loadMovie( "video.mov" ); 
  2. Starting video to play:
    video.play();
  3. Decoding the needed frame to show and playing the corresponding sound chunk (best to call it in testApp::update()):
    video.update();
  4. Drawing the current video frame:
    video.draw( x, y );

    or

    video.draw( x, y, w, h );

While drawing a video frame, you can think of the current frame of video as if it were an ordinal ofImage object. So, you can use the video.width, video.height values and set anchor using video.setAnchorPercent( percentX, percentY ), video.setAnchorPoint( x, y ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required