Starting VLC in Java with Runtime.exec() consumes a lot CPU!
Posted: 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):
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:
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%.
Weird.
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]/"");
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());
}
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());
}