当前位置: 首页>>代码示例>>C#>>正文


C# VideoInfo.AddAlternativeMetadataTimestamp方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:Remo,项目名称:MediaData,代码行数:101,代码来源:FFmpegVideoProcessor.cs


注:本文中的System.VideoInfo.AddAlternativeMetadataTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。