I've just started to experiment with the Movie library and I've run into some basic questions.
Here's the testbed code:
import processing.video.*;
Movie myMovie;
int screenSizeX = 800;
int screenSizeY = 600;
float duration = 0;
void settings()
{
size(screenSizeX, screenSizeY);
}
void setup() {
myMovie = new Movie(this, "20180201103135_20180201103155_01_M.dav");
myMovie.frameRate(25);
myMovie.speed(0.01);
duration = myMovie.duration();
println("setup duration =" + duration);
duration = myMovie.playbin.queryDuration().toSeconds();
println("setup playbin.queryDuration() duration =" + duration);
myMovie.loop();
}
void draw() {
image(myMovie, 0, 0);
println("Duration=" + myMovie.duration());
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
m.read();
duration = myMovie.duration();
println("movieEvent duration =" + duration);
}
When I run it, duration always appear to return 0.0 regardless of when I test it -- including if I call playbin directly (mimicking the library code at line 270 here: https://github.com/processing/processing-video/blob/master/src/processing/video/Movie.java ).
The console output is:
setup duration =0.0
setup playbin.queryDuration() duration =0.0
movieEvent duration =0.0
Duration=0.0
Duration=0.0
movieEvent duration =0.0
Duration=0.0
:
What I was really trying to do (apart from experimenting with playback at various speeds) was figure out how to detect when a Movie has finished playing? I've seen some example code that did this:
if (myMovie.time() >= myMovie.duration()) // Test if the playhead is at the end
{
// end of Movie
}
Of course that's destined to fail if .duration() always returns zero. So that raises the question, how do you tell when a movie has finished?? I supposed I could check when .time() stops changing, but that squawks a dreaded red text error on the console when the code runs "off the end" of the Movie.
Anyone got any ideas how you test for when a Movie has finished playing? I need to work my way through a directory with hundreds of different movie files and extract individual frames -- I've figured out what I thought would be the hard part only to screech to a halt on this "simple" problem. :(
Oh....and anyone got any ideas why myMovie.frameRate() and .speed() don't appear to do anything?
Thanks in advance Andy