Closed arslan2012 closed 5 years ago
Yes. Always portrait :( It seems this behavior is a specification.
Isn't there anyway that can rotate the stream?
ok I made it work by adding a custom effect
final class RotationEffect: VisualEffect {
override func execute(_ image: CIImage, info: CMSampleBuffer?) -> CIImage {
guard #available(iOS 11.0, *),
let info = info,
let orientationAttachment = CMGetAttachment(info, key: RPVideoSampleOrientationKey as CFString, attachmentModeOut: nil) as? NSNumber,
let orientation = CGImagePropertyOrientation(rawValue: orientationAttachment.uint32Value) else {
return image
}
switch orientation {
case .left:
return image.oriented(.right)
case .right:
return image.oriented(.left)
default:
return image
}
}
}
but because RPVideoSampleOrientationKey is only available in ios11 or newer. this does not work on ios10, is there any other way we can get orientation in an VisualEffect? @shogo4405
@shogo4405 Any update on this? I'm also experiencing similar issues
@locorocoo No. I won't fix this issue.
@shogo4405 Any update on this? We many developers love this library. It's truly great and save lots of time. Could please help out regarding orientation?
@locorocoo No. I won't fix this issue.
The fact that this library doesn't handle orientation changes to landscape, and freezes when you rotate the device makes it unusable for replaykit 2.
ok I made it work by adding a custom effect
final class RotationEffect: VisualEffect { override func execute(_ image: CIImage, info: CMSampleBuffer?) -> CIImage { guard #available(iOS 11.0, *), let info = info, let orientationAttachment = CMGetAttachment(info, key: RPVideoSampleOrientationKey as CFString, attachmentModeOut: nil) as? NSNumber, let orientation = CGImagePropertyOrientation(rawValue: orientationAttachment.uint32Value) else { return image } switch orientation { case .left: return image.oriented(.right) case .right: return image.oriented(.left) default: return image } } }
but because RPVideoSampleOrientationKey is only available in ios11 or newer. this does not work on ios10, is there any other way we can get orientation in an VisualEffect? @shogo4405
I try this one but my stream become green after I open a landscape app :(
@mooncatventures-group do you have any solution for this?
Modify
AVCaptureVideoDataOutput.connection.videoOrientation
worked for me
Can you describe more detail ?
Modify
AVCaptureVideoDataOutput.connection.videoOrientation
worked for me
Can you describe more detail ?
Modify
AVCaptureVideoDataOutput.connection.videoOrientation
worked for meCan you describe more detail ?
Modify
AVCaptureVideoDataOutput.connection.videoOrientation
worked for meCan you describe more detail ?
Sorry, I'm wrong.
But maybe can you try with this one is make a singleton to hold videoDataOutput. And while device rotate we can modified this output.
At the line 328 https://github.com/shogo4405/HaishinKit.swift/blob/master/Sources/Media/VideoIOComponent.swift#L328
put: SingletonX.shared.addVideoOutput(output)
Device rotate:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: nil, completion: { [weak self] _ in
guard let self = self else { return }
guard let orientation = DeviceUtil.videoOrientation(by: UIApplication.shared.statusBarOrientation)
else { return }
SingletonX.shared.videoDataOutputs.values.forEach { (output) in
output.connections.forEach { (connection) in
connection.videoOrientation = orientation
}
}
})
}
ok I made it work by adding a custom effect
final class RotationEffect: VisualEffect { override func execute(_ image: CIImage, info: CMSampleBuffer?) -> CIImage { guard #available(iOS 11.0, *), let info = info, let orientationAttachment = CMGetAttachment(info, key: RPVideoSampleOrientationKey as CFString, attachmentModeOut: nil) as? NSNumber, let orientation = CGImagePropertyOrientation(rawValue: orientationAttachment.uint32Value) else { return image } switch orientation { case .left: return image.oriented(.right) case .right: return image.oriented(.left) default: return image } } }
but because RPVideoSampleOrientationKey is only available in ios11 or newer. this does not work on ios10, is there any other way we can get orientation in an VisualEffect? @shogo4405
I try this one but my stream become green after I open a landscape app :(
you should create CIContext at VideoIOComponent
ok I made it work by adding a custom effect
final class RotationEffect: VisualEffect { override func execute(_ image: CIImage, info: CMSampleBuffer?) -> CIImage { guard #available(iOS 11.0, *), let info = info, let orientationAttachment = CMGetAttachment(info, key: RPVideoSampleOrientationKey as CFString, attachmentModeOut: nil) as? NSNumber, let orientation = CGImagePropertyOrientation(rawValue: orientationAttachment.uint32Value) else { return image } switch orientation { case .left: return image.oriented(.right) case .right: return image.oriented(.left) default: return image } } }
but because RPVideoSampleOrientationKey is only available in ios11 or newer. this does not work on ios10, is there any other way we can get orientation in an VisualEffect? @shogo4405
I get the error EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=50 MB) when using this? Do you have a solution for that?
Stream is always portrait in Broadcast Upload Extension
I used the exact copy of Examples/iOS/Screencast
When I enter games that are landscape I expect the output to be landscape as well. But it's not.
I tried
both does not work