-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turning On/Off Audio recording while Streaming #19
Comments
When you want to "stop audio recording", instead of actually stopping, simply keep recording, but record silence. That's the easiest way I see to accomplish that. |
Hi Samuel, Thanks for the help. I have already tried that scenario. In that case we are getting array of 0 for audioData and bufferedResult is also 0 , so it will not record those bytes. Also we have tried to remove if(bufferedResult > 0) from audioThread but no of use. It streams well in starting with audioStatus true , and also when we change the audio status to false (without audio.) But when I again change the audioStatus value to true , then it will go into if(bufferedresult >0 ) condition and record the audio with FFMpegFramerecorder object , but will not stream well. It will have a lot of delay in video with a lot of distortion. And no Audio at all. Please try this scenario. Thanks in Advance. |
That sounds like a problem with the Android API, does it not? |
I think not when you try to send mute data recorder accepts those values but when we again send the audio data then it doesn't behave properly. So there must be some mechanism which do not like the real audio data then and misbehaves. Following things I could not understand :
Any hint or help would be much appreciated. |
Like I said, do not stop "sending audio data", and that's it: It will work. The audio data acts as a timer, so it is not recommended to stop it. So, just do not stop sending audio data, and that's it. Please try it. |
Here's another option to manually recording silence: Set the volume to 0 through the Android API, and keep recording, of course. |
Hey Samuel , Thanks for your inputs , when you will set volume to 0 , it will set device speaker on silent mode and not device microphone , so it will keep recording data what is there coming from Mic ! By the way i found solution to this ! In FFMpegFrameRecorder , record(AVFrame frame) we are not sending Audio so I out condition as follows : /* write the compressed frame in the media file */
synchronized (oc) {
if(isAudio){
if (interleaved && video_st != null) {
if ((ret = av_interleaved_write_frame(oc, audio_pkt)) < 0) {
throw new Exception("av_interleaved_write_frame() error " + ret + " while writing interleaved audio frame.");
}
} else {
if ((ret = av_write_frame(oc, audio_pkt)) < 0) {
throw new Exception("av_write_frame() error " + ret + " while writing audio frame.");
}
}
}
} Hope that helps some one facing same issue |
In the same case when initially I initially(before starting streaming) make isAudio false , then it is creating issue. Hope I will find solution to this as well. See if you can reproduce the same. Thanks |
Can you find out if this solution is officially supported by the FLV format? If it is, then we'll add this change to |
Here is my solution for this: audioData = new short[bufferSize];
...
if (!recordingSound) {
for (int i = 0; i < audioData.length; i++) {
audioData[i] = 0;
}
} Works pretty well and doesn't seems to be too slow. |
@vaibhavbparikh Did you get the solution for this issue?Can you please post your solution. |
Hi,, Did anybody found the soundtion please resond i had struked from a week |
Solved it using Android API. public void toggleAudio(boolean enable) {
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if (audioManager.isMicrophoneMute() == !enable) {
if (enable) {
audioManager.setMicrophoneMute(false);
} else {
audioManager.setMicrophoneMute(true);
}
}
} Muting microphone will make AudioRecord produce zeroed buffers. |
Hi,
I am streaming video android to android with this library and it works great. However I am facing an issue in streaming only video without audio with RTMP.
In Record Activity , when I tries to stop audio recording with a flag and then again change value of flag and start audio recording , at that time I find streaming is not sync between audio and video and video streaming is having too much delay while audio stream is live.And both have too much glitches.
Any help would be much appreciated.
Following is my code
The text was updated successfully, but these errors were encountered: