Using HaishinKit (via SPM) to live stream video from VisionCamera to Cloudflare. Audio works using MediaMixer with attachAudio(), but when sending video frames using RTMPStream.append(), the await hangs indefinitely
#1825
Closed
ryanhall00
started this conversation in
General
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.
-
My iOS Setup:
Code:
Swift
// Stream setup (working)
stream = RTMPStream(connection: connection)
var videoSettings = VideoCodecSettings(
videoSize: .init(width: 1280, height: 720),
bitRate: 4_800_000,
profileLevel: kVTProfileLevel_H264_Main_4_1 as String,
scalingMode: .letterbox,
maxKeyFrameIntervalDuration: 3
)
try? await stream?.setVideoSettings(videoSettings)
// Audio works (using MediaMixer)
try await mixer.attachAudio(audioDevice, track: 0)
await mixer.addOutput(stream!)
await mixer.startCapturing()
await mixer.startRunning()
// Publish succeeds
try await stream?.publish(streamKey)
// Logs show: "NetStream.Publish.Start - Stream is LIVE!"
// Video append HANGS HERE
@objc public func appendVideo(_ sampleBuffer: CMSampleBuffer) {
Task {
await streamSetupTask?.value // Wait for setup
}
}
Observations
✅ Stream connects and publishes successfully
✅ Audio works (MediaMixer → stream → Cloudflare)
✅ appendVideo() called at 30fps with valid CMSampleBuffer
❌ stream?.append() never completes (no success, no error, just hangs)
❌ No frames reach VideoToolbox encoder
❌ Cloudflare shows FPS = 0
Questions
Is RTMPStream.append() the correct method for external video frames?
Do I need to configure the stream differently for external sources?
Does the stream need to be in a specific state before calling append?
Should I NOT use MediaMixer at all if using stream.append() for video?
What I've Tried
✅ Read HaishinKit docs, troubleshooting tips, example code, similar discussions, etc.
✅ Verified stream is not nil
✅ Waited for publish to complete before appending
✅ Verified CMSampleBuffer is valid video (kCMMediaType_Video)
❌ Still hangs indefinitely
Any guidance on the correct way to send external video frames to RTMPStream would be greatly appreciated! Thank you!
Beta Was this translation helpful? Give feedback.
All reactions