Trying to pipe an AudioInputStream I got from a libary to this process:
oggenc - -o wtf.ogg
via
AudioSystem.write(audio, AudioFileFormat::Type::WAVE, process.getOutputStream());
gives me the error:
IOException
stream length not specified
file: com.sun.media.sound.WaveFileWriter.write(WaveFileWriter.java)
line: 129
So it seems audio stream length needs to be specified. This is a 44.8 kHz stereo PCM format audio with no length specified. I got this from a library so I can’t modify their code. I tried creating another AudioInputStream from this stream, but I couldn’t find a proper length. So how can I specify the length ?
So, I found that you are reading
audiofrom somewhere unknown, and then trying to write it intoWAVformat. ButWAVformat requires to write header, which should contain file length. AnywayWaveFileWriterthrows exception if feeded by stream without knowing length.I guess your direction is
Java -> oggenc.So, you are to learn
oggencand know if it accepts headlessWAVstream. If so, then just pass youraudioto output stream, without processing withAudioSystem.write()which is for headedWAVsAccording to here http://www.linuxcommand.org/man_pages/oggenc1.html you are able to accept
RAWwithoggenc.