javacv icon indicating copy to clipboard operation
javacv copied to clipboard

Audio Recording JavaCV

Open muguryildirim opened this issue 1 year ago • 5 comments

Hi everyone, I'm trying to record&play only audio but i keep getting the same error. org.bytedeco.javacv.FFmpegFrameRecorder$Exception: No audio output stream (Is audioChannels > 0 and has start() been called?) (For more details, make sure FFmpegLogCallback.set() has been called.)

recorder.recordSamples(sampleRate, numChannels, sBuff); //Error Line


muguryildirim avatar Sep 12 '22 09:09 muguryildirim

Please use record(Frame) instead of recordSamples().

saudet avatar Sep 12 '22 10:09 saudet

Well, the exception message may be on point.

Two things I would check: Has the recorder been started with start()? and When constructing the recorder have you set the audioChannel count?

Simply try setting the audiochannels with: recorder.setAudioChannels(2); Before starting the recorder.

Nycrera avatar Sep 12 '22 12:09 Nycrera

Hey @saudet , what you said yesterday, did not work. I ran a different code with using 'Mixer' and this is the result I got ( I'm currently working with Ubuntu OS )

"Line unsupported: interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame. little-endian.
TargetDataLine line = (TargetDataLine) mixer.getLine(dataLineinfo); // Cause of error.

muguryildirim avatar Sep 13 '22 05:09 muguryildirim

I've got it, thank you both.

muguryildirim avatar Sep 13 '22 06:09 muguryildirim

If you're trying to record audio from the microphone, there's a working example here: https://github.com/bytedeco/javacv/blob/master/samples/WebcamAndMicrophoneCapture.java

saudet avatar Sep 13 '22 10:09 saudet