Пример #1
0
 public static Result Probe(string filePath)
 {
     string args = $"-v quiet -print_format json -show_streams -show_format -hide_banner \"{filePath}\"";
       string json = Cache.Instance.Get<string>(Cache.CACHE_STRINGS, args);
       if (json == null)
       {
     json = new Executer(Executer.FFPROBE).Execute(args);
     Cache.Instance.Put(Cache.CACHE_STRINGS, args, json);
       }
       try
       {
     JObject root = JObject.Parse(json);
     var videoStream = root["streams"].Where(x => x["codec_type"].ToString() == "video").First();
     return new Result()
     {
       EndTime = root["format"]["duration"].ToString(),
       WidthPix = int.Parse(videoStream["width"].ToString()),
       HeightPix = int.Parse(videoStream["height"].ToString()),
       Scale = $"{videoStream["width"]}:{videoStream["height"]}",
       Framerate = videoStream["r_frame_rate"].ToString()
     };
       }
       catch { return default(Result); }
 }
Пример #2
0
 static string GetCrop(string file, string start, string t)
 {
     string args = $"-hide_banner -ss {start} -i \"{file}\" -t {t} -vf cropdetect=64:2:0 -f null NUL";
       string cached = Cache.Instance.Get<string>(Cache.CACHE_STRINGS, args);
       if (cached == null)
       {
     string output = new Executer(Executer.FFMPEG).Execute(args);
     Regex regex = new Regex(@".*(crop=\d+:\d+:\d+:\d+).*");
     Match match = regex.Match(output);
     if (!match.Success)
       return null;
     cached = match.Groups[match.Groups.Count - 1].Value;
     Cache.Instance.Put(Cache.CACHE_STRINGS, args, cached);
       }
       return cached;
 }
Пример #3
0
 public void Generate(bool toFile)
 {
     output = new Executer().Execute($"-hide_banner \"{File}\"");
       GetTimings(toFile);
 }