Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  VLC and Java pipeing  (Read 5107 times)
0 Members and 1 Guest are viewing this topic.
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Posted 2012-06-26 15:49:33 »

I am currently really confused about why my program doesn't work.
Here I have set up a tiny test program for you:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public static void main(String[] args) {
   try {
      // Start new Process / Start VLC:
      Process p = Runtime.getRuntime().exec(new String[] { "vlc", "-vvv" /* Super-verbose*/});
      BufferedReader read = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line;
      while ((line = read.readLine()) != null) {
         System.out.println("VLC has print: " + line);
      }
   } catch (IOException e) {
      e.printStackTrace();
   }
}


Try starting "vlc -vvv" via command line too. You will see lots of debug-text, which is what I need.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline nsigma
« Reply #1 - Posted 2012-06-26 15:55:17 »

Tangential question - what are you actually trying to do, and why not use https://github.com/caprica/vlcj?

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2012-06-26 16:14:01 »

You can use my code as reference:

http://pastebin.java-gaming.org/54a6b2d341c

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #3 - Posted 2012-06-26 16:19:34 »

Okey. Sorry for spawining such a topic... I "fixed" it...
I used a "workaround".

I'm using gstreamer now Cheesy (over commandline via "gst-launch-0.10 playbin2 ...").
Works fine, and even does return if the song is finished.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2012-06-26 16:21:43 »

Works fine
For the sake of the community, share your code! Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #5 - Posted 2012-06-26 16:37:55 »


Was actually for private use, because I hated all these hard-to-use and take-10-years-to-"learn"-players, so I invented my own one.

The player is super simple. It just searches recursivly through the current directory, the jar is placed in, and then just picks a random one, and plays it. Remember, this is a commandline tool. Don't expect to get some windows popped up. I like commandline tools, because it is so simple, and I have a konsole opened with one key: F12 (install yakuake Wink ). The only available things to tell the player are: "next" and "exit". Exit will make the player exit, and "next" will make the player pick the next song.

So finally, here is the source:
http://pastebin.java-gaming.org/54a6b6d341c

Have fun Wink (also, this is programmed in about 1h now Grin

EDIT: I forgot. Make sure you have all gstreamer plugins installed, especially the mp3-player plugin Wink (this player only plays .mp3)

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2012-06-26 16:44:48 »

Thanks!

1  
p = Runtime.getRuntime().exec(commands);

If the process writes a significant amount of bytes to either stdout or stderr, it will eventually block if you don't read these streams from the Java side.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #7 - Posted 2012-06-26 16:46:28 »

Thanks!

1  
p = Runtime.getRuntime().exec(commands);

If the process writes a significant amount of bytes to either stdout or stderr, it will eventually block if you don't read these streams from the Java side.
What would be the fix, or the workaround? Reading that InputStream, doing nothing with it?

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2012-06-26 16:51:24 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public static void asyncConsumeStream(final InputStream in) {
   new Thread(new Runnable() {
      public void run() {
         consumeStream(in);
      }
   }).start();
}

public static void consumeStream(InputStream in) {
   byte[] tmp = new byte[4*1024];
   try {
      while(in.read(tmp) != -1) {
         continue;
      }
      in.close();
   }
   catch(IOException exc) {
      // ignore
   }
}


1  
2  
asyncConsumeStream(p.getInputStream()); // stdout
asyncConsumeStream(p.getErrorStream()); // stderr

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2012-06-26 16:55:47 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public static void asyncConsumeStream(final InputStream in) {
   new Thread(new Runnable() {
      public void run() {
         consumeStream(in);
      }
   }).start();
}

public static void consumeStream(InputStream in) {
   byte[] tmp = new byte[4*1024];
   try {
      while(in.read(tmp) != -1) {
         continue;
      }
      in.close();
   }
   catch(IOException exc) {
      // ignore
   }
}


1  
2  
asyncConsumeStream(p.getInputStream()); // stdout
asyncConsumeStream(p.getErrorStream()); // stderr


thanks a lot Smiley
Fixed an issue on another project I have Cheesy

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2012-06-26 22:43:48 »

Hi

Matheus23, why don't you use com.jogamp.opengl.util.av.GLMediaPlayerFactory to do that? If you need some help, let us know. Sorry for the "off topic".

Offline Regenuluz
« Reply #11 - Posted 2012-06-27 12:50:37 »

Tangential question - what are you actually trying to do, and why not use https://github.com/caprica/vlcj?

Just got to point out that VLCJ is GPL, which means that you'll have to release all source code you write, if you use it. And it won't be changed to LGPL like libVLC and libVLCcore is. I know this because I mailed him asking if he'd release it under another license.
Offline Cero
« Reply #12 - Posted 2012-06-27 12:58:45 »

Tangential question - what are you actually trying to do, and why not use https://github.com/caprica/vlcj?

Just got to point out that VLCJ is GPL, which means that you'll have to release all source code you write, if you use it. And it won't be changed to LGPL like libVLC and libVLCcore is. I know this because I mailed him asking if he'd release it under another license.

He was still undecided when I asked him 2 months ago or so. What did he say exactly ?
Well if it really comes to this I am just going to GPL my code. Its not like anyone cares about source code anyway; and maybe I can even only make a certain part GPL that interacts with VLCJ...

Offline Regenuluz
« Reply #13 - Posted 2012-06-27 13:23:55 »

6 days ago.

Here is his email:

Quote
Hello,

I have no incentive to license my work under a free-as-in-beer license.

I am quite happy with GPL, so the choice will remain at least for the foreseeable future as GPL or commercial.

Regards,

-Mark.

I guess he isn't saying that it'll never be LGPL, but... Tongue
Offline Cero
« Reply #14 - Posted 2012-06-27 14:00:54 »

6 days ago.

Here is his email:

Quote
Hello,

I have no incentive to license my work under a free-as-in-beer license.

I am quite happy with GPL, so the choice will remain at least for the foreseeable future as GPL or commercial.

Regards,

-Mark.

I guess he isn't saying that it'll never be LGPL, but... Tongue

well fine
I would even pay money for a good video playback lib - but obviously not too much
but GPL isnt that bad - end user dont care either way

what is weird is: he couldnt even answer me back then if it was possible to only GPL a part of my source code that uses VLCJ and stuff, since he is not a lawyer, he said.
But I dont get why he likes and wants GPL, if he doesnt even understand it completely. What are his benefits =o

Offline nsigma
« Reply #15 - Posted 2012-06-27 14:54:43 »

he couldnt even answer me back then if it was possible to only GPL a part of my source code that uses VLCJ and stuff,

Almost certainly not, as that would be breaking the license conditions, unless you went with weird hacks in terms of how you distribute, and even that would be dubious.

What are his benefits =o

GPL's a great license if you have control of the code base, as it gives you better leverage to commercialise your code.  I assume if he's bothered he might be making (or envisages making) money from commercial licensing.

What's wrong with GStreamer?  That's LGPL (apart from a couple of optional codecs) and works great.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Cero
« Reply #16 - Posted 2012-06-27 15:47:19 »

What's wrong with GStreamer?  That's LGPL (apart from a couple of optional codecs) and works great.

Guy, we talked about this in great length in various threads... we had some success with vlcj, I dont recall anyone who produced what we need with gstreamer. it might be possible, but I think no one but you looked into gstreamer that long.

we need theora/vorbis playback, in opengl meaning it will have to render it to an LWJGL texture.
the game you are distributing has to work on all 3 platforms
it has to have everything the game needs to play the video
the user cannot be promted to install anything, not gstreamer, not vlc - its all packaged
it has to just work, even on weaker machines, as best as possible, no audio/video desync and no tearing if possible

I pretty much got it with VLCJ, just the license makes a little trouble

if you can release a lwjgl example that plays a theora video, with everything bundled, which just works on all platforms, then I would take gstreamer seriously
When trying I couldnt get the linking to work
with vlc I just have a "vlib" folder, put everything there and tell VLCJ to look there.

Offline Regenuluz
« Reply #17 - Posted 2012-06-27 15:49:38 »

What are his benefits =o

He actually sells a commercial license via his website, so I guess he gets money from it. xD
Offline Cero
« Reply #18 - Posted 2012-06-27 15:54:57 »

What are his benefits =o

He actually sells a commercial license via his website, so I guess he gets money from it. xD

I would really be interested how much that would be.

Offline nsigma
« Reply #19 - Posted 2012-06-27 15:59:04 »

What's wrong with GStreamer?  That's LGPL (apart from a couple of optional codecs) and works great.

Guy, we talked about this in great length in various threads... we had some success with vlcj, I dont recall anyone who produced what we need with gstreamer. it might be possible, but I think no one but you looked into gstreamer that long.

we need theora/vorbis playback, in opengl meaning it will have to render it to an LWJGL texture.
the game you are distributing has to work on all 3 platforms
it has to have everything the game needs to play the video
the user cannot be promted to install anything, not gstreamer, not vlc - its all packaged
it has to just work, even on weaker machines, as best as possible, no audio/video desync and no tearing if possible

I pretty much got it with VLCJ, just the license makes a little trouble

if you can release a lwjgl example that plays a theora video, with everything bundled, which just works on all platforms, then I would take gstreamer seriously
When trying I couldnt get the linking to work
with vlc I just have a "vlib" folder, put everything there and tell VLCJ to look there.

I'm aware we've discussed before, and I've also told you that Praxis does almost all this already (not doing audio playback at the moment for other reasons).  That includes bundling GStreamer, and rendering into an LWJGL texture.  My GStreamer plugin for Windows may be an optional download, but it could as easily work bundled - it's all locally linked.  However, Praxis is a far bigger project than you need for this.  As I've said, I'll point you in the right direction with what's in the Praxis plugin to make this work, but I'm not writing it.  It's a simplified fork of what's in Processing anyway.  There's some code up here (theagentd?) that will directly push the data to a texture in a much simpler way than my code.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #20 - Posted 2012-06-27 16:03:58 »

Erm... actually this project was only intended as private Project, so what are you even talking about Cheesy
Also, yes, I know VLCJ but it is simply overkill. I just wanted to play a random music file. I've done that with 162 Lines?!? thats it.

And Cero, if you are looking for Video playing in opengl, then you could switch to / wrap between LWJGL and JOGL, and play the video with JogAmp's video player Wink

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline gouessej
« Reply #21 - Posted 2012-06-27 16:09:57 »

And Cero, if you are looking for Video playing in opengl, then you could switch to / wrap between LWJGL and JOGL, and play the video with JogAmp's video player Wink
That's why I talked about com.jogamp.opengl.util.av.GLMediaPlayerFactory.

Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #22 - Posted 2012-06-27 16:11:45 »

And Cero, if you are looking for Video playing in opengl, then you could switch to / wrap between LWJGL and JOGL, and play the video with JogAmp's video player Wink
That's why I talked about com.jogamp.opengl.util.av.GLMediaPlayerFactory.
Yep. I know that class Smiley It's the class I was referring to Wink
But using that would be overkill, because - as I said - I don't want it to be a big project or anything. Just some private code, one little file. I don't want to install natives or anything.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline nsigma
« Reply #23 - Posted 2012-06-27 16:12:56 »

And Cero, if you are looking for Video playing in opengl, then you could switch to / wrap between LWJGL and JOGL, and play the video with JogAmp's video player Wink
That's why I talked about com.jogamp.opengl.util.av.GLMediaPlayerFactory.
Yep. I know that class Smiley It's the class I was referring to Wink
But using that would be overkill, because - as I said - I don't want it to be a big project or anything. Just some private code, one little file. I don't want to install natives or anything.

Don't be alarmed - I think your thread got hijacked!  Grin

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Cero
« Reply #24 - Posted 2012-06-27 16:29:03 »

video playback is so important, threads gonna get hijacked =D

what gstreamer java binding do you use; or did you write your own ? I might take a look into it again
if praxis cannot play audio im not gonna look into it yet - cortado was perfect without audio, but playing audio and not desyncing is an essential problem - which vlcj solved imo

if jogamp can play ogg video and audio thats good I guess, but since Im using LWJGL, someone would have to combine it somehow

Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #25 - Posted 2012-06-27 16:36:09 »

what gstreamer java binding do you use; or did you write your own ? I might take a look into it again
I'm dealing with threads. I'm using gstreamer via Runtime.getRuntime().exec(...), a.k.a. command-line, so I don't need any wrapper.

What I've seen is gstreamer-java, a gstreamer wrapper for java. Seems to be about as easy as using gstreamer with command-line, and could even give you pausing, unpausing, volume etc.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Cero
« Reply #26 - Posted 2012-06-27 16:44:31 »

what gstreamer java binding do you use; or did you write your own ? I might take a look into it again
I'm dealing with threads. I'm using gstreamer via Runtime.getRuntime().exec(...), a.k.a. command-line, so I don't need any wrapper.

What I've seen is gstreamer-java, a gstreamer wrapper for java. Seems to be about as easy as using gstreamer with command-line, and could even give you pausing, unpausing, volume etc.

Yeah was talking to nsigma
for a general solution for video playback, we need something that renders direct to texture n stuff

Offline nsigma
« Reply #27 - Posted 2012-06-27 17:04:31 »

I'm using GStreamer-Java with the prebuilt libs from Processing repo and a  fork of their library loading code.

GStreamer supports audio fine. I just haven't got around to getting the audio into the Praxis audio pipeline yet. It's irrelevant for your usage.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Cero
« Reply #28 - Posted 2012-06-27 18:04:02 »

I'm using GStreamer-Java with the prebuilt libs from Processing repo and a  fork of their library loading code.

Do you use the old 1.5 version or 2.0 pre-releases ?

Offline nsigma
« Reply #29 - Posted 2012-06-27 18:32:32 »

I'm using GStreamer-Java with the prebuilt libs from Processing repo and a  fork of their library loading code.

Do you use the old 1.5 version or 2.0 pre-releases ?

I forked the current Processing 2.0 library code (GStreamer isn't in 1.5 is it?)

Anyway (as I've pointed you to before  Tongue ) the forked library loader (for Windows) is here - http://code.google.com/p/praxis/source/browse/praxis.video-gstreamer-win/src/net/neilcsmith/praxis/video/gstreamer/windows/LibraryLoaderImpl.java?repo=ext  You'll need to change the lines with InstalledFileLocator (from NetBeans platform) to point at the folder you put the native libs in.  You'll probably want to make load() public too.

You'll need the GStreamer native libs themselves - easier than checking out Processing will be to download the Praxis plugin from http://code.google.com/p/praxis/downloads/list.  An *.nbm file is just a rebadged Zip, so extract it and you'll find the libs.

The GStreamer libs from Processing include a few GPL plugins.  Unfortunately, I'm not entirely sure which are the GPL ones (Praxis is GPL anyway), so you'll have to figure it out and just delete them.  Removing plugins you don't need shouldn't break anything.

You'll need to write a simple player, and upload to the texture using the code that theagentd gave you as a base.  Some of the code in my PlaybinDelegate might help you - ignore the GPL, I'll let you use what you want!  Wink  You'll also want to take out the line that sets the audio sink to null, which is why audio doesn't work in Praxis - I need to write a custom audio sink to get the audio into Praxis' audio pipeline.

OSX is also doable (and should be easier to port from Processing) but I don't have access to a Mac to test on at the moment.

Anything else, just ask.  And if you want to check all the native libs link properly, try Praxis and the plugin first.  They work here fine, so hopefully the same for you.

Best wishes, Neil

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (27 views)
2014-11-22 12:13:56

xFryIx (69 views)
2014-11-13 12:34:49

digdugdiggy (48 views)
2014-11-12 21:11:50

digdugdiggy (42 views)
2014-11-12 21:10:15

digdugdiggy (36 views)
2014-11-12 21:09:33

kovacsa (60 views)
2014-11-07 19:57:14

TehJavaDev (64 views)
2014-11-03 22:04:50

BurntPizza (62 views)
2014-11-03 18:54:52

moogie (77 views)
2014-11-03 06:22:04

CopyableCougar4 (77 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!