Audio from video file not streaming via AVAssetReader + AudioCodec #1814
Unanswered
hiranmayee-ncompass
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I’m trying to stream a pre-recorded video file (MP4) with both video and audio via RTMP using HaishinKit v1.4.6. Video streams fine, but audio is never sent.
I’ve tried multiple approaches — using AVAssetReader with AudioCodec, and also tried streaming via filters-based audio transmission — but in both cases, the video works fine while audio remains silent.
Steps to reproduce:
Create an AVAssetReader from a local video file containing AAC audio.
Add AVAssetReaderTrackOutput for the video track — video works fine.
Add AVAssetReaderTrackOutput for the audio track:
Tried outputSettings: nil (keep AAC) → crash: AVAssetReaderOutput does not currently support compressed output.
Tried converting to PCM (kAudioFormatLinearPCM) and feeding it to AudioCodec → no crash, but audio never appears on RTMP server.
Set up AudioCodecDelegate and call encodeSampleBuffer on each PCM sample buffer. Delegate is called, but CMSampleBuffer conversion does not result in audio in RTMP stream.
Observed behavior:
Video streams successfully.
Audio does not appear in RTMP stream.
AudioCodec logs show a valid format description and bitrate, but no sound.
Sample logs:
inSourceFormat > AudioStreamBasicDescription(mSampleRate: 44100.0, mFormatID: 1819304813, ...)
formatDescription > Optional(<CMAudioFormatDescription 0x...>)
actualBitrate > 64000
Connected
Expected behavior:
Both video and audio from the local file should stream via RTMP.
Environment:
HaishinKit v1.4.6
iOS 17.5
MP4 video file with H.264 video and AAC audio
Beta Was this translation helpful? Give feedback.
All reactions