Ejemplo n.º 1
0
        public static VideoEncoderConfig Load(string fileName)
        {
            if (fileName == null)
            {
                return(null);
            }

            VideoEncoderConfig newConfig = null;

            try
            {
                XmlSerializer objSerializer = new XmlSerializer(typeof(VideoEncoderConfig));
                TextReader    objReader     = new StreamReader(fileName);
                newConfig = (VideoEncoderConfig)objSerializer.Deserialize(objReader);
                objReader.Close();
                newConfig.filename = fileName;
            }
            catch (Exception ex)
            {
                throw (new Exception("Error reading config from file. " + ex.Message));
            }
            return(newConfig);
        }         // method
Ejemplo n.º 2
0
        public void Run()
        {
            VideoEncoderConfig currentConfig = null;

            try
            {
                currentConfig = VideoEncoderConfig.Load(_configFile);
            }
            catch (Exception ex)
            {
                stdOut.Write("Error reading config file. ");
                stdOut.WriteLine(ex.Message);
                stdOut.Close();
                return;
            }

            if (currentConfig == null)
            {
                stdOut.WriteLine("Unable to read config file.");
                stdOut.Close();
                return;
            }

            ProfileConfig currentProfile = currentConfig.GetProfile(_profile);

            if (currentConfig == null)
            {
                stdOut.WriteLine("Profile not found. " + _profile);
                stdOut.Close();
                return;
            }

            stdOut.WriteLine("Using profile " + _profile);

            if ((currentProfile.overwrite == false) && (Encode.DestinationExists(_destination) == true))
            {
                stdOut.WriteLine("Destination file exists.");
                stdOut.Close();
                return;
            }

            bool result = this.CropDetect(currentConfig.encodeCommand, String.Format(currentProfile.cropDetect, this._source, this._destination));

            if (result == true)
            {
                foreach (string currentPass in currentProfile.passes)
                {
                    result = this.EncodeProcess(currentConfig.encodeCommand, String.Format(currentPass, this._source, this._destination, this._cropCommand));
                    if (result == false)
                    {
                        break;
                    }
                }

                foreach (string currentCleanup in currentProfile.cleanup)
                {
                    result = this.CleanupProcess(String.Format(currentCleanup, this._source, this._destination));
                    if (result == false)
                    {
                        break;
                    }
                }

                if ((currentProfile.fourCC != null) && (currentProfile.fourCC.Length == 4))
                {
                    FixRiff(_destination, currentProfile.fourCC);
                }
            }

            stdOut.Close();
        }