Video library: speed() in conjunction with mouseX is delivering jittery playback, and I can't use -1

edited November 2015 in Library Questions

I have two questions with the below code:

import processing.video.*;
Movie myMovie;

void setup() {
  size(600, 400);
  frameRate(30);
  myMovie = new Movie(this, "1.mp4");
  myMovie.loop();
}

void draw() {
  if (myMovie.available()) {
    myMovie.read();
    float  x1 = map(mouseX, 0, width, 0, 3);
    myMovie.speed(x1);
  }
  image(myMovie, 0, 0);
} 

1) How can I make the video play backwards? If I write the following code, I get this error message: (Processing core video:14294): GStreamer-CRITICAL **: get_segment_set_seek: assertion 'start <= stop' failed

    float  x1 = map(mouseX, 0, width, -1, 3)

2) Is there a way to make the playback a little more smooth? There is a lengthy delay between when the mouse is moved and when the video changes playback speeds.

Answers

  • edited November 2015

    There is a lengthy delay between when the mouse is moved and when the video changes playback speeds.

    Since both of your map() & speed() depend on available(), response time isn't frameRate(30);.
    I'd also replace image() w/ set() for a tiny bit performance gain. B-)

  • How can I make the video play backwards?

    I don't think that library got such feature. :(
    If you got lotsa RAM, you might try to get() each read() into some List<PImage>.
    Once playback is finished, display each PImage backwards:

    // forum.processing.org/two/discussion/13557/
    // video-library-speed-in-conjunction-with-mousex-
    // is-delivering-jittery-playback-and-i-can-t-use-1
    
    // 2015-Nov-18
    
    import java.util.List;
    final List<PImage> frames = new ArrayList<PImage>();
    
    import processing.video.Movie;
    Movie mv;
    
    void movieEvent(Movie m) {
      m.read();
      frames.add(m.get());
    }
    
  • Hi GoToLoop,

    Thanks for your response.

    After doing a little more reading, it looks like the inability to play the video backwards is because of the codec I'm using--so that solves that issue.

    I'm still a little cofused as to how to solve the jittery playback though.

    I understand that what you're saying is that both my map() and speed() depend on available(), and so it's slowing things down. Is there a way to solve that problem?

    Thanks!

    • I mean that while draw() is called back @ ~30 FPS -> frameRate(30);, map()'s calculation + speed() modification only happen once a new frame becomes available().
    • That is, even though we're continuously moving the mouse, its mouseX will only be read once per Movie's read().
    • Obviously if you don't want those calculations & modifications bound to available(), you should place them outside its if () block.
    • Of course, that doesn't necessarily mean it's gonna fix the slowdown you're getting.
  • Thanks for your feedback, and for clarifying your last post.

    Unfortunately, I've tried moving them out of the if block, but it still doesn't seem to solve the problem:

    void draw() {
      float  x1 = map(mouseX, 0, width, 0, 3);
      myMovie.speed(x1);
      if (myMovie.available()) {
        myMovie.read();
      }
      image(myMovie, 0, 0);
    } 
    
Sign In or Register to comment.