- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As the title suggests I want to record a stream holding the phone upright (portrait oriented) and have it cropped to landscape orientation, so the receiving end always sees a landscape video no matter the phones orientation. Coming from an Android project this was a relatively easy task, as I was able to access the VideoSource object which has adaptOutputFormat that did all of that for me.
OWT for iOS provides two ways (as I see it) to set up a stream. The OWTLocalStream class offers two initializers:
initWithConstratins:(OWTStreamConstraints*)constraints
error:(NSError**)outError;
The first option just needs you to pass simple constraints, such as resolution and fps, and all the rest happens under the hood automatically.
initWithMediaStream:(RTCMediaStream*)mediaStream
source:(OWTStreamSourceInfo*)source;
The second option gives you a little more possibilities as you provide the media stream yourself and have a lot more possibilities (you even have access to the VideoSource object). Unfortunately I was not able to get this option to work and I was not able to find any working examples on the internet.
Let me post what I have so far... maybe you can help. Or maybe there is another solution to my initial problem.
let peerConnectionFactory = RTCPeerConnectionFactory.sharedInstance()
if let peerConnectionFactory = peerConnectionFactory {
let videoSource = peerConnectionFactory.videoSource()
let capturer = RTCCameraVideoCapturer.init(delegate: videoSource)
let videoTrack = peerConnectionFactory.videoTrack(with: videoSource, trackId: "testVideo")
let audioTrack = peerConnectionFactory.audioTrack(withTrackId: "testAudio")
let mediaStream = peerConnectionFactory.mediaStream(withStreamId: "testStream")
mediaStream.addVideoTrack(videoTrack)
mediaStream.addAudioTrack(audioTrack)
let sourceInfo = OWTStreamSourceInfo()
sourceInfo.audio = .mic
sourceInfo.video = .camera
let stream = OWTLocalStream.init(mediaStream: mediaStream, source: sourceInfo)
let publishOptions = OWTPublishOptions.init()
let opusParameter = OWTAudioCodecParameters.init()
opusParameter.name = OWTAudioCodec.opus
let audioEncodingParameter = OWTAudioEncodingParameters.init()
audioEncodingParameter.codec = opusParameter
publishOptions.audio = [audioEncodingParameter]
let h264Parameter = OWTVideoCodecParameters.init()
h264Parameter.name = OWTVideoCodec.H264
let videoEncodingParamter = OWTVideoEncodingParameters.init()
videoEncodingParamter.codec = h264Parameter
publishOptions.video = [videoEncodingParamter]
let device = AVCaptureDevice.default(for: .video)
self.conferenceClient!.publish(stream, with: publishOptions, onSuccess: { publication in
capturer.startCapture(with: device!, format: device!.activeFormat, fps: 24)
self.streamObserver?.clientStreamPublished(publication)
}, onFailure: { error in
self.streamObserver?.clientStreamPublishedFailed(error)
})
}
Link Copied

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page