Issue with appending SampleBuffer #1623
-
Hello, I am trying to append modified frames into stream (v2.0.0): func captureOutput(
_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer,
from connection: AVCaptureConnection
) {
guard let pixelBufferWide = CMSampleBufferGetImageBuffer(sampleBuffer), let stream = stream else {
return
}
if isPublishingStream {
Task {
//modify the pixelBuffer to CIImage and create a new sample buffer using same `CMSampleTimingInfo` as the original SampleBuffer
await stream.append(sampleBuffer) //<-- append to the stream
}
}
} this works great but after sometime, I start getting this warning error continously:
which is from this function In my backend I am running
I don't know what's going wrong, it happens anytime after 5-10 minutes of running the stream. I also tried with new // Get the current timestamp
let currentTime = CMClockGetTime(CMClockGetHostTimeClock())
// Create CMTime instances
let duration = CMTimeMake(value: 0, timescale: 0)
let presentationTimeStamp = CMTimeMake(value: currentTime.value, timescale: currentTime.timescale)
let decodeTimeStamp = CMTimeMake(value: 0, timescale: 0)
// Create CMSampleTimingInfo instance
let sampleTimingInfo = CMSampleTimingInfo(
duration: duration,
presentationTimeStamp: presentationTimeStamp,
decodeTimeStamp: decodeTimeStamp
)
if !CMTIME_IS_VALID(timingInfo.presentationTimeStamp) {
print("invalid pts")
return
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The appendSampleBuffer method is designed under the assumption that it processes output from MediaMixer. I can't determine its behavior in the current use case. Either solve it yourself or give up! |
Beta Was this translation helpful? Give feedback.
The appendSampleBuffer method is designed under the assumption that it processes output from MediaMixer. I can't determine its behavior in the current use case.
Either solve it yourself or give up!