When setting the playback speed of a movie using the speed() method, and the stream is returns to the beginning either using jump() or stop(), the speed is reset to zero.
Code that shows the error:
import codeanticode.gsvideo.*;
GSMovie movie;
public void setup() {
size(320, 240);
background(0);
movie = new GSMovie(this, "balloon.ogg");
movie.loop();
PFont font = loadFont("DejaVuSans-24.vlw");
textFont(font, 24);
}
public void movieEvent(GSMovie movie) {
movie.read();
}
public void draw() {
image(movie, 0, 0, width, height);
if (movie.isPlaying()) {
float newSpeed = map(mouseX, 0, width, 0.1, 2);
movie.speed(newSpeed);
fill(240, 20, 30);
text(nfc(newSpeed, 2) + "X", width - 80, 30);
}
}
public void keyPressed() {
if (key == 'p') {
//movie.pause();
movie.goToBeginning();
} else if (key == 'l') {
movie.loop();
//movie.goToBeginning();
}
}
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Currently facing this issue, have you find a workaround? Thank you.
Lionel Radisson - Makio135
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
it seems to be due to this line in GSMovie.speed(): if (PApplet.abs(rate - irate) > 0.1) // avoid to set speed again if value is the same as actual speed
public void speed(float irate) {
// If the frameRate() method is called continuously with very similar
// rate values, playback might become sluggish. This condition attempts
// to take care of that.
if (PApplet.abs(rate - irate) > 0.1) {
rate = irate;
frameRate(fps); // The framerate is the same, but the rate (speed) could be different.
}
}
Here is a little workaround:
import codeanticode.gsvideo.*;
GSMovie movie;
float movieSpeed = 4.98;
public void setup() {
size(320, 240);
background(0);
movie = new GSMovie(this, "station.mov");
movie.loop();
textSize(24);
}
public void movieEvent(GSMovie movie) {
movie.read();
}
public void draw() {
if (movie.isPlaying()) {
movie.speed(movieSpeed);
image(movie, 0, 0, width, height);
fill(240, 20, 30);
text(nfc(movieSpeed, 2), width - 80, 30);
if(movie.duration()-movie.time()<.1){
movie.speed(movieSpeed+1);//modifying speed before goToBeginning,
movie.goToBeginning();
movie.speed(movieSpeed);// then setting speed back at next frame
}
}
}
void mouseMoved(){
movieSpeed = map(mouseX, 0, width, 0.1, 5);
println("new speed: "+movieSpeed);
}
</code>
A method like "float GSMovie.getSpeed(){ return rate; }" could be usefull.
Thanks for your great work.
Lionel Radisson / Makio135
Hello, thanks for your report.
Since GSVideo became the new built-in video library in Processing 2.0, I haven't had the time to work on it, and all the fixes and improvement have been done in the main trunk of Processing.
I think the changes in the core video library that take care of this issue are the following:
http://code.google.com/p/processing/source/detail?r=10264
http://code.google.com/p/processing/source/detail?r=9571
It would be great to backport them to GSVideo, and I'd also like to have a new release to make it more compatible with Processing 2.0 but right now the priority is to get 2.0 out...
Andres