예제 #1
0
        public static MediaCodec CreateFromXmlnode(XmlElement element)
        {
            var codec = new MediaCodec();

            if (element.HasAttribute("name"))
            {
                codec.Name = element.GetAttribute("name");
            }
            if (element.HasAttribute("title"))
            {
                codec.Title = element.GetAttribute("title");
            }
            if (element.HasAttribute("link"))
            {
                codec.Link = element.GetAttribute("link");
            }
            if (element.HasAttribute("cmd"))
            {
                codec.Command = element.GetAttribute("cmd");
            }
            if (element.HasAttribute("hwaccel"))
            {
                codec.HWAcceleration = element.GetAttribute("hwaccel");
            }
            if (element.HasAttribute("encode"))
            {
                codec.Encode = Convert.ToBoolean(element.GetAttribute("encode"));
            }

            return(codec);
        }
예제 #2
0
        /// <summary>
        /// Loads the configuration.
        /// </summary>
        /// <param name='path'>
        /// Path to xml config file
        /// </param>
        public static void Load(string filename)
        {
            OpenWithApplications = new List <string>();
            VideoCodecs          = new List <MediaCodec> ();
            AudioCodecs          = new List <MediaCodec> ();
            Containers           = new List <MediaContainer> ();

            DefaultVideoBitRates = new Dictionary <decimal, string> ();
            DefaultSamplingRates = new Dictionary <decimal, string> ();
            DefaultAudioBitrates = new Dictionary <decimal, string> ();

            if (!Path.IsPathRooted(filename))
            {
                // adding app path
                filename = Path.Combine(SupportMethods.AppPath + Path.DirectorySeparatorChar, filename);
            }

            if (!File.Exists(filename))
            {
                // creating default configuration
                Save(filename);
            }

            var xmlDoc = new EnhancedXmlDocument();

            xmlDoc.Load(filename);

            var appOpenWithNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/Applications/OpenWith/Application");

            foreach (XmlNode appNode in appOpenWithNodes)
            {
                OpenWithApplications.Add(appNode.InnerText);
            }

            var codecNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableCodecs/Video/Codec");

            foreach (XmlElement codecNode in codecNodes)
            {
                VideoCodecs.Add(MediaCodec.CreateFromXmlnode(codecNode));
            }

            var audioCodecNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableCodecs/Audio/Codec");

            foreach (XmlElement codecNode in audioCodecNodes)
            {
                AudioCodecs.Add(MediaCodec.CreateFromXmlnode(codecNode));
            }

            var contNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableContainers/Container");

            foreach (XmlElement cont in contNodes)
            {
                Containers.Add(MediaContainer.CreateFromXmlnode(cont));
            }

            MediaInfoPath = xmlDoc.GetSingleNodeValue("//MediaConvertGUIConfiguration/MediaInfoPath", "mediainfo");
            FFMpegPath    = xmlDoc.GetSingleNodeValue("//MediaConvertGUIConfiguration/FFMpegPath", "ffmpeg");


            LoadDictionaryFromXmlNode(DefaultVideoBitRates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultVideoBitrates/Bitrate");
            LoadDictionaryFromXmlNode(DefaultSamplingRates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultSamplingRates/Rate");
            LoadDictionaryFromXmlNode(DefaultAudioBitrates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultAudioBitrates/Bitrate");

            // Saving
            Save(filename);
        }