在iOS xamarin中将视频从mov转换为MP4

时间:2018-06-01 06:46:10

标签: ios xamarin xamarin.ios

如何在xamarin iOS中将mov转换为MP4。我正在使用AVAssetExportSession。最后几秒的视频被关闭..任何解决方案都可以保留完整的视频时长。

这是我的代码。

var basePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        var inputFilePath = Path.Combine(basePath, Path.ChangeExtension(_vm.Model.AnswerName, "mov"));
        var outputFilePath = Path.Combine(basePath, _vm.Model.AnswerName);

        var asset = AVAsset.FromUrl(NSUrl.FromFilename(inputFilePath));

        AVAssetExportSession export = new AVAssetExportSession(asset, AVAssetExportSession.PresetHighestQuality);

        export.OutputUrl = NSUrl.FromFilename(outputFilePath);
        export.OutputFileType = AVFileType.Mpeg4;
        export.ShouldOptimizeForNetworkUse = true;

   try
        {
            export.ExportTaskAsync().Wait();


        }
        catch (Exception ex)
        {

            System.Diagnostics.Debug.WriteLine(ex);
        }

        var fileHelper = new FileHelper();

        // If Export successful then delete the MOV file
        if (fileHelper.FileExists(_vm.Model.AnswerName))
        {
            fileHelper.DeleteFile(Path.ChangeExtension(_vm.Model.AnswerName, "mov"));
        }

0 个答案:

没有答案