title: How to run VLC stream on Linux server using Java code?
body: <p>I am trying to run vlc stream from my Java code on Debian server.
  Simple commands as given in the example below works fine both from java code as well as terminal.</p>
  
  <pre><code>String cmd = "/Applications/ video.avi"
  Process p = Runtime.getRuntime().exec(cmd);
  </code></pre>
  
  <p>But I try to run more advanced command with multiple options"</p>
  
  <pre><code>vlc -vvv http://umevakameran.net.umea.se/mjpg/video.mjpg --no-audio --sout '#transcode{vcodec=MJPG,venc=ffmpeg{strict=1}}:standard{access=http{mime=image/jpeg},mux=mpjpeg,dst=xxxxx:25000}'
  </code></pre>
  
  <p>This is my main class:</p>
  
  <pre><code>NewCamera obj = new NewCamera();
  ...
  String mobile_command = "vlc -d -vvv " + camera.getUrl() + 
  " --no-audio --sout"
  + " '#transcode{vcodec=MJPG,venc=ffmpeg{strict=1}}:"
  + "standard{access=http{mime=image/jpeg},mux=mpjpeg,dst="
  + camera.getServerName() + ":"
  + camera.getMobilePort() + "}'";
  
  obj.executeCommand(mobile_command);
  logger.info("New mobile stream started");
  </code></pre>
  
  <p>and this is class for executing shell commands:</p>
  
  <pre><code>    private String executeCommand(String command) {
  
      StringBuffer output = new StringBuffer();
  
      Process p;
      try {
          p = Runtime.getRuntime().exec(command);
          logger.info(command);
          p.waitFor();
          BufferedReader reader = 
                          new BufferedReader(new InputStreamReader(p.getInputStream()));
  
                      String line = "";           
          while ((line = reader.readLine())!= null) {
              output.append(line + "\n");
  
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
      logger.info(output.toString());
      return output.toString();
  
  }
  </code></pre>
  
  <p>Process in Linux is created, but the stream is I will say "offline", because I cannot connect and get it. Executing the same command directly from command line in Linux works and creates stream.</p>
  
  <p>Any ideas?</p>