Due to the fact that the jvlc library does not work properly, I decided to use VLC externaly for streaming the video from the Robot to the Controlling PC.

With the jvlc library it would have been possible to hit any button within the VLC player to change options like the Video size or source.

With an external VLC player there is no possibility to change propertys remotly. VLC must be always restarted, with new command line options, to change propertys. The following Code snippets show how to start and how to stop the VLC player.  In this case there should only be one VLC instance be running. Therefore all VLC instances are killed before starting a new one.

The following code shows how an external program like the VLC player can be killed and started.
The exitVal is 0 if no error was returned by the called programm.
If it is not 0 the input stream contains the error message.

Runtime rt = Runtime.getRuntime();
try {
Process pr1=rt.exec("cmd /c TASKKILL /F /im vlc.exe");
int exitVal =0;
    try {
              exitVal = pr1.waitFor();
              System.out.println("Process exitValue: " + exitVal);
         } catch (InterruptedException e1) {
              e1.printStackTrace();
         }
 
    System.out.println("Starting vlc with file: " + port);
    System.out.println(vlcpath + "\\vlc.exe -vvv ");
    pr_ = rt.exec("cmd /c START "+system.data.library.vlc + "\\vlc.exe -vvv dshow:// :dshow-vdev=\""+cam+"\" :dshow-adev=\"\"  :dshow-size=\"320\" :dshow-caching=50 :dshow-chroma=\"\" :dshow-fps=15.000000 :no-dshow-config :no-dshow-tuner :dshow-tuner-channel=0 :dshow-tuner-country=0 :dshow-tuner-input=0 :dshow-video-input=-1 :dshow-audio-input=-1 :dshow-video-output=-1 :dshow-audio-output=-1 :sout=#transcode{vcodec=mp4v,vb=256,scale=1}:duplicate{dst=std{access=udp,mux=ts,dst=192.168.1.10:1238}}");
    this.started_ = true;	
 
    InputStream stderr = pr_.getErrorStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    tring line = null;
 
    try {
         exitVal = pr_.waitFor();
         System.out.println("Process exitValue: " + exitVal);
        } catch (InterruptedException e1) {
         e1.printStackTrace();
        }
 
    if(exitVal != 0)
    {
        System.out.println("");
        while ( (line = br.readLine()) != null)
             System.out.println(line);
        System.out.println("");
    }
 
    System.out.println("VLC should be started");
} catch (IOException e) {
    e.printStackTrace();
}

Leave a Reply