/// <summary> /// Gets video info about the file from a <see cref="JsonElement"/>. /// </summary> /// <param name="audioStream">The <see cref="JsonElement"/> to parse.</param> /// <returns>A formatted <see cref="string"/> containing video info.</returns> public static string GetVideoInfo(JsonElement videoStream) { var codecName = videoStream.TryGetProperty("codec_name", out var JcodecName) ? JcodecName.GetString() : "N/A"; var width = videoStream.TryGetProperty("width", out var Jwidth) ? Jwidth.GetInt32().ToString() : "N/A"; var height = videoStream.TryGetProperty("height", out var Jheight) ? Jheight.GetInt32().ToString() : "N/A"; var frameRate = videoStream.TryGetProperty("avg_frame_rate", out var JframeRate) ? JframeRate.GetString() : "N/A"; var bitRate = videoStream.TryGetProperty("bit_rate", out var JbitRate) ? JbitRate.GetString() : "N/A"; return($"Video: {codecName}, {width}x{height}, {GetFps(frameRate)}, {Converter.ToKB(bitRate)}b/s"); }
/// <summary> /// Gets audio info about the file from a <see cref="JsonElement"/>. /// </summary> /// <param name="audioStream">The <see cref="JsonElement"/> to parse.</param> /// <returns>A formatted <see cref="string"/> containing audio info.</returns> public static string GetAudioInfo(JsonElement audioStream) { var codecName = audioStream.TryGetProperty("codec_name", out var JcodecName) ? JcodecName.GetString() : "N/A"; var sampleRate = audioStream.TryGetProperty("sample_rate", out var JsampleRate) ? JsampleRate.GetString() : "N/A"; var channels = audioStream.TryGetProperty("channels", out var Jchannels) ? Jchannels.GetInt32() : 0; var bitRate = audioStream.TryGetProperty("bit_rate", out var JbitRate) ? JbitRate.GetString() : "N/A"; return($"Audio: {codecName}, {sampleRate} Hz, {channels} channels, {Converter.ToKB(bitRate)}b/s"); }