Skip to content

Instantly share code, notes, and snippets.

@sushihangover
Created November 4, 2017 20:34
Show Gist options
  • Save sushihangover/e30e516a0081ea9abe493c6d07dfd24a to your computer and use it in GitHub Desktop.
Save sushihangover/e30e516a0081ea9abe493c6d07dfd24a to your computer and use it in GitHub Desktop.
AVAssetExportSession / Log all combinations of an asset with an AVFoundation file type (UTI) and an export preset if it is a valid combination
//var bundleUrl = NSBundle.MainBundle.GetUrlForResource("anemone_coralmorphologic", "mp4");
var bundleUrl = NSBundle.MainBundle.GetUrlForResource("addf8-Alaw-GW", "wav");
var asset = AVAsset.FromUrl(bundleUrl);
foreach (var fileType in Enum.GetValues(typeof(AVFileTypes)))
{
foreach (var preset in AVAssetExportSession.AllExportPresets)
{
var UTIConstant = ((AVFileTypes)(Enum.Parse(typeof(AVFileTypes), fileType.ToString()))).GetConstant();
var ok = await AVAssetExportSession.DetermineCompatibilityOfExportPresetAsync(
preset,
asset,
UTIConstant
);
Console.WriteLine($"{ok.ToString().PadLeft(5)}: {fileType.ToString().PadLeft(20)} : {UTIConstant} : {preset}");
}
}
@sushihangover
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment