Getting the Surround Sound Audio Format from Video File C#

104 views Asked by At

Is there a reliable way to find out the Surround Sound format a video file is using? (Ex: Dolby Atmos, Dolby Digital, DTS Sound, etc.)

The closest thing I've found is this old post

and this code snippet:

        private void ParseFormat()
        {
            this.FeatureAudioFormat = AudioFormat.Unknown;

            if (string.IsNullOrEmpty(this.Feature)) { return; }

            int start = this.Feature.LastIndexOf("_", StringComparison.Ordinal) + 1;
            int len = this.Feature.LastIndexOf(".", StringComparison.Ordinal);
            bool isAudioFormat = false;

            var audioFormat = new StringBuilder(5);

            for (int i = start; i < len; i++) {
                if (isAudioFormat) {
                    if (this.Feature[i] == '.') {
                        isAudioFormat = false;
                    } else {
                        audioFormat.Append((char.IsUpper(this.Feature[i])) ? this.Feature[i] : char.ToUpper(this.Feature[i], CultureInfo.InvariantCulture));
                    }
                }
            }

            switch (audioFormat.ToString()) {
                case ATMOS: this.FeatureAudioFormat = AudioFormat.Atmos; break;
                case DTS: this.FeatureAudioFormat = AudioFormat.DTS; break;
                default: this.FeatureAudioFormat = AudioFormat.Dolby; break;
            }
        }
1

There are 1 answers

0
AKASGaming On BEST ANSWER

For those curious, I've found that MediaInfo.Wrapper can gather HDR, Video resolutions, and Surround Sound Formats everything I needed!