Starting VLC in Java with Runtime.exec() consumes a lot CPU!

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
dhirwinjr
Blank Cone
Blank Cone
Posts: 35
Joined: 14 Jan 2008 17:46
Operating System: Windows / Linux

Starting VLC in Java with Runtime.exec() consumes a lot CPU!

Postby dhirwinjr » 28 Jun 2008 05:05

All,

I have a Java application that I've developed to view/control video. I use VLC as the video software decoder and so far it's worked really well (I've looked at jVLC but that just wasn't going to work for this application). One issue, however, is that VLC consumes a lot of CPU when I start it using Java and Runtime.exec(). In particular, I have something similar in my current setup (this is from memory so it may not be 100% correct):

Code: Select all

System.getRuntime().exec("C:\Documents and Settings\d.irwin\VideoLAN-0.8.6d\VLC\vlc.exe -I telnet --telnet-host 192.168.0.72:4212 -I rc --rc-host 192.168.0.72:4214 --video-title /"Video Title [192.168.0.72:4212]/"");
In my actual design I pass the resulting Process object to a custom process handler that creates a couple of threads to read in the output streams coming from VLC (per some other suggestions in this forum and others). When VLC is started on my laptop it consumes just about 50% of the CPU and it's not even decoding any video. If, however, I launch VLC from the Windows command line using the exact same command as above VLC consumes maybe 1%-2%.

Note: VLC consumed 50% CPU both before and after I created the process handler/stream reader so that didn't really make any difference.

Any suggestions? This is really causing a problem on some slightly older computers that really chug along when they actually start to decode live video.

Thanks,
Dave

Java 1.5+ on Windows XP with VLC 0.8.6d+

========================================

A little more research done. I found that the following works fine in that it doesn't cause any high CPU consumption:

Code: Select all

private final String vlcPath = "C:\\Documents and Settings\\d.irwin\\VideoLAN-0.8.6d\\VLC\\vlc.exe"; private final String[] args = { vlcPath, "-I", "telnet", "--telnet-host", "192.168.0.72:4212" }; ... try { Runtime.getRuntime().exec(args); } catch (IOException ioe) { System.err.println("IO exception: " + ioe.getMessage()); }
However, if I add the VLC option to enable the remote control interface via the command line all of a sudden the CPU consumption hits 50%.

Code: Select all

private final String vlcPath = "C:\\Documents and Settings\\d.irwin\\VideoLAN-0.8.6d\\VLC\\vlc.exe"; private final String[] args = { vlcPath, "-I", "telnet", "--telnet-host", "192.168.0.72:4212", "-I", "rc", "--rc-host", "192.168.0.72:4214" }; ... try { Runtime.getRuntime().exec(args); } catch (IOException ioe) { System.err.println("IO exception: " + ioe.getMessage()); }
Weird.

dhirwinjr
Blank Cone
Blank Cone
Posts: 35
Joined: 14 Jan 2008 17:46
Operating System: Windows / Linux

Re: Starting VLC in Java with Runtime.exec() consumes a lot CPU!

Postby dhirwinjr » 29 Jun 2008 18:45

It turns out that if you use the "--rc-quite" command line option this fixes the high CPU usage problem when starting VLC using Java. In turn, however, I found that if you have opened the input streams that you can use to view the output from VLC when you try to close the streams (i.e. when you try to close VLC via Java) Java just hangs. If I don't use these input streams then VLC will exit normally via Java.

Dave

agussi
New Cone
New Cone
Posts: 9
Joined: 11 Jun 2008 11:51

Re: Starting VLC in Java with Runtime.exec() consumes a lot CPU!

Postby agussi » 30 Jun 2008 14:10

hi dhirwinjr,

thanks for your post
I am also using a runtime.exec command to launch and use vlc.
what do you mean by :
It turns out that if you use the "--rc-quite" command line option this fixes the high CPU usage problem when starting VLC using Java.
Can you give me your command line, please?

thx

dhirwinjr
Blank Cone
Blank Cone
Posts: 35
Joined: 14 Jan 2008 17:46
Operating System: Windows / Linux

Re: Starting VLC in Java with Runtime.exec() consumes a lot CPU!

Postby dhirwinjr » 03 Jul 2008 03:55

hi dhirwinjr,

thanks for your post
I am also using a runtime.exec command to launch and use vlc.
what do you mean by :
It turns out that if you use the "--rc-quite" command line option this fixes the high CPU usage problem when starting VLC using Java.
Can you give me your command line, please?

thx
Just add the "--rc-quite" option to the command line. For example, here's the command line that I now use:

Code: Select all

System.getRuntime().exec("C:\Documents and Settings\d.irwin\VideoLAN-0.8.6d\VLC\vlc.exe -I telnet --telnet-host 192.168.0.72:4212 -I rc --rc-host 192.168.0.72:4214 --rc-quite --video-title /"Video Title [192.168.0.72:4212]/"");
In some initial testing on the particular machine I was using (a Pentium IV with 1 GB of RAM with a medium range ATI Radeon graphics card) it help reduce CPU consumption by 25-35%.

Dave


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 13 guests