We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › GSVideo - problem obtaining video width and read()
Page Index Toggle Pages: 1
GSVideo - problem obtaining video width and read() (Read 544 times)
GSVideo - problem obtaining video width and read()
Jan 15th, 2009, 1:45pm
 
hi folks

I am trying to realize a small app which takes a video, makes screenshots every nth-frame and tiles the images on to the screen. as i ran into problems with larger videos using the built in video library i switched over to GSVideo.

First trying to obtain the movies width and height with movie.width and movie.height i always get a 1 back. i even have a while loop to wait for the movie being loaded

while(myMovie.duration() <= 0.0) {
   print("wait...");
 }

when i set these values manually, i run into the next problem with the read() method.
i am jumping to the different frames using the jump method. but to get the image on to the screen i have to use the read() method, which, not using it within the movieEvent function, gives me a NullPointerException.
The program using the built in Video library worked fine (except of the crashing issue using larger videos).

Having installed GSVideo on a mac which wasn't that easy (at least for me) i tried some examples. as for the examples pixelate and loop they work fine. but the Scratch example wont work. it just stays black. with no error.

The reason i wrote that is. Somehow i think these two problems are related.

I hope someone understands my brabble.
thanks
fakob
Re: GSVideo - problem obtaining video width and re
Reply #1 - Jan 25th, 2009, 9:30pm
 
Hello,

Sorry for the late replay, I've been away from the processing forums for a little while.

I just fixed the scratch example, which didn't work precisely because it didn't check that the video width and height weren't yet initialized. I didn't have time to upload a new version of gsvideo, so here you have the updated code of scratch:

Code:

import codeanticode.gsvideo.*;

GSMovie myMovie;


void setup() {
size(640, 480);
background(0);
// Load and play the video in a loop
myMovie = new GSMovie(this, "station.mov");
myMovie.play();
}

void movieEvent(GSMovie myMovie) {
myMovie.read();
}

void draw() {
if ((1 < myMovie.width) && (1 < myMovie.height)) {
myMovie.jump(myMovie.duration() * mouseX / width);
image(myMovie, 0, 0, width, height);
}
}


The problem with movie.width and movie.height is that they are set to 1 until the first frame is read, so until that point you don't know the width and height of the video.

But the solution I think is easy, just add in your code a condition similar to the one I put in the scratch example.

As for the complexity of the installation of gsvideo on OSX, this has been a hurdle for a long time, and the main reason for this is gstreamer itself, and the lack of binary packages for OSX. Macports is a really cumbersome and not very convenient way of installing gstreamer, as you discovered yourself, at least for the purpose of integrating with gsvideo, since it installs lots of unneeded dependencies (GTK, gnome, etc), and everything has to be inside /opt/local.

However, there is some hope that the situation on OSX will improve. For example, the songbird music player (http://www.getsongbird.com/) uses gstreamer on Windows, Linux and OSX. In fact, I was able to use the OSX gstreamer binaries that come with songbird inside gsvideo (so no more macports), and at least I could initialize gsvideo and play audio files. The problem is that songbird's gstremaer doesn't include any video decoder plugin yet, so it is pretty much useless at this point. However, the whole build environment that the songbird developers use to compile gstremaer seems to be available here:

http://src.songbirdnest.com/source/xref/dependencies/

which opens the possibility of using it to add and compile the video plugins for OSX.
Page Index Toggle Pages: 1