本文整理汇总了C#中MediaBrowser.MediaEncoding.Encoder.EncodingJob.ReportTranscodingProgress方法的典型用法代码示例。如果您正苦于以下问题:C# EncodingJob.ReportTranscodingProgress方法的具体用法?C# EncodingJob.ReportTranscodingProgress怎么用?C# EncodingJob.ReportTranscodingProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaBrowser.MediaEncoding.Encoder.EncodingJob
的用法示例。
在下文中一共展示了EncodingJob.ReportTranscodingProgress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTranscodeBeginning
private void OnTranscodeBeginning(EncodingJob job)
{
job.ReportTranscodingProgress(null, null, null, null);
}
示例2: ParseLogLine
private void ParseLogLine(string line, EncodingJob transcodingJob)
{
float? framerate = null;
double? percent = null;
TimeSpan? transcodingPosition = null;
long? bytesTranscoded = null;
var parts = line.Split(' ');
var totalMs = transcodingJob.RunTimeTicks.HasValue
? TimeSpan.FromTicks(transcodingJob.RunTimeTicks.Value).TotalMilliseconds
: 0;
var startMs = transcodingJob.Options.StartTimeTicks.HasValue
? TimeSpan.FromTicks(transcodingJob.Options.StartTimeTicks.Value).TotalMilliseconds
: 0;
for (var i = 0; i < parts.Length; i++)
{
var part = parts[i];
if (string.Equals(part, "fps=", StringComparison.OrdinalIgnoreCase) &&
(i + 1 < parts.Length))
{
var rate = parts[i + 1];
float val;
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val))
{
framerate = val;
}
}
else if (transcodingJob.RunTimeTicks.HasValue &&
part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
{
var time = part.Split(new[] { '=' }, 2).Last();
TimeSpan val;
if (TimeSpan.TryParse(time, _usCulture, out val))
{
var currentMs = startMs + val.TotalMilliseconds;
var percentVal = currentMs / totalMs;
percent = 100 * percentVal;
transcodingPosition = val;
}
}
else if (part.StartsWith("size=", StringComparison.OrdinalIgnoreCase))
{
var size = part.Split(new[] { '=' }, 2).Last();
int? scale = null;
if (size.IndexOf("kb", StringComparison.OrdinalIgnoreCase) != -1)
{
scale = 1024;
size = size.Replace("kb", string.Empty, StringComparison.OrdinalIgnoreCase);
}
if (scale.HasValue)
{
long val;
if (long.TryParse(size, NumberStyles.Any, _usCulture, out val))
{
bytesTranscoded = val * scale.Value;
}
}
}
}
if (framerate.HasValue || percent.HasValue)
{
transcodingJob.ReportTranscodingProgress(transcodingPosition, framerate, percent, bytesTranscoded);
}
}