mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-14 02:04:14 +01:00
Renamed files
This commit is contained in:
parent
17fa6aafee
commit
18cc364fff
3 changed files with 198 additions and 198 deletions
|
@ -1,54 +1,154 @@
|
||||||
namespace FFMpegCore.Enums
|
using FFMpegCore.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Enums
|
||||||
{
|
{
|
||||||
public enum CodecType
|
public enum FeatureStatus
|
||||||
{
|
{
|
||||||
Unknown = 0,
|
Unknown,
|
||||||
Video = 1 << 1,
|
NotSupported,
|
||||||
Audio = 1 << 2,
|
Supported,
|
||||||
Subtitle = 1 << 3,
|
|
||||||
Data = 1 << 4,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VideoCodec
|
public class Codec
|
||||||
{
|
{
|
||||||
public static Codec LibX264 => FFMpeg.GetCodec("libx264");
|
private static readonly Regex _codecsFormatRegex = new Regex(@"([D\.])([E\.])([VASD\.])([I\.])([L\.])([S\.])\s+([a-z0-9_-]+)\s+(.+)");
|
||||||
public static Codec LibVpx => FFMpeg.GetCodec("libvpx");
|
private static readonly Regex _decodersEncodersFormatRegex = new Regex(@"([VASD\.])([F\.])([S\.])([X\.])([B\.])([D\.])\s+([a-z0-9_-]+)\s+(.+)");
|
||||||
public static Codec LibTheora => FFMpeg.GetCodec("libtheora");
|
|
||||||
public static Codec Png => FFMpeg.GetCodec("png");
|
|
||||||
public static Codec MpegTs => FFMpeg.GetCodec("mpegts");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AudioCodec
|
public class FeatureLevel
|
||||||
{
|
{
|
||||||
public static Codec Aac => FFMpeg.GetCodec("aac");
|
public bool IsExperimental { get; internal set; }
|
||||||
public static Codec LibVorbis => FFMpeg.GetCodec("libvorbis");
|
public FeatureStatus SupportsFrameLevelMultithreading { get; internal set; }
|
||||||
public static Codec LibFdk_Aac => FFMpeg.GetCodec("libfdk_aac");
|
public FeatureStatus SupportsSliceLevelMultithreading { get; internal set; }
|
||||||
public static Codec Ac3 => FFMpeg.GetCodec("ac3");
|
public FeatureStatus SupportsDrawHorizBand { get; internal set; }
|
||||||
public static Codec Eac3 => FFMpeg.GetCodec("eac3");
|
public FeatureStatus SupportsDirectRendering { get; internal set; }
|
||||||
public static Codec LibMp3Lame => FFMpeg.GetCodec("libmp3lame");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class VideoType
|
internal void Merge(FeatureLevel other)
|
||||||
{
|
{
|
||||||
public static ContainerFormat MpegTs => FFMpeg.GetContinerFormat("mpegts");
|
IsExperimental |= other.IsExperimental;
|
||||||
public static ContainerFormat Ts => FFMpeg.GetContinerFormat("mpegts");
|
SupportsFrameLevelMultithreading = (FeatureStatus)Math.Max((int)SupportsFrameLevelMultithreading, (int)other.SupportsFrameLevelMultithreading);
|
||||||
public static ContainerFormat Mp4 => FFMpeg.GetContinerFormat("mp4");
|
SupportsSliceLevelMultithreading = (FeatureStatus)Math.Max((int)SupportsSliceLevelMultithreading, (int)other.SupportsSliceLevelMultithreading);
|
||||||
public static ContainerFormat Mov => FFMpeg.GetContinerFormat("mov");
|
SupportsDrawHorizBand = (FeatureStatus)Math.Max((int)SupportsDrawHorizBand, (int)other.SupportsDrawHorizBand);
|
||||||
public static ContainerFormat Avi => FFMpeg.GetContinerFormat("avi");
|
SupportsDirectRendering = (FeatureStatus)Math.Max((int)SupportsDirectRendering, (int)other.SupportsDirectRendering);
|
||||||
public static ContainerFormat Ogv => FFMpeg.GetContinerFormat("ogv");
|
}
|
||||||
public static ContainerFormat WebM => FFMpeg.GetContinerFormat("webm");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public enum Filter
|
public string Name { get; private set; }
|
||||||
{
|
public CodecType Type { get; private set; }
|
||||||
H264_Mp4ToAnnexB,
|
public bool DecodingSupported { get; private set; }
|
||||||
Aac_AdtstoAsc
|
public bool EncodingSupported { get; private set; }
|
||||||
}
|
public bool IsIntraFrameOnly { get; private set; }
|
||||||
|
public bool IsLossy { get; private set; }
|
||||||
|
public bool IsLossless { get; private set; }
|
||||||
|
public string Description { get; private set; } = null!;
|
||||||
|
|
||||||
public enum Channel
|
public FeatureLevel EncoderFeatureLevel { get; private set; }
|
||||||
{
|
public FeatureLevel DecoderFeatureLevel { get; private set; }
|
||||||
Audio,
|
|
||||||
Video,
|
internal Codec(string name, CodecType type)
|
||||||
Both
|
{
|
||||||
|
EncoderFeatureLevel = new FeatureLevel();
|
||||||
|
DecoderFeatureLevel = new FeatureLevel();
|
||||||
|
Name = name;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool TryParseFromCodecs(string line, out Codec codec)
|
||||||
|
{
|
||||||
|
var match = _codecsFormatRegex.Match(line);
|
||||||
|
if (!match.Success)
|
||||||
|
{
|
||||||
|
codec = null!;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = match.Groups[7].Value;
|
||||||
|
var type = match.Groups[3].Value switch
|
||||||
|
{
|
||||||
|
"V" => CodecType.Video,
|
||||||
|
"A" => CodecType.Audio,
|
||||||
|
"D" => CodecType.Data,
|
||||||
|
"S" => CodecType.Subtitle,
|
||||||
|
_ => CodecType.Unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
if(type == CodecType.Unknown)
|
||||||
|
{
|
||||||
|
codec = null!;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
codec = new Codec(name, type);
|
||||||
|
|
||||||
|
codec.DecodingSupported = match.Groups[1].Value != ".";
|
||||||
|
codec.EncodingSupported = match.Groups[2].Value != ".";
|
||||||
|
codec.IsIntraFrameOnly = match.Groups[4].Value != ".";
|
||||||
|
codec.IsLossy = match.Groups[5].Value != ".";
|
||||||
|
codec.IsLossless = match.Groups[6].Value != ".";
|
||||||
|
codec.Description = match.Groups[8].Value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
internal static bool TryParseFromEncodersDecoders(string line, out Codec codec, bool isEncoder)
|
||||||
|
{
|
||||||
|
var match = _decodersEncodersFormatRegex.Match(line);
|
||||||
|
if (!match.Success)
|
||||||
|
{
|
||||||
|
codec = null!;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = match.Groups[7].Value;
|
||||||
|
var type = match.Groups[1].Value switch
|
||||||
|
{
|
||||||
|
"V" => CodecType.Video,
|
||||||
|
"A" => CodecType.Audio,
|
||||||
|
"D" => CodecType.Data,
|
||||||
|
"S" => CodecType.Subtitle,
|
||||||
|
_ => CodecType.Unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
if (type == CodecType.Unknown)
|
||||||
|
{
|
||||||
|
codec = null!;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
codec = new Codec(name, type);
|
||||||
|
|
||||||
|
var featureLevel = isEncoder ? codec.EncoderFeatureLevel : codec.DecoderFeatureLevel;
|
||||||
|
|
||||||
|
codec.DecodingSupported = !isEncoder;
|
||||||
|
codec.EncodingSupported = isEncoder;
|
||||||
|
featureLevel.SupportsFrameLevelMultithreading = match.Groups[2].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
||||||
|
featureLevel.SupportsSliceLevelMultithreading = match.Groups[3].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
||||||
|
featureLevel.IsExperimental = match.Groups[4].Value != ".";
|
||||||
|
featureLevel.SupportsDrawHorizBand = match.Groups[5].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
||||||
|
featureLevel.SupportsDirectRendering = match.Groups[6].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
||||||
|
codec.Description = match.Groups[8].Value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
internal void Merge(Codec other)
|
||||||
|
{
|
||||||
|
if (Name != other.Name)
|
||||||
|
throw new FFMpegException(FFMpegExceptionType.Operation, "different codecs enable to merge");
|
||||||
|
|
||||||
|
Type |= other.Type;
|
||||||
|
DecodingSupported |= other.DecodingSupported;
|
||||||
|
EncodingSupported |= other.EncodingSupported;
|
||||||
|
IsIntraFrameOnly |= other.IsIntraFrameOnly;
|
||||||
|
IsLossy |= other.IsLossy;
|
||||||
|
IsLossless |= other.IsLossless;
|
||||||
|
|
||||||
|
EncoderFeatureLevel.Merge(other.EncoderFeatureLevel);
|
||||||
|
DecoderFeatureLevel.Merge(other.DecoderFeatureLevel);
|
||||||
|
|
||||||
|
if (Description != other.Description)
|
||||||
|
Description += "\r\n" + other.Description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
54
FFMpegCore/FFMpeg/Enums/Enums.cs
Normal file
54
FFMpegCore/FFMpeg/Enums/Enums.cs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
namespace FFMpegCore.Enums
|
||||||
|
{
|
||||||
|
public enum CodecType
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
Video = 1 << 1,
|
||||||
|
Audio = 1 << 2,
|
||||||
|
Subtitle = 1 << 3,
|
||||||
|
Data = 1 << 4,
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoCodec
|
||||||
|
{
|
||||||
|
public static Codec LibX264 => FFMpeg.GetCodec("libx264");
|
||||||
|
public static Codec LibVpx => FFMpeg.GetCodec("libvpx");
|
||||||
|
public static Codec LibTheora => FFMpeg.GetCodec("libtheora");
|
||||||
|
public static Codec Png => FFMpeg.GetCodec("png");
|
||||||
|
public static Codec MpegTs => FFMpeg.GetCodec("mpegts");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AudioCodec
|
||||||
|
{
|
||||||
|
public static Codec Aac => FFMpeg.GetCodec("aac");
|
||||||
|
public static Codec LibVorbis => FFMpeg.GetCodec("libvorbis");
|
||||||
|
public static Codec LibFdk_Aac => FFMpeg.GetCodec("libfdk_aac");
|
||||||
|
public static Codec Ac3 => FFMpeg.GetCodec("ac3");
|
||||||
|
public static Codec Eac3 => FFMpeg.GetCodec("eac3");
|
||||||
|
public static Codec LibMp3Lame => FFMpeg.GetCodec("libmp3lame");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoType
|
||||||
|
{
|
||||||
|
public static ContainerFormat MpegTs => FFMpeg.GetContinerFormat("mpegts");
|
||||||
|
public static ContainerFormat Ts => FFMpeg.GetContinerFormat("mpegts");
|
||||||
|
public static ContainerFormat Mp4 => FFMpeg.GetContinerFormat("mp4");
|
||||||
|
public static ContainerFormat Mov => FFMpeg.GetContinerFormat("mov");
|
||||||
|
public static ContainerFormat Avi => FFMpeg.GetContinerFormat("avi");
|
||||||
|
public static ContainerFormat Ogv => FFMpeg.GetContinerFormat("ogv");
|
||||||
|
public static ContainerFormat WebM => FFMpeg.GetContinerFormat("webm");
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Filter
|
||||||
|
{
|
||||||
|
H264_Mp4ToAnnexB,
|
||||||
|
Aac_AdtstoAsc
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Channel
|
||||||
|
{
|
||||||
|
Audio,
|
||||||
|
Video,
|
||||||
|
Both
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,154 +0,0 @@
|
||||||
using FFMpegCore.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace FFMpegCore.Enums
|
|
||||||
{
|
|
||||||
public enum FeatureStatus
|
|
||||||
{
|
|
||||||
Unknown,
|
|
||||||
NotSupported,
|
|
||||||
Supported,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Codec
|
|
||||||
{
|
|
||||||
private static readonly Regex _codecsFormatRegex = new Regex(@"([D\.])([E\.])([VASD\.])([I\.])([L\.])([S\.])\s+([a-z0-9_-]+)\s+(.+)");
|
|
||||||
private static readonly Regex _decodersEncodersFormatRegex = new Regex(@"([VASD\.])([F\.])([S\.])([X\.])([B\.])([D\.])\s+([a-z0-9_-]+)\s+(.+)");
|
|
||||||
|
|
||||||
public class FeatureLevel
|
|
||||||
{
|
|
||||||
public bool IsExperimental { get; internal set; }
|
|
||||||
public FeatureStatus SupportsFrameLevelMultithreading { get; internal set; }
|
|
||||||
public FeatureStatus SupportsSliceLevelMultithreading { get; internal set; }
|
|
||||||
public FeatureStatus SupportsDrawHorizBand { get; internal set; }
|
|
||||||
public FeatureStatus SupportsDirectRendering { get; internal set; }
|
|
||||||
|
|
||||||
internal void Merge(FeatureLevel other)
|
|
||||||
{
|
|
||||||
IsExperimental |= other.IsExperimental;
|
|
||||||
SupportsFrameLevelMultithreading = (FeatureStatus)Math.Max((int)SupportsFrameLevelMultithreading, (int)other.SupportsFrameLevelMultithreading);
|
|
||||||
SupportsSliceLevelMultithreading = (FeatureStatus)Math.Max((int)SupportsSliceLevelMultithreading, (int)other.SupportsSliceLevelMultithreading);
|
|
||||||
SupportsDrawHorizBand = (FeatureStatus)Math.Max((int)SupportsDrawHorizBand, (int)other.SupportsDrawHorizBand);
|
|
||||||
SupportsDirectRendering = (FeatureStatus)Math.Max((int)SupportsDirectRendering, (int)other.SupportsDirectRendering);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; private set; }
|
|
||||||
public CodecType Type { get; private set; }
|
|
||||||
public bool DecodingSupported { get; private set; }
|
|
||||||
public bool EncodingSupported { get; private set; }
|
|
||||||
public bool IsIntraFrameOnly { get; private set; }
|
|
||||||
public bool IsLossy { get; private set; }
|
|
||||||
public bool IsLossless { get; private set; }
|
|
||||||
public string Description { get; private set; } = null!;
|
|
||||||
|
|
||||||
public FeatureLevel EncoderFeatureLevel { get; private set; }
|
|
||||||
public FeatureLevel DecoderFeatureLevel { get; private set; }
|
|
||||||
|
|
||||||
internal Codec(string name, CodecType type)
|
|
||||||
{
|
|
||||||
EncoderFeatureLevel = new FeatureLevel();
|
|
||||||
DecoderFeatureLevel = new FeatureLevel();
|
|
||||||
Name = name;
|
|
||||||
Type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool TryParseFromCodecs(string line, out Codec codec)
|
|
||||||
{
|
|
||||||
var match = _codecsFormatRegex.Match(line);
|
|
||||||
if (!match.Success)
|
|
||||||
{
|
|
||||||
codec = null!;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = match.Groups[7].Value;
|
|
||||||
var type = match.Groups[3].Value switch
|
|
||||||
{
|
|
||||||
"V" => CodecType.Video,
|
|
||||||
"A" => CodecType.Audio,
|
|
||||||
"D" => CodecType.Data,
|
|
||||||
"S" => CodecType.Subtitle,
|
|
||||||
_ => CodecType.Unknown
|
|
||||||
};
|
|
||||||
|
|
||||||
if(type == CodecType.Unknown)
|
|
||||||
{
|
|
||||||
codec = null!;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
codec = new Codec(name, type);
|
|
||||||
|
|
||||||
codec.DecodingSupported = match.Groups[1].Value != ".";
|
|
||||||
codec.EncodingSupported = match.Groups[2].Value != ".";
|
|
||||||
codec.IsIntraFrameOnly = match.Groups[4].Value != ".";
|
|
||||||
codec.IsLossy = match.Groups[5].Value != ".";
|
|
||||||
codec.IsLossless = match.Groups[6].Value != ".";
|
|
||||||
codec.Description = match.Groups[8].Value;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
internal static bool TryParseFromEncodersDecoders(string line, out Codec codec, bool isEncoder)
|
|
||||||
{
|
|
||||||
var match = _decodersEncodersFormatRegex.Match(line);
|
|
||||||
if (!match.Success)
|
|
||||||
{
|
|
||||||
codec = null!;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = match.Groups[7].Value;
|
|
||||||
var type = match.Groups[1].Value switch
|
|
||||||
{
|
|
||||||
"V" => CodecType.Video,
|
|
||||||
"A" => CodecType.Audio,
|
|
||||||
"D" => CodecType.Data,
|
|
||||||
"S" => CodecType.Subtitle,
|
|
||||||
_ => CodecType.Unknown
|
|
||||||
};
|
|
||||||
|
|
||||||
if (type == CodecType.Unknown)
|
|
||||||
{
|
|
||||||
codec = null!;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
codec = new Codec(name, type);
|
|
||||||
|
|
||||||
var featureLevel = isEncoder ? codec.EncoderFeatureLevel : codec.DecoderFeatureLevel;
|
|
||||||
|
|
||||||
codec.DecodingSupported = !isEncoder;
|
|
||||||
codec.EncodingSupported = isEncoder;
|
|
||||||
featureLevel.SupportsFrameLevelMultithreading = match.Groups[2].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
|
||||||
featureLevel.SupportsSliceLevelMultithreading = match.Groups[3].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
|
||||||
featureLevel.IsExperimental = match.Groups[4].Value != ".";
|
|
||||||
featureLevel.SupportsDrawHorizBand = match.Groups[5].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
|
||||||
featureLevel.SupportsDirectRendering = match.Groups[6].Value != "." ? FeatureStatus.Supported : FeatureStatus.NotSupported;
|
|
||||||
codec.Description = match.Groups[8].Value;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
internal void Merge(Codec other)
|
|
||||||
{
|
|
||||||
if (Name != other.Name)
|
|
||||||
throw new FFMpegException(FFMpegExceptionType.Operation, "different codecs enable to merge");
|
|
||||||
|
|
||||||
Type |= other.Type;
|
|
||||||
DecodingSupported |= other.DecodingSupported;
|
|
||||||
EncodingSupported |= other.EncodingSupported;
|
|
||||||
IsIntraFrameOnly |= other.IsIntraFrameOnly;
|
|
||||||
IsLossy |= other.IsLossy;
|
|
||||||
IsLossless |= other.IsLossless;
|
|
||||||
|
|
||||||
EncoderFeatureLevel.Merge(other.EncoderFeatureLevel);
|
|
||||||
DecoderFeatureLevel.Merge(other.DecoderFeatureLevel);
|
|
||||||
|
|
||||||
if (Description != other.Description)
|
|
||||||
Description += "\r\n" + other.Description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue