我正在尝试将输出从FFMPEG传输到Java中的AudioInputStream。这就是我到目前为止所做的:
Process process = new ProcessBuilder("ffmpeg", "-hide_banner", "no-stats", "-y", "-i", "song.wav", "-vn", "-q:a", "5", "-f", "mp3", "pipe:1").start();
AudioInputStream stream = AudioSystem.getAudioInputStream(process.getInputStream());
我以为我可以从进程中获取InputStream并从中创建和AudioInputStream,但这会导致以下异常:
Caused by: java.io.EOFException: null
at java.io.DataInputStream.readInt(DataInputStream.java:392)
at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:234)
at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:150)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1113)
at com.darichey.argentumbot.ArgentumBot.onReady(ArgentumBot.java:68)
我不确定如何正确地做到这一点。