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 issue while transmitting. WebRTC. 4 channels #1289
Comments
The fix made in #1208 was for the case of 2-channel stereo. It might not work correctly for 3 channels or more. It seems like the iPhone 14 Pro is detecting 4 channels. |
Thanks for your reply @shogo4405 😊 I tried to force the AVAudioSession preferredIntputChannels to 1 or 2 using the setPreferredIntputChannels. So if I have to deal with 4-channels samples. what would be the best way to deal with it inside Haishinkit from your point of view ? |
You can try to discard channels within HK by providing a channel map. Negative value is used to discard an input channel:
|
Also the format descriptions that show on the screenshots look like "input" audio format. HK does conversion from PCM to compressed AAC format. The "output" format can be found in |
I've made significant changes to the internal audio processing in #1294. There's a possibility that it brings improvements. You can test it on the 'main' branch. |
I'm currently testing it and will tell you if there is improvements or not. |
Hi, I took some time to make several tests and waited for the iPhone 15 Pro release to confirm what I thought. As @leo150 mentioned, I tried to set audioSettings as below:
But it seems it doesn't have any effect on the audio. I also tried to update the library to use the latest code but it also doesn't seem to change anything. One piece of info I may provide you is that my AVAudioSession is using If I'm using AirPods or so, I use I also tried, when AVAudioSession change, to detach audio from rtmpStream and then reattach it, thinking that maybe it'd get new settings from incoming audio and set things up in a different way that'd be able to handle audio. But it doesn't work either. Are all of these info giving you any piece of idea or advice for me ? |
@shogo4405 @leo150 @CedricEugeni unfortunately we're facing the very same issue. What we've found is that the crackling sound is due to recurring silences or missing samples in the audio. Here are Audacity screenshots : Here you can see the recurring silences or missing samples. What we've found is that there's exactly 1024 samples between each recurring silences or missing samples. Therefore we concluded they are either at the beginning or at the end of each audio frame. We've tried to dig into the resampler and ring buffer but we couldn't find anything that would help us determine where this could come from. Do the screenshots and/or explanation make you think of anything ? Any help would be greatly appreciated 👍 Cheers |
|
Unfortunately there doesn't seem to be any information in the Do you have any thought on that? Or any idea on how we could go about fixing this issue?
|
Code is here. I'm not interested in the byte sequence of the CMSampleBuffer. I want to know the PTS (Presentation Time Stamp). Please provide the dump result. |
Here's our dump. I had to add a ".zip" extension so that Github let me upload it. Is it what you were looking for? |
Thanks for clearing that out 👍 Is there anything this lib or we could do to fix the issue? 🤔 |
Maybe this fix could have improved it. If you don't mind, I would like to ask you to test it. #1310 |
First off, thanks for providing a fix to test ❤️ Here's how it went: we had 2 problems
Your patch fixed the second problem but not the first one. Therefore I think it would be a good idea to merge it, but we still have an issue with the crackling sound. |
I confirmed that the issue can be reproduced when launching Example.app while having a Discord call.
|
That looks pretty good indeed! Let us know whether you need any help testing a fix 👍 |
It's being discussed on the developer forum. It seems like there is blank data at the beginning like this, which can disrupt calculations such as PTS (Presentation Time Stamp). When I remove the blank data, it sounds correct.
|
Did you manage to find a way to automatically remove that annoying blank data based on the CMBlockBuffer information (like the |
I haven't found a way to retrieve it from the parameters. |
@shogo4405 what are you looking to do regarding this issue? We're still experiencing crackling noise. Cheers |
Are you saying that it's still occurring in the post-fix branch at https://github.com/shogo4405/HaishinKit.swift/pull/1310/files? If so, I won't be able to fix it because I can't reproduce it in my environment. |
With your post-fix branch, we're experiencing:
Random crackling noises may be due to audio/video getting unsynchronized 🤔 |
The direction of the modifications seems promising. I believe that with extensive debugging, improvements can be achieved. On the other hand, I'm currently allocating my time for the 1.7.0 release, so the subsequent fixes will have to wait. |
OK thanks for the clarifications 👍 we're available if you need help to debug or test improvements whenever you go back to that issue. Thanks again ❤️ |
As a temporary solution, I disabled voice processing in voice_processing_audio_unit.mm:76 and the issue is gone. In our case the voice processing isn't a requirement.
I don't have time to create a reproducible example, but ideally we need to add a voice processing unit to the HaishinKit example app so the issue could looked into. |
Describe the bug
Hi,
On some devices, there is a strange audio behavior seems like audio is cutting in and out quickly.
I could reproduce it on iPhone 12 Pro on iOS 16.xx and iPhone 14 Pro on iOS 16.xx and 17.0 beta.
Maybe this is a duplicate from this issue :
#1208
But I read the thread and a PR in late July should've fixed this.
I made a view to add some technical information.
Chart is representing numSamples in AudioCode.swift file in
public func appendSampleBuffer(_ sampleBuffer: CMSampleBuffer, offset: Int = 0)
method.You can see on iPhone 13 mini that I either have a steady 1024 numSamples value or something that bounce between 2 values like for example 955 & 69 (my example makes the sum of it 1024 but I'm not sure that's the case).
You can also see on the iPhone 14, chart is kinda crazy and not looking as steady as the iPhone 13 min.
(On these screenshots, other info is coming from the same place where numSamples values come from, where I display the
inSourceFormat
information.)To Reproduce
Start a RTMPStream for the first time, wait for mic authorization request, then accept it and record.
I reproduce it doing this on iPhone 12 Pro. On iPhone 14 Pro, it happens every time.
Expected behavior
Audio should be fine.
Version
latest from main branch
Smartphone info.
Additional context
I have a WebRTC connection to display the user what is being streamed online (RTMP stream is sent to the cloud to render a streaming scene, then WebRTC feed shows the user this streaming rendering that can be broadcasted on Twitch and everything afterwards)
WebRTC connection tends to change AudioSession, so I made sure to attachAudio on my RTMPStream only after WebRTC connection is done playing with audio session to try to avoid issues.
Screenshots
Relevant log output
No response
The text was updated successfully, but these errors were encountered: