VideoEffect doesn't run execute function #1504
-
Hi, first of all, thank you very much for this amazing library and keeping it up-to-date and supporting so many features out of the box. I have been playing around with this library for a couple of days but I can't seem to figure out why VideoEffect "execute" function never gets called. Here is an example: private class ContentModel: ObservableObject, IOStreamObserver, IOStreamDelegate {
@Published var stream:RTMPStream?
private let connection = RTMPConnection()
init() {
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(.playAndRecord, mode: .default, options: [.defaultToSpeaker, .allowBluetooth])
try session.setActive(true)
stream = RTMPStream(connection: connection)
stream?.videoOrientation = .portrait
stream?.sessionPreset = .hd1280x720
stream?.videoSettings.profileLevel = kVTProfileLevel_H264_Baseline_AutoLevel as String
stream?.videoSettings.videoSize = CGSize(width: 720, height: 1280)
stream?.videoSettings.bitRate = 4 * 1000 * 1000
stream?.frameRate = 30
stream!.attachAudio(AVCaptureDevice.default(for: .audio)) { _, error in
if let error {
print("errr 1: \(error.localizedDescription)")
}
}
stream!.attachCamera(AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)) { videoUnit, error in
if let error {
print("errr 2: \(error.localizedDescription)")
}
}
stream?.addObserver(self)
stream?.delegate = self
let _ = stream?.registerVideoEffect(SepiaEffect()) //here attempts to use Video effect
} catch(let err) {
print("error :\(err)")
}
}
//on button click
public func startStream() {
connection.connect("rtmp://192.168.1.38/live")
stream?.publish("hello")
}
} and now for the my video effect class: final class SepiaEffect: VideoEffect {
let filter = CIFilter.sepiaTone()
override init() {
print("sepiaeffect ") // this gets called successfully
}
override func execute(_ image: CIImage, info: CMSampleBuffer?) -> CIImage {
print("called here") //never gets called
filter.inputImage = image
filter.intensity = 0.9
return filter.outputImage!
}
} now talking about my true intention, I don't really need to use CIFilter in my actual project, as I just want to access There is another way where I can access func stream(_ stream: HaishinKit.IOStream, track: UInt8, didInput video: CMSampleBuffer) {
//do some processing and then:
stream?.append(newSampleBuffer, track: track)
| but this method causes the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you are using version 1.9.x, you need to specify the following value. The default is .passthrough.
|
Beta Was this translation helpful? Give feedback.
If you are using version 1.9.x, you need to specify the following value. The default is .passthrough.
stream.videoMixerSettings.mode = .offscreen