I've been struggling with this problem for quite some time now as it's my very first time doing an application related to streaming and I just can't figure out why. Here's the problem...
What I'm trying to achieve is to send a command's output as an input for the next one, which is basically what the pipe operator does. As I knew this couldn't be executed directly with Exec library from Apache Commons I started looking for ways to solve this. I've seen quite a few examples of similar things to this but none of them covers my situation: I have two Java applications separated, one is the main application and the second one is initialized by the first one. This second applications sends to the Standard Output bytes, which FFMPEG should receive. The code that I have so far is the following one... public void initStream(String path) { File file = new File(path); for (File s : file.listFiles()) { if (s.getName().equals("ffmpeg.exe")) { try { // Second app, supposedly, writes here. PipedOutputStream output = new PipedOutputStream(); DefaultExecutor executor = new DefaultExecutor(); //DefaultExecutor executorFFMPEG = new DefaultExecutor(); executor.setWorkingDirectory(file); //executor.setWorkingDirectory(file); CommandLine commandLine = new CommandLine(s.getParentFile().getAbsolutePath()); System.out.println("Path: " + commandLine.toString()); String executeMe = "java -jar streamer.jar"; commandLine = CommandLine.parse(executeMe); System.out.println("[testing] streamer about to launch."); executor.setStreamHandler(new PumpStreamHandler(output, null)); executor.execute(commandLine, new DefaultExecuteResultHandler()); System.out.println("[testing] streamer started."); PipedInputStream input = new PipedInputStream(); output.connect(input); String feedMe = "ffmpeg"; // more attributes here commandLine = CommandLine.parse(feedMe); System.out.println("[testing] ffmpeg about to launch."); executor.setStreamHandler(new PumpStreamHandler(null, null, input)); executor.execute(commandLine, new DefaultExecuteResultHandler()); System.out.println("[testing] ffmpeg started."); } catch (IOException e) { e.printStackTrace(); } } }} And the code for the second application (the zone where I send data to the stdout) is the following one. static OutputStream stdout = System.out; (more code and other things around here) try { line = (TargetDataLine) mixer.getLine(info); line.open(format); int bytesRead, CHUNK_SIZE = 4096; byte[] data = new byte[line.getBufferSize() / 5]; line.start(); while (true) { bytesRead = line.read(data, 0, CHUNK_SIZE); stdout.write(data, 0, bytesRead); stdout.flush(); } } catch (LineUnavailableException ex) { System.out.println("Line is unavailable."); ex.printStackTrace(); } At the moment, no communication seems to be made between both commands as ffmpeg isn't receiving anything. Hope you guys can tell what I'm missing out, or if I'm incorrectly working with the library thinking it works in a way when it works in another one.