Scrubbing through video (frame by frame) with button pulse & RASPBERRY PI

edited September 2017 in Raspberry PI

Modifying a sketch that uses mouseX to scrub through a video. Looking to substitute a increasing integer value controlled by a button press.

Button is working and video on the RasPi works well.

This will work but then eventually crash with errors: Gstreamer encountered a general supporting library error GLVideo: qtedemux0: internal data stream error.

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.RaspiPin;
import gohai.glvideo.*;

GLMovie video1;
GpioController gpio;
GpioPinDigitalInput button;
int interval;

void setup() {
  size(1500, 800, P2D);
  background(0);
  interval = 0;
  gpio = GpioFactory.getInstance();
  button = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);
  video1 = new GLMovie(this, "wheel.mp4");

  video1.pause();
}

void draw() {
  if (button.isHigh()) {
    println("pressed");
    interval++;
    println(interval);
    if (video1.available()) {
      video1.read();
    }
     float moviePosition = map(interval, 0, width, 0, video1.duration());
     print(mouseX);
    video1.jump(moviePosition);
    image(video1, 0, 0, width, height);
  }
}

Answers

  • edited September 2017

    This works, but how to make that scrubbing smooth like mouseX....? hmmmm...

    import com.pi4j.io.gpio.GpioController;
    import com.pi4j.io.gpio.GpioFactory;
    import com.pi4j.io.gpio.GpioPinDigitalInput;
    import com.pi4j.io.gpio.PinPullResistance;
    import com.pi4j.io.gpio.RaspiPin;
    import gohai.glvideo.*;
    
    GLMovie video1;
    GpioController gpio;
    GpioPinDigitalInput button;
    int interval = 0;
    
    void setup() {
      size(1500, 800, P2D);
      background(0);
    
      gpio = GpioFactory.getInstance();
      button = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);
      video1 = new GLMovie(this, "wheel.mp4");
    
      video1.pause();
    }
    
    void draw() {
      if (button.isHigh()) {
        println("pressed");
        interval = interval + 10;
        println(interval);
        if (video1.available()) {
          video1.read();
    
         float moviePosition = map(interval, 0, width, 0, video1.duration());
         print(mouseX);
        video1.jump(moviePosition);
        image(video1, 0, 0, width, height);
      }
    }
    } 
    
Sign In or Register to comment.