Example #1
0
        /// <summary>
        /// Gets the basic info about the file from a <see cref="JsonElement"/>.
        /// </summary>
        /// <param name="format">The <see cref="JsonElement"/> to parse.</param>
        /// <returns>A formatted <see cref="string"/> containing basic file info.</returns>
        public static string GetFileInfo(JsonElement format)
        {
            var size     = format.TryGetProperty("size", out var Jsize) ? Jsize.GetString() : "N/A";
            var duration = format.TryGetProperty("duration", out var Jduration) ? Jduration.GetString() : "N/A";
            var bitRate  = format.TryGetProperty("bit_rate", out var JbitRate) ? JbitRate.GetString() : "N/A";

            return($"Size: {size} bytes ({Converter.ToKiB(size)}B), duration: {Converter.ToHMS(double.Parse(duration))}, avg. bitrate: {Converter.ToKB(bitRate)}b/s");
        }
Example #2
0
        /// <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");
        }
Example #3
0
        /// <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");
        }