FFMpegCore/FFMpegCore/FFMpeg/Enums/ContainerFormat.cs
Malte Rosenbjerg 7457168c44 Cleanup
Former-commit-id: df0205fb11
2021-03-07 00:26:08 +01:00

47 lines
No EOL
1.4 KiB
C#

using System.Text.RegularExpressions;
namespace FFMpegCore.Enums
{
public class ContainerFormat
{
private static readonly Regex FormatRegex = new Regex(@"([D ])([E ])\s+([a-z0-9_]+)\s+(.+)");
public string Name { get; private set; }
public bool DemuxingSupported { get; private set; }
public bool MuxingSupported { get; private set; }
public string Description { get; private set; } = null!;
public string Extension
{
get
{
if (GlobalFFOptions.Current.ExtensionOverrides.ContainsKey(Name))
return GlobalFFOptions.Current.ExtensionOverrides[Name];
return "." + Name;
}
}
internal ContainerFormat(string name)
{
Name = name;
}
internal static bool TryParse(string line, out ContainerFormat fmt)
{
var match = FormatRegex.Match(line);
if (!match.Success)
{
fmt = null!;
return false;
}
fmt = new ContainerFormat(match.Groups[3].Value)
{
DemuxingSupported = match.Groups[1].Value != " ",
MuxingSupported = match.Groups[2].Value != " ",
Description = match.Groups[4].Value
};
return true;
}
}
}