-1

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.

4

2 回答 2

3

所以,我找到了解决方案,这里是为那些追随我的人准备的。

第 1 步:创建一个 AVCaptureMovieFileOutput 实例。

var output = new AVCaptureMovieFileOutput();

第 2 步:创建一个 NSDictionary,在其中列出所需的电影输出设置的键和值。

var outputSettings = new NSDictionary(AVVideoCodecType.H264, AVVideo.CodecKey);

第 3 步:设置输出设置

output.SetOutputSettings(outputSettings, output.ConnectionFromMediaType(AVMediaType.Video))

这里的技巧是调用 ConnectionFromMediaType 方法,传入 AVCaptureMovieFileOutput 实例上的 MediaType,该实例返回一个 AVCaptureConnection。

于 2018-01-11T15:46:23.280 回答
0

我必须执行以下操作才能使其在 Xamarin.iOS 中工作:

var videoOutput = new AVCaptureMovieFileOutput();
var outputSettings = new NSDictionary(AVVideo.CodecKey, AVVideo.CodecH264);

videoOutput.SetOutputSettings(outputSettings, videoOutput.Connections[0]);
于 2019-12-05T10:58:52.973 回答