Basha Basha -3 years ago 46
Android Question

Getting Audio issue in Youtube Live streaming in android application

I am Developing an app in android live streaming. I am able to stream the live videos to the YouTube channel. But the problem was, getting no audio to that live streaming video.

My code will like below

private static final int frequency= 44100;
public void recordThread() {
Log.d(MainActivity.APP_NAME, "recordThread");

int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
int channelConfiguration = AudioFormat.CHANNEL_IN_STEREO;
int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
Log.i(MainActivity.APP_NAME, "AudioRecord buffer size: " + bufferSize);

// 16 bit PCM stereo recording was chosen as example.
AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, frequency, channelConfiguration,
audioEncoding, bufferSize);

// Make bufferSize be in samples instead of bytes.
bufferSize /= 2;
short[] buffer = new short[bufferSize];
while (!cancel) {
int bufferReadResult =, 0, bufferSize);
// Utils.Debug("bufferReadResult: " + bufferReadResult);
if (bufferReadResult > 0) {
frameCallback.handleFrame(buffer, bufferReadResult);
} else if (bufferReadResult < 0) {
Log.w(MainActivity.APP_NAME, "Error calling " + bufferReadResult);

Log.d(MainActivity.APP_NAME, "exit recordThread");

please some suggest me the solution to get out of this issue.

Answer Source

Search in github. There you will find a sample project(yasea) for audio encoding. Intermix those two projects, you will get the solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download