Beispiel #1
0
        /// <summary>
        /// Creates a new Obs audio encoder with default settings.
        /// </summary>
        /// <returns></returns>
        public static ObsEncoder CreateAudioEncoder()
        {
            // mf_aac for W8 and later, ffmpeg_aac for W7
            string encoderId = "mf_aac";

            // Windows 7 is Version 6.1. Check if version 6.1 and below. We don't support anything below Windows 7.
            if (System.Environment.OSVersion.Platform == PlatformID.Win32NT &&
                ((System.Environment.OSVersion.Version.Major == 6 && System.Environment.OSVersion.Version.Minor <= 1) ||
                 System.Environment.OSVersion.Version.Major < 6)
                )
            {
                encoderId = "ffmpeg_aac";
            }

            ObsEncoder obsAudioEncoder = new ObsEncoder(ObsEncoderType.Audio, encoderId, "simple_aac");

            obsAudioEncoder.SetAudio(Obs.GetAudio());

            ObsData audioEncoderSettings = new ObsData();

            audioEncoderSettings.SetInt("bitrate", Constants.Audio.ENCODER_BITRATE);
            audioEncoderSettings.SetString("rate_control", Constants.Audio.RATE_CONTROL);
            audioEncoderSettings.SetInt("samplerate", Constants.Audio.SAMPLES_PER_SEC);
            audioEncoderSettings.SetBoolDefault("allow he-aac", true);
            obsAudioEncoder.Update(audioEncoderSettings);
            audioEncoderSettings.Dispose();

            return(obsAudioEncoder);
        }