Reputation: 980
Need help setting the video codec to H.264 when using an AVCaptureMovieFileOutput instance.
Looking at the Apple Docs I see that they support a struct of type AVVideoCodecType, however, I'm not seeing this in the Xamarin.iOS Docs.
Help would be much appreciated as I don't want to have to rewrite the Video Capture logic to use AVAssetWriter.
Upvotes: -1
Views: 1836
Reputation: 1118
I had to do the following to get this to work in Xamarin.iOS:
var videoOutput = new AVCaptureMovieFileOutput();
var outputSettings = new NSDictionary(AVVideo.CodecKey, AVVideo.CodecH264);
videoOutput.SetOutputSettings(outputSettings, videoOutput.Connections[0]);
Upvotes: 0
Reputation: 980
So, I found the solution and here it is for those who come after me.
Step 1: Create a AVCaptureMovieFileOutput instance.
var output = new AVCaptureMovieFileOutput();
Step 2: Create a NSDictionary where you list the keys and values of the Movie's Output settings you want.
var outputSettings = new NSDictionary(AVVideoCodecType.H264, AVVideo.CodecKey);
Step 3: Set the output Settings
output.SetOutputSettings(outputSettings, output.ConnectionFromMediaType(AVMediaType.Video))
The trick here is to call ConnectionFromMediaType Method passing in the MediaType on your AVCaptureMovieFileOutput instance which returns an AVCaptureConnection.
Upvotes: 3