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.
Page Index Toggle Pages: 1
GSVideo, Minim and pulseaudio (Read 1313 times)
GSVideo, Minim and pulseaudio
Nov 16th, 2009, 2:23pm
 
I'm trying to incorporate GSVideo into a game I've developed - the video is to be displayed as a texture on a panel in the game (the video has sound which I also want to play), and I've run a few tests to make sure my initial GSVideo code is correct.

Problems arise, however, when I start the video after playing a few sound effects using Minim. The video appears as a texture for the first frame or two then disappears.  I've checked what's going on, and the video width is correct for those few frames, but then returns to zero.  No error messages are printed.

What I think is going on is a pulseaudio problem.  I'm running processing-1.0.9 on Ubuntu Karmic, and if I want Minim to work, I have to start processing after making sure that no other applications that use audio are running.  That's my first clue.

Obviously, my GSMovie object needs to use audio too, so when it starts to play the video but finds it can't output audio, it dies.  Using this fuzzy logic, I've added code that kills any running samples Minim may be playing, but my GSMovie still fails silently.

So what I'm asking is, has anyone else had this type of problem?  Am I right in thinking this is pulseaudio (Ubuntu users shout YES in unison Smiley)  And how do I debug this if GSVideo fails silently?

Edit: Thought I'd include an example that demonstrates the problem:

This works:
Code:
import processing.opengl.*;
import codeanticode.gsvideo.*;

import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

GSMovie movie;
Minim minim;
AudioSnippet sfx;

boolean KEY = false;

void setup() {
 size(640, 480, OPENGL);
 minim = new Minim(this);
 sfx = minim.loadSnippet("groove.mp3");
 sfx.play();
 movie = new GSMovie(this, "back-wall.avi");
 background(0);
}

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

void draw() {
   if (KEY) image(movie, 0, 0, width, height);
}

void keyPressed() {
 movie.play();
 sfx.close();
 KEY = true;
}

void stop() {
   minim.stop();
   super.stop();
}


When I remove the command to stop the sound effects, the video displays the first frame then fails:
Code:
void keyPressed() {
 movie.play();
 KEY = true;
}
Re: GSVideo, Minim and pulseaudio
Reply #1 - Nov 16th, 2009, 3:46pm
 
Hurrah!  I was looking in the wrong place - I should have done a search for "pulseaudio javasound.  And yes, it was pulseaudio that was the problem.

For other Ubuntu pulseaudio sufferers,  I eventually found the answer here: http://tuxguitar.herac.com.ar/rd.php/message_boards/forum_posts.do?wlang=en&tid=1035&fid=4

Apparently, Java still doesn't talk with pulse in Ubuntu, instead using OSS to output sound (and the two, of course, can't cope with each other running at the same time).  So to send audio from Java to pulse, use this line when starting processing: Code:
padsp processing 

and pulseaudio will capture the java sound output and wrap it as a pulseaudio plugin, meaning you can then run GSVideo without it getting confused!

Thanks to Julian's post on the TuxGuitar forums.
Re: GSVideo, Minim and pulseaudio
Reply #2 - Nov 17th, 2009, 8:42am
 
Well, I was a little premature with that solution.  It worked for just a few running sample instances in Minim, but then GSVideo started failing silently again when it got too busy.

Anyway, I've now resorted to using only GSVideo in my game - it now controls all sound effects, music and any video (with/without sound) very nicely.  I have a feeling that this Ubuntu pulseaudio problem is going to be prevalent for at least the next 6 months, so I think I'll stick with managing my audio with gstreamer for the foreseeable future.

Hope this is of use to someone, and big thanks to Andres for his fantastic libraries.
Re: GSVideo, Minim and pulseaudio
Reply #3 - Nov 20th, 2009, 4:29am
 
And finally, to put an end to this monologue, I've found an extra caveat of using gstreamer in processing sketches - don't cross the streams!

I found that while using a GSPlayer object whilst also using a GSMovie object in Linux worked perfectly, in Windoze it resulted in failure.  Reading through the development lists for gstreamer, the reason is that one method uses one type of playbin, the other method uses another type of playbin, and the use of two different playbins usually results in a seg fault.

GSMovie seems to be preferable if cross-platform compatibility is required.
Re: GSVideo, Minim and pulseaudio
Reply #4 - Nov 20th, 2009, 11:38am
 
hey, thanks for posting your experience with gsvideo, and glad to know that you find the lib useful.

With regards to the mixing of players, it is great that you pointed out this issue since GSPlayer should use PlayBin2 as well. I'm changing the code right now Smiley
Page Index Toggle Pages: 1