I’m trying to play a video using the official video library on Linux (openSUSE tumbleweed). I noticed the following: if I try to run a sketch with P2D or P3D, doing new Movie(this, ...) causes Processing to exit, seemingly normally, without any error message. Here’s a minimal example:
import processing.video.*;
void setup() {
// same with P3D. If I leave out P2D and use the default renderer, it works
size(640, 480, P2D);
new Movie(this, "test.mp4");
}
The filename doesn’t matter, it’s the same if the file exists or not. I get the following output in the terminal:
Processing video library using bundled GStreamer 1.20.3 (CVS)
Scanning GStreamer plugins... Done.
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 3/3, reusable (open, marked uncloseable): 0, pend
ing (open in creation order): 3)
X11Util: Open X11 Display Connections: 3
X11Util: Open[0]: NamedX11Display[:0, 0x7f01b0747f50, refCount 1, unCloseable false]
X11Util: Open[1]: NamedX11Display[:0, 0x7f00e8002050, refCount 1, unCloseable false]
X11Util: Open[2]: NamedX11Display[:0, 0x7f00e8011760, refCount 1, unCloseable false]
Finished.
The X11Util messages are normal I think, I get the same output (except for the GStreamer messages) if I replace new Movie() with just exit(). I have no idea how to investigate this further. Is it possible to run Processing some debugging info or more verbose output?
I’m using Processing 4.3. and the latest version of the Video library, 2.2.2.
Huh, now it suddenly does work, it’s just that the file name was incorrect / the video file was not in the data/ folder next to the sketch. But it didn’t show an error! So if I run it with an incorrect filename with the default renderer, I get
sketch.pde:16:0:16:0: RuntimeException: Could not load movie file nonexistent.mp4
but if I do the same with P2D or P3D, I get the “normal” exit without any error message. I thought I tested this carefully with the example files from the library, but maybe I mixed something up because I was having some other issues with shared libraries as well.
import processing.video.*;
Movie theMovie;
void setup() {
// same with P3D. If I leave out P2D and use the default renderer, it works
size(640, 480, P2D);
string filename = "test.mp4";
try
{
theMovie = new Movie(this, filename);
}
catch (RuntimeException ex)
{
println("file '" + filename + "' not found");
// do other things to handle the exception
...
...
}
}
I did try to find a way to test for the existence of a file in Processing but did not find one, hence the exception handler.
Hmm, weird, I thought that it’s not throwing an exception, but actually it is! It’s just not displayed in the terminal output for some reason. I would have expected that the program exits with an error if an uncaught exception occurs, but it doesn’t seem to be doing it here.
I’m quite new to processing. What I seem to have noticed is that in some cases the underlaying stuff handles exceptions (and possibly silently dies) and in other cases underlaying stuff doesn’t handle it and your application crashes.
But in this case the library doesn’t seem to be handling the exception or dying, but rather somehow changing how the main processing process handles it. With both the default renderer and P2D the catch (RuntimeException ex) { } block is executed. But the behavior is different: for the default renderer, the window gets stuck with the exception message printed to the terminal, but with P2D, the window is closed “normally”, like calling exit(). I wrote some more details on github.
This is really a minor thing, but it still caused me a couple of hours of head-scratching.