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.
VCSimpleSessionis the easiest way to setup the encoder.There are a few different initializers for
VCSimpleSession:videoSizeis the desired resolution of your encoded video.fpsis 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.bpsis the video bitrate, in bits per second.useInterfaceOrientationis used to notify the encoder of device orientation changes.. Passing inYESwill tell the encoder to rotate the video when you rotate the device.cameraStateis used to start the encoder with your desired camera source. TheVCCameraStateenum has two values:VCCameraStateFrontandVCCameraStateBack.aspectModeis 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
previewViewproperty as a subview to someUIViewon 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.