-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Audio is flickering while streaming to Youtube #554
Comments
I have expanded the PCM sampling buffer. Please try this commit |
Hi, Thanks for the reply. I did exactly what you have committed but I got BufferOverflowException
|
Hi, when I set mPcmBuffer byte array size in SrsPublisher.java to 16384 it gives me BufferOverflowException on bb.put(data, 0, size); in onGetPcmFrame(byte[] data, int size) method. But when I set mPcmBuffer size to 4096 it works fine. Please help. |
I am afraid 4096 is the limitation for microphone reading. |
Yes, you were right. 1 frame of a Stereo 48khz 16bit PCM stream is 4 bytes. So to fix the flickering of sound I changed the audio sampling rate to 16KHz and audio bit rate to 64kbps. Now sound is smooth while streaming. |
But the sampling frequency is 44.1K by default. |
Yes I changed it to 16000 and keep PCM buffer size to 4096 |
Same problem here. |
@st4ycool As @begeekmyfriend has mentioned it, change it to 16000 |
@begeekmyfriend 16khz doesnt really solve the problem. Here is stream with 16khz audio: https://www.youtube.com/watch?v=3ZXoZMTezmk @thakurmayu07 have you tried to go below 16k? My MediaCodec crashes if there are lower values |
It seems to me the issue is in AAC part. ADTS headers writes in some wrong way |
The ADTS writing code is here. Would you please show me anything wrong? |
I don't know what exactly wrong, I am trying to solve it for a while. Maybe they are written too often? |
ADTS is only for AAC-LC. It works all right for other players except Youtube. What kind of format of AAC for Youtube? AAC-HE or AAC-HEv2? |
No details provided by youtube... does it mean they accept any of them? |
@st4ycool @thakurmayu07 There are two solutions:
Note both of two solutions above are not compatible with some old flash media players. |
I tried streaming using both solutions, but it didn't solve issue. But I noticed something very strange: When I stream LIVE I hear audio flickering, but when youtube saves live stream to videos, it sounds OK. Why? I was streaming with 4g, and watching my live stream with wired 100mbps, so it's for sure not the bandwidth problem. It looks like youtube cant decode quickly enough? |
@st4ycool Maybe. Then what about 16K sample rate? |
yasea he v2 24000: youtube stream is not starting. What can be wrong with youtube when sample rate is 41.1? |
Never sound 41.1K, maybe the best choice is 48K for you... |
My bad, I meant 44.1khz, of course. |
@begeekmyfriend |
PCM is the format for voice sampling. |
@begeekmyfriend P.S. mp4 record sounds great, but it doesn't relate to AAC we are talking about, right? |
That's how I hear it on youtube stream LIVE: |
I forgot to tell you that ADTS is for conventional flash media player which has been abandoned by Youtube. |
@begeekmyfriend I can start youtube stream without ADTS, but it sounds same terrible when live. |
@st4ycool @begeekmyfriend Have you found any solution? Live stream with 16K sampling frequency also creates noise when audio is loud or multiple persons are talking. Also I observed that voice is cutting after every 2-3 seconds. |
@thakurmayu07 the thing is YouTube can't decode yasea's AAC fast enough to broadcast without audio lags (because auto-saved video is fine). So I think the only solution is to improve/replace the AAC part. I ve been streaming on facebook and there is no such problem like audio lags. |
As I can see in SrsEncoder class the audio codec is "audio/mp4a-latm". Can we change it to something else? |
You can try on your own. I think it is the issue of Youtube not the streaming. @st4ycool has said that streaming on Facebook is OK, right? |
Hi guys, I have found the issue. The library is fantastic, you just need to set latency to normal in YouTube admin panel. For more details : https://support.google.com/youtube/answer/7444635?hl=en |
@thakurmayu07 genius. How could it have been so easy? Wow! Thank you! I always thought it was something with audio codecs. Sorry, @begeekmyfriend , your codecs are shiny! |
Unfortunately I do not get access to Youtube quite conveniently in China you know it... |
@begeekmyfriend I totally forgot about China firewall. |
@st4ycool I was going in details about the requirements of video stream. There I found latency settings. I changed that from admin panel and boom! everything works like charm. @begeekmyfriend This library is awesome. As we understand the issue and come to know that library doesn't do anything wrong, you can close this thread now. |
@thakurmayu07 Better keep it open and let someone know it. |
@begeekmyfriend Yes, Sure. |
But I still need low latency and ultra low latency because of An ultra-low-latency stream further reduces the time it takes for video to be visible to viewers, making interaction with viewers easier.If I use normal latency long time. |
@thakurmayu07 , I am trying to stream to Youtube too, but it is not working. The logcat is no showing errors, so it seems to work fine. I think the problem is regarding the authentication. How do you push to the rtmp link being authenticated? Thanks in advance. |
long time I still not resolve audio flicker while using youtube with ultra low latency mode.any one help me. |
getting same trouble with AWS MediaLive service. When streaming from obs everything seems to be fine |
@KostyaBoss please check out the configuration settings on AWS MediaLive service and try more times. |
@begeekmyfriend thanks for quick responding. Maybe you know what exactly should I configure? Stub with this issue for 2 days right now |
@KostyaBoss In China it is hard to connect with AWS. The reason you know... |
@begeekmyfriend after some research I've found that the problem is in default google encoder. If I am setting force to harware everything goes fine. Btw it also fixes YouTube problem. But it works only on some devices (for ex Samsung) which have their own encoder. How do you think, is it possible to make some expanding and install custom encoder on runtime? |
@KostyaBoss Your issue is out of my knowledge but the information you provided might be very valuable for others. |
by searching and using some of the examples above.. audio is not fine. still same problem.. |
@KostyaBoss I found that useSoftEncoder in SrsEncoder class is false by default.
Is this the forcing that you're talking about? Any other ideas? N.B.: I'm trying to stream to AWS MediaLive service |
@axelbartolomei did you try enable it and test? |
@thakurmayu07 how to live stream to youtube>?? i cant please help me |
I can successfully live stream on youtube by using this library but the audio quality of uploaded video is not so good. It is flickering. How can I solve that?
The text was updated successfully, but these errors were encountered: