本文整理汇总了C#中System.VideoInfo.AddAlternativeMetadataTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C# VideoInfo.AddAlternativeMetadataTimestamp方法的具体用法?C# VideoInfo.AddAlternativeMetadataTimestamp怎么用?C# VideoInfo.AddAlternativeMetadataTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.AddAlternativeMetadataTimestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInfo
protected override MediaInfo GetInfo(string fullFilename)
{
VideoInfo result = new VideoInfo();
Tool tool = new Tool(Tool.Which.FFprobe, new string[] { "-hide_banner", "-print_format xml=fully_qualified=1", "-show_format", "-show_streams", "-show_error", Tool.Escape(fullFilename) }, new int[] { 0 });
Tool.Result toolResult = tool.Run();
if (toolResult.Error != null)
{
throw toolResult.Error;
}
FFprobe.ffprobeType ffp;
using (MemoryStream ms = new MemoryStream())
{
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(toolResult.StdOut);
ms.Write(bytes, 0, bytes.Length);
ms.Position = 0L;
using (XmlReader xr = XmlReader.Create(ms))
{
ffp = (MediaData.FFprobe.ffprobeType)FFmpegVideoProcessor.FFProbeDeserializer.Deserialize(xr);
}
}
if (ffp.error != null)
{
throw new Exception([email protected]);
}
if (ffp.format.tag != null)
{
foreach (FFprobe.tagType tag in ffp.format.tag)
{
switch (tag.key)
{
case "creation_time":
DateTime? dt = FFmpegVideoProcessor.ParseCreationTimeTag(tag.value);
if (!dt.HasValue)
{
throw new Exception(string.Format(i18n.Invalid_tag_X_value_V, tag.key, tag.value));
}
result.AddAlternativeMetadataTimestamp(string.Format(i18n.GlobalTag_X, tag.key), dt.Value);
break;
case "location":
case "location-eng":
Position position = FFmpegVideoProcessor.ParseLocationTag(tag.value);
if (position == null)
{
throw new Exception(string.Format(i18n.Invalid_tag_X_value_V, tag.key, tag.value));
}
if (result.Position == null || (result.Position.Lat == 0M && result.Position.Lng == 0M))
{
result.Position = position;
}
else if (position.Lat != 0M && position.Lng != 0M && (position.Lat != result.Position.Lat || position.Lng != result.Position.Lng))
{
throw new Exception(i18n.Multiple_GPS_positions_found);
}
break;
}
}
}
if (ffp.streams != null)
{
foreach (FFprobe.streamType stream in ffp.streams)
{
switch (stream.codec_type)
{
case "audio":
result.AudioTracks++;
break;
case "video":
result.VideoTracks++;
break;
default:
throw new Exception(string.Format(i18n.Unsupported_stream_type_X, stream.codec_type));
}
if (stream.tag != null)
{
foreach (FFprobe.tagType tag in stream.tag)
{
switch (tag.key)
{
case "creation_time":
DateTime? dt = FFmpegVideoProcessor.ParseCreationTimeTag(tag.value);
if (!dt.HasValue)
{
throw new Exception(string.Format(i18n.Invalid_tag_X_value_V, tag.key, tag.value));
}
result.AddAlternativeMetadataTimestamp(string.Format(i18n.StreamTag_X, tag.key), dt.Value);
break;
case "location":
case "location-eng":
Position position = FFmpegVideoProcessor.ParseLocationTag(tag.value);
if (position == null)
{
throw new Exception(string.Format(i18n.Invalid_tag_X_value_V, tag.key, tag.value));
}
if (result.Position == null || (result.Position.Lat == 0 && result.Position.Lng == 0))
{
result.Position = position;
}
else if (position.Lat != 0 && position.Lng != 0 && (position.Lat != result.Position.Lat || position.Lng != result.Position.Lng))
{
throw new Exception(i18n.Multiple_GPS_positions_found);
//.........这里部分代码省略.........