本文整理汇总了C#中Nikse.SubtitleEdit.Logic.Subtitle.ChangeFrameRate方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.ChangeFrameRate方法的具体用法?C# Subtitle.ChangeFrameRate怎么用?C# Subtitle.ChangeFrameRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.Subtitle
的用法示例。
在下文中一共展示了Subtitle.ChangeFrameRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BatchConvertSave
internal static bool BatchConvertSave(string toFormat, string offset, Encoding targetEncoding, string outputFolder, int count, ref int converted, ref int errors, IList<SubtitleFormat> formats, string fileName, Subtitle sub, SubtitleFormat format, bool overwrite, string pacCodePage, double? targetFrameRate)
{
double oldFrameRate = Configuration.Settings.General.CurrentFrameRate;
try
{
// adjust offset
AdjustOffset(offset, sub);
// adjust frame rate
if (targetFrameRate.HasValue)
{
sub.ChangeFrameRate(Configuration.Settings.General.CurrentFrameRate, targetFrameRate.Value);
Configuration.Settings.General.CurrentFrameRate = targetFrameRate.Value;
}
bool targetFormatFound = false;
string outputFileName;
foreach (SubtitleFormat subtitleFormat in formats)
{
if (subtitleFormat.IsTextBased && (
subtitleFormat.Name.Replace(" ", string.Empty).Equals(toFormat, StringComparison.OrdinalIgnoreCase) ||
subtitleFormat.Name.Replace(" ", string.Empty).Equals(toFormat.Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase)))
{
targetFormatFound = true;
subtitleFormat.BatchMode = true;
outputFileName = FormatOutputFileNameForBatchConvert(fileName, subtitleFormat.Extension, outputFolder, overwrite);
Console.Write("{0}: {1} -> {2}...", count, Path.GetFileName(fileName), outputFileName);
if (subtitleFormat.IsFrameBased && !sub.WasLoadedWithFrameNumbers)
{
sub.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.CurrentFrameRate);
}
else if (subtitleFormat.IsTimeBased && sub.WasLoadedWithFrameNumbers)
{
sub.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
}
if ((subtitleFormat.GetType() == typeof(WebVTT) || subtitleFormat.GetType() == typeof(WebVTTFileWithLineNumber)))
{
targetEncoding = Encoding.UTF8;
}
if (subtitleFormat.GetType() == typeof(ItunesTimedText) || subtitleFormat.GetType() == typeof(ScenaristClosedCaptions) || subtitleFormat.GetType() == typeof(ScenaristClosedCaptionsDropFrame))
{
Encoding outputEnc = new UTF8Encoding(false);
using (var file = new StreamWriter(outputFileName, false, outputEnc))
{
file.Write(sub.ToText(subtitleFormat));
}
}
else if (targetEncoding == Encoding.UTF8 && (format.GetType() == typeof(TmpegEncAW5) || format.GetType() == typeof(TmpegEncXml)))
{
Encoding outputEnc = new UTF8Encoding(false);
using (var file = new StreamWriter(outputFileName, false, outputEnc))
{
file.Write(sub.ToText(subtitleFormat));
}
}
else
{
try
{
File.WriteAllText(outputFileName, sub.ToText(subtitleFormat), targetEncoding);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
errors++;
return false;
}
}
if (format.GetType() == typeof(Sami) || format.GetType() == typeof(SamiModern))
{
//var sami = (Sami)format;
foreach (string className in Sami.GetStylesFromHeader(sub.Header))
{
var newSub = new Subtitle();
foreach (Paragraph p in sub.Paragraphs)
{
if (p.Extra != null && p.Extra.Trim().Equals(className.Trim(), StringComparison.OrdinalIgnoreCase))
{
newSub.Paragraphs.Add(p);
}
}
if (newSub.Paragraphs.Count > 0 && newSub.Paragraphs.Count < sub.Paragraphs.Count)
{
string s = fileName;
if (s.LastIndexOf('.') > 0)
{
s = s.Insert(s.LastIndexOf('.'), "_" + className);
}
else
{
s += "_" + className + format.Extension;
}
outputFileName = FormatOutputFileNameForBatchConvert(s, subtitleFormat.Extension, outputFolder, overwrite);
//.........这里部分代码省略.........