I'm integrating the VideoCore RTMP encoder into my app, but I'm having trouble starting a new encoding session. I see the VCSimpleSession
class, but how do I start the encoder and see the output?
VCSimpleSession *mySession = [[VCSimpleSession alloc] init];
I don't see the preview view. What am I doing wrong?
VideoCore uses simple and complex graphs.
VCSimpleSession
is the easiest way to setup the encoder.There are a few different initializers for
VCSimpleSession
:videoSize
is the desired resolution of your encoded video.fps
is the video frame rate. Depending on your server settings, you will probably want to make this 30, maybe even 60 if your server supports it.bps
is the video bitrate, in bits per second.useInterfaceOrientation
is used to notify the encoder of device orientation changes.. Passing inYES
will tell the encoder to rotate the video when you rotate the device.cameraState
is used to start the encoder with your desired camera source. TheVCCameraState
enum has two values:VCCameraStateFront
andVCCameraStateBack
.aspectMode
is used to set the aspect mode of your preview view. VCAspectMode has two values:VCAspectModeFit
(your sessions video preview should "aspect fit" into its parent view, andVCAscpectModeFill
(scale your video preview to fill its parent view).Use one of these initializers to create a new session. Make sure you retain the session after initialization as a property or ivar. After initialization, add the sessions's
previewView
property as a subview to someUIView
on your view controller.To connect to a server, use the
startRtmpSessionWithURL:
method on your session. To stop your encoder, callendRtmpSession
.Your full setup will probably look something like this:
When you're done:
I've done some work on the VideoCore sample app, you should check it out the sample view controller.