Closed ghost closed 6 years ago
Thank for your issue. Please tell me your Mac model name.
Best regards.
This happens with the sample app. I have tried to use it in a custom app and I can repro the issue. It goes away if I say this (copy-paste from the README)
self.rtmpStream.recorderSettings = [
AVMediaTypeAudio: [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVSampleRateKey: 0,
AVNumberOfChannelsKey: 0,
],
AVMediaTypeVideo: [
AVVideoCodecKey: AVVideoCodecH264,
AVVideoHeightKey: 0,
AVVideoWidthKey: 0
],
]
Sorry, this is what actually did it
self.rtmpStream.audioSettings = [
"muted": false,
"bitrate": 32 * 1024,
// "profile",
"sampleRate": 44_100 // down,up sampleRate not supported yet #58
]
Closed cannot reproduce.
FYI I managed to reproduce this on my machine.
I managed to track this down to it failing when I use my virtual audio device which has 16 channels (it is called "blackhole", similar to the old "soundflower" tool). I believe the system libraries cannot create a converter from the 16 channels.
I temporarily solved this in a local build by: -modifying ChannelConfiguration enum, as it only supports up to 7 channels up to: "frontCenterAndFrontLeftAndFrontRightAndSideLeftAndSideRightAndBackLeftAndBackRightLFE" -In AudioConverter.swift, I forced the destination format to use 2 channels (instead of the 16 it was going to use based on the import source).
_inDestinationFormat = destination.audioStreamBasicDescription(inSourceFormat, sampleRate: sampleRate, channels: 2)
This obviously isn't an ideal solution. Maybe if the audio converter fails to convert, it should fallback to creating a format we know it can always convert to, or at least show some sort of error or something. I don't have much audio or audio dev knowledge - so I don't yet know if that is easily possible... but will do some reading!
I also ran into this crash and it can be reproduced by using Audio MIDI Setup and set the Built-in Microphone's format to 2 ch 16-bit Integer 96.0 kHz.
I think it will also crash for other formats that are 96.0 kHz.
Setting the rtmpStream.audioSettings sampleRate to 44_100 seems to fix it.
Ideally, it shouldn't crash the app since this error can be detected.
Hello i was wondering if you guys have found more info on this, i am trying to use this framework on iOS on an iPhone XR and am having the same problem, when i change the channels in _inDestinationFormat to 2 it works but if i leave it alone the app crashes with a failed to unwrap optional variable from _converter. I have also tried to make the rtmpStream.audioSettings: sampleRate to 44_100 with no luck.
I have this log line, File [Warn] [com.haishinkit.HaishinKit] [153] converter > 1718449215
After this log line the app crashes. Screenshot attached. So in short the "AudioConverterNewSpecific()" is returning null
If I modify in "AudioIOComponent.swift" the "extension AudioIOComponent: AVCaptureAudioDataOutputSampleBufferDelegate" and comment out the line "encoder.encodeSampleBuffer(sampleBuffer)"
then it does not crash but of course there is no audio in the published video