本文整理汇总了C#中System.Text.RegularExpressions.Match.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Match.Count方法的具体用法?C# Match.Count怎么用?C# Match.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Match
的用法示例。
在下文中一共展示了Match.Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var options = new Options();
if (!CommandLine.Parser.Default.ParseArguments(args, options))
{
throw new Exception("Couldn't parse settings");
}
//System.Diagnostics.Debugger.Break();
//try
//{
// Environment.SetEnvironmentVariable("FC_CONFIG_DIR", ".\\", EnvironmentVariableTarget.Machine);
// Environment.SetEnvironmentVariable("FC_CONFIG_FILE", ".\\fonts.conf", EnvironmentVariableTarget.Machine);
//}
//catch
//{ }
string tmp;
//string command = "-i \"{0}\" -s 740x416 -c:v libx264 -crf:v 26 -preset:v medium -ac 1 -c:a aac -strict -2 -cutoff 15000 -b:a 64k \"{1}\"";
string command = "-i \"{0}\" -s 740x416 -c:v libx264 -crf:v 26 -preset:v veryfast -ac 1 -c:a aac -strict -2 -cutoff 15000 -b:a 64k \"{1}\"";
//command = "-y -i \"{0}\" -map 0:v -map 0:{3} -loglevel verbose -c:v libx264 -crf:v 21 -preset:v fast -ac 1 -c:a copy -vf \"ass='{2}'\" \"{1}\""; //no resizing for mobile, just hardsubbing
command = "-y -i \"{0}\" -s {4} -map 0:v -map 0:{3} -c:v libx264 -crf:v 26 -preset:v veryfast -ac 1 -c:a libfdk_aac -b:a 64k -strict -2 -cutoff 15000 -vf \"ass='{2}'\" \"{1}\"";
string commandnoSubs = "-y -i \"{0}\" -s {3} -map 0:v -map 0:{2} -c:v libx264 -crf:v 26 -preset:v veryfast -ac 1 -c:a libfdk_aac -b:a 64k -strict -2 -cutoff 15000 \"{1}\"";
List<string> cleanup = new List<string>();
int count = 0;
foreach (var item in options.InputFiles)
{
FileInfo fileinfo = new FileInfo(item);
var dir = Path.GetDirectoryName(item);
if (dir == "")
dir = ".";
List<string> fileParts = item.Split('.').ToList();
string filename = "";
fileParts.Insert(fileParts.Count - 1, "MOBILE");
fileParts.RemoveAt(fileParts.Count - 1);
fileParts.Add("mp4");
filename = string.Join(".", fileParts.ToArray());
//string mkvmergeOutput = ExecuteAndReturn("mkvmerge", "--identify \"" + item + "\"");
//string[] mkvmergeLines = mkvmergeOutput.Split(new string[]{System.Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
//int SubtitleTrack = -1;
//string subFormat = "";
string subtitlefile = filename + ".ass";
string outputFileName = filename;
if (options.OutputFiles.Length >= count + 1)
{
outputFileName = options.OutputFiles[count];
}
//foreach (var line in mkvmergeLines)
//{
// if (line.IndexOf("TEXT/SSA") != -1 || line.IndexOf("TEXT/SRT") != -1 || line.IndexOf("TEXT/ASS") != -1)
// {
// if (line.IndexOf("TEXT/SSA") != -1)
// subFormat = "SSA";
// if (line.IndexOf("TEXT/ASS") != -1)
// subFormat = "ASS";
// if (line.IndexOf("TEXT/SRT") != -1)
// subFormat = "SRT";
// SubtitleTrack = int.Parse(line.Substring(9, line.IndexOf(':') - 9));
// break;
// }
//}
//Regex r = new Regex("Attachment ID ([0-9]*): type 'application/.+font', size [0-9]+ bytes, file name '(.+)'");
////System.Diagnostics.Debugger.Break();
//foreach (var line in mkvmergeLines)
//{
// var result = r.Match(line);
// if (result.Success)
// {
// ExecuteAndReturn("mkvextract", string.Format("attachments \"{0}\" {1}:\"{2}\"", item, result.Groups[1].Value, result.Groups[2].Value));
// if (!File.Exists("C:\\tools\\ffmpeg\\fonts\\" + result.Groups[2].Value))
// File.Copy(result.Groups[2].Value, "C:\\tools\\ffmpeg\\fonts\\" + result.Groups[2].Value);
// cleanup.Add(result.Groups[2].Value);
// }
//}
tmp = ExecuteAndReturn("ffmpeg", string.Format(" -i \"{0}\"", item));
Regex r = new Regex("Input #0, .+?, from '" + Regex.Escape(item) + "':.+", RegexOptions.Singleline);
var result = r.Match(tmp);
tmp = result.Value;
r = new Regex("\\s{4}Stream #0:(?<TrackID>[0-9])+(\\((?<language>[^()]+)\\))?: (?<Type>Video|Audio|Subtitle|Attachment):[^\\r\\n]+\\r\\n(\\s{4}Metadata:\\r\\n\\s{6}filename\\s*:\\s*(?<FileName>[^\\r\\n]+)\\r\\n\\s{6}mimetype[^\\r\\n]+)?", RegexOptions.Singleline);
var resultCollection = r.Matches(tmp);
//Stream #0:0: Video: mpeg4 (XVID / 0x44495658), yuv420p, 640x480, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
//Stream #0:1(English[eng]): Audio: vorbis, 48000 Hz, stereo, fltp, 176 kb/s
//Stream #0:2(Japanese[jpn]): Audio: vorbis, 48000 Hz, stereo, fltp, 176 kb/s
//Stream #0:3(English[eng]): Subtitle: text
Match[] a = new Match[resultCollection.Count];
resultCollection.CopyTo(a, 0);
//.........这里部分代码省略.........