Can ofVideoplayer rewind the video?

Hello, I am trying to rewind the video using ofVideoplayer. but I cant find solutions, I’ve tried setSpeed to -1 but it wont work.

do I have to use addons to rewind the video on OF? plz help…

Hey @quinton, it might be helpful for others if you posted some info about your platform and maybe some code. On linux with 0.11.2, a video will play backward when ofVideoPlayer::setSpeed(-1.0) is called. The motion in reverse was a bit jerky sometimes though. I ran the install_codecs.sh script before I compiled oF. The following thread talks a bit about codecs and playing a video backwards: ofVideoPlayer direction backwards. There may be other previous threads in forum that could be helpful too.

This played backwards and forwards for me:

// ofApp.h
// the ususal stuff, then
    ofVideoPlayer videoPlayer;
    float speed;
// ofApp.cpp
void ofApp::setup(){
    speed = 1.0;
    videoPlayer.load("video.MOV");
    videoPlayer.setLoopState(OF_LOOP_NORMAL);
    videoPlayer.setSpeed(speed);
    videoPlayer.play();
}
//--------------------------------------------------------------
void ofApp::update(){
    videoPlayer.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
    videoPlayer.draw(0.f, 0.f);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    if(key == 'r') {speed *= -1.0; videoPlayer.setSpeed(speed);}
}
1 Like

@quinton , @TimChi is correct -

ofVideoPlayer will play forwards or backwards just fine - set the play speed and issue the play command -

some codecs are really designed to play forward only and show poor performance playing backwards (and sometimes seeking to specific frames) so if the video is jerky playing backwards then re-encoding with another codec may help a lot.

there is a quick overview here - https://www.videomaker.com/article/c03/18165-how-to-choose-the-right-codec-and-container-for-your-video-workflow

and many other helpful discussions across the web on codec choice for different applications>

(as a shameless plug) I did a tutorial walking thru playing video with ofVideoPlayer (including backwards) you can see it here

2 Likes