public IFFprobeValue Get(FFprobeCodecTypes ffprobeCodecType, int streamIndex, string key) { var streamResultItems = Results.Where(r => r.Type == "STREAM").ToList(); if (!streamResultItems.Any()) { return(null); } var codecTypeObject = FFprobeObject.Create(ffprobeCodecType.ToString().ToLower()); var codecResultItems = Results.Where(r => r.ValuePairs.Any(vp => vp.Key == "codec_type" && vp.Value.Equals(codecTypeObject))).ToList(); if (!codecResultItems.Any()) { return(null); } if (codecResultItems.Count <= streamIndex) { return(null); } var streamData = codecResultItems.ElementAt(streamIndex); var streamDataValue = streamData.ValuePairs.FirstOrDefault(vp => vp.Key == key); return(streamDataValue == null ? null : streamDataValue.Value); }
public static FFprobeKeyValuePair SerializeAsFFprobeLong(List <FFprobeKeyValuePair> inputValuePairs, string key) { var inputValuePair = inputValuePairs.FirstOrDefault(ivp => ivp.Key == key); if (inputValuePair == null) { return(null); } var ffprobeObject = inputValuePair.Value as FFprobeObject; if (ffprobeObject == null) { return(null); } long value; if (!long.TryParse(ffprobeObject.Value.ToString(), out value)) { return(null); } return(FFprobeKeyValuePair.Create(key, FFprobeObject.Create(value))); }
public int GetCount(FFprobeCodecTypes ffprobeCodecType) { var streamResultItems = Results.Where(r => r.Type == "STREAM").ToList(); if (!streamResultItems.Any()) { return(0); } var codecTypeObject = FFprobeObject.Create(ffprobeCodecType.ToString().ToLower()); var codecResultItems = Results.Where(r => r.ValuePairs.Any(vp => vp.Key == "codec_type" && vp.Value.Equals(codecTypeObject))).ToList(); return(codecResultItems.Count); }
public static FFprobeKeyValuePair Create(string key, object value) { var rawObject = FFprobeObject.Create(value); return(new FFprobeKeyValuePair(key, rawObject)); }