Java execute ffmpeg commands with (pipe) "... -f nut - | ffmpeg -i - ..." just hangs

I can't get this to run,because java just waits for ffmpeg. But ffmpeg doesn't give an input- nor an error stream. It just runs, but doing nothing.

The output of "System.out.println("command:.." insert into bash just runs fine as expected.So there is nothing wrong with the ffmpeg syntax.

Here's the code.

package mypackage;

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

 * @author test
public class ffmpeg_hang {

     * @param args the command line arguments
    public static void main(String[] args) throws IOException, InterruptedException {
        String INPUT_FILE="/path/to/media";
        String FFMPEG_PATH="/path/to/ffmpegFolder/";

            for(int i=0;(i+4)<40;i+=4){                
            String[] ffmpeg_pipe = new String[]{
                FFMPEG_PATH + "ffmpeg_4.1.1",
                "-ss",(i+""),"-t", "4",             
                "-i", INPUT_FILE,                                        
                "-ac", "1", "-acodec", "pcm_s16le", "-ar", "16000", 
                FFMPEG_PATH + "ffmpeg_4.1.1",
                "-lavfi", "showspectrumpic=s=128x75:legend=disabled:saturation=0:stop=8000",

            System.out.println("command: "+String.join(" ", ffmpeg_pipe));

            Process p;
            //ffmpe wav->pipe->spectrogra->pipe->java
            p = Runtime.getRuntime().exec(ffmpeg_pipe);

            StringBuilder Boxbuffer = new StringBuilder();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
            String line = "";

            while ((line = reader.readLine()) != null) {

            System.out.println("ffmpeg errors->> "+Boxbuffer.toString());

            BufferedImage image =;
            //do stuff with image