Changing video playback speed during playback on raspberry pi

Hello, I am trying to use OpenFrameworks to play back videos on my raspberry pi. I have been using ofxOMXPlayer becuase it seems like it is the only player that will run smoothly on full screen. Is there some way I can change the speed of the video while it is running. I was able to change the speed of the video initally, but can’t change it again once the video is playing. I see my program calls ofRunApp( new ofApp()) to start the video. Is this possible at all to do?

Thanks for your help

ping @jvcleave

Hi, you can call fastForward() in your ofxOMXPlayer whenever you want to. Each time you call it it will increase the speed multiplier (2x normal speed, 3x , …).
Or you can dig a bit into the addon itself and implement a function to set the speed to any desired speed.

It’s definitely one of the lesser tested features and looking at github it looks like fastForward may be disabled in the Master branch

if you want to try it out move the unlock/return to the bottom of this method

You should be able to set it back to normal speed by using
omxPlayer. setNormalSpeed();

Thanks for your response! I have actually implemented something like the method you both mentioned. I created two methods, one in the ofxOMXPlayerEngine that was able to change the speed of the video, and also one in the ofxOMXPlayer that just passes the arguments to the ofxOMXPlayer newly implemted method. The method was called changeVideoPlayback and it took an argument (double) that determined the video speed (0.5 or 2.0). In the code shown below, I called my newly created method in the testApp.c, and it worked as intended, except it could only change the video speed initally and wasn’t able to change it while it was already playing. Where should I implement this method to be able to change the video speed during playback?

##testApp.c ##

void testApp::setup()
    string videoPath = ofToDataPath("../../../video/test1.mp4", true);
    //Somewhat like ofFboSettings we may have a lot of options so this is the current model
    ofxOMXPlayerSettings settings;
    settings.videoPath = videoPath;
    settings.useHDMIForAudio = true;    //default true
    settings.enableTexture = true;        //default true
    settings.enableLooping = true;        //default true
    settings.enableAudio = true;        //default true, save resources by disabling
    //settings.doFlipTexture = true;        //default false
    //so either pass in the settings
    omxPlayer.changeVideoPlayback(2.0)  //This is the new function implemented
    //or live with the defaults


int main()
    ofSetupOpenGL(1280, 720, OF_FULLSCREEN);
    ofRunApp( new testApp());

I believe ofRunApp(new testApp()) is what starts the video. So i am not sure where i should implement the method I created.

Thanks for your help

ofRunApp(new testApp()) starts the OF application - so not there

I would think where you are calling changeVideoPlayback should be ok but I am not sure of the implications of the implementation. You are likely speeding up the clock which is pretty core and may cause some weird things to happen (breaking looping, etc).

Here is how I implemented it:


void ofxOMXPlayer::setNormalSpeed()


void ofxOMXPlayerEngine::changeVideoPlayback(double speed)

    speedMultiplier =(int)normalPlaySpeed*speed;
    ofLogVerbose(__func__) << "clock speed: " << clock.OMXPlaySpeed();
    ofLogVerbose(__func__) << "reader speed: " << omxReader.GetSpeed();


Like I said, this way somehwat worked. I can start the video at any playback rate I want via this method. What I really want to do though is to be able to change the speed of the video while it is playing.

Thanks for your help!

I just messed with it and put an increaseSpeed() method and example in the Master branch

It seemed to work ok with my test movie until it looped - once that happened it took it a while to recover to the normal speed (5-10 seconds)

The currentFrame and remaining frame count also become inaccurate

1 Like

Yes, this is exactly what I wanted, thank you! The only thing I need to do now is be able to control the speed through a program rather then a keyboard. My question now is where is testApp::onCharacterRecieved called? Is see this the method that calls the keyPressed method. If I can find that out, I should be able to implement what I am trying to do. Thank you for providing these examples for me, they are extremly helpful!

onCharacterReceived is a callback so you can enter keys in a terminal/ssh window

You can call omxPlayer.increaseSpeed() anywhere

Did anyone of you work on this further?
I also need to control playback speed. I tried to change it by myself, but I can’t compile this on the raspberry. I followed all the steps that Dom uploaded on GitHub, but it always fails. Maybe because of the new Jessie.
Unfortunately I have too little Linux knowledge to find a solution there …

The master ofxOMXPlayer still has increaseSpeed and works with Jessie/OF 0.9.x

Hey jvcleave,

I mixed it up and thought this post was about the omxplayer!

Now this is even better, because now I can use OF :wink:
I tried your increase-speed example (Compiled, but I had to use make -j2 on the Raspberrypi2. I think RAM got full).
The next step will be changing the example so that smooth fps control is possible
and I need communication with PureData, so I think I can use OSC commands for that.
I have very little experience in C, so this will be a tough learning project, but I will try it.

Thanks a lot,