public EncodeParameters GetEncodeParameters(InputFile file)
 {
     return(new EncodeParameters(
                inputPath: file.GetFilePath(),
                outputFolder: savePathLabel.Text,
                outputName: autoNamingBox.Checked? $"{file.GetFileName()}_V{selectedVCodec}_A{selectedACodec}_{selectedPreset}" : $"{prefixBox.Texts}{file.GetFileName()}{postfixBox.Texts}",
                videoCodec: selectedVCodec,
                audioCodec: selectedACodec,
                preset: selectedPreset,
                extention: selectedExtension,
                bitrateBox.Checked ? bitRate : file.GetFileBitrate() / 1024f,
                width: customWidthBox.Checked ? ((int)customWidthNumeric.Value) : file.GetFileWidth(),
                height: customHeightBox.Checked ? ((int)customHeightNumeric.Value) : file.GetFileHeight(),
                horizontalFlip: horFlipBox.Checked,
                verticalFlip: verFlipBox.Checked,
                saveAspect: saveAspectButton.Checked
                ));
 }
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the pattern to match against. If it's a simple pattern (eg. *.cpp, Engine/Build/...), automatically infer the source wildcard
            string FromPattern = Parameters.From;

            if (FromPattern == null)
            {
                List <string> Patterns = SplitDelimitedList(Parameters.Files);
                if (Patterns.Count != 1 || Patterns[0].StartsWith("#"))
                {
                    throw new AutomationException("Missing 'From' attribute specifying pattern to match source files against");
                }

                FromPattern = Patterns[0];

                int SlashIdx = FromPattern.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
                if (SlashIdx != -1)
                {
                    FromPattern = FromPattern.Substring(SlashIdx + 1);
                }
                if (FromPattern.StartsWith("..."))
                {
                    FromPattern = "*" + FromPattern.Substring(3);
                }
            }

            // Convert the source pattern into a regex
            string EscapedFromPattern = "^" + Regex.Escape(FromPattern) + "$";

            EscapedFromPattern = EscapedFromPattern.Replace("\\*", "(.*)");
            EscapedFromPattern = EscapedFromPattern.Replace("\\?", "(.)");
            Regex FromRegex = new Regex(EscapedFromPattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            // Split the output pattern into fragments that we can insert captures between
            string[] FromFragments = FromPattern.Split('*', '?');
            string[] ToFragments   = Parameters.To.Split('*', '?');
            if (FromFragments.Length < ToFragments.Length)
            {
                throw new AutomationException("Too few capture groups in source pattern '{0}' to rename to '{1}'", FromPattern, Parameters.To);
            }

            // Find the input files
            HashSet <FileReference> InputFiles = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);

            // Find all the corresponding output files
            Dictionary <FileReference, FileReference> RenameFiles = new Dictionary <FileReference, FileReference>();

            foreach (FileReference InputFile in InputFiles)
            {
                Match Match = FromRegex.Match(InputFile.GetFileName());
                if (Match.Success)
                {
                    StringBuilder OutputName = new StringBuilder(ToFragments[0]);
                    for (int Idx = 1; Idx < ToFragments.Length; Idx++)
                    {
                        OutputName.Append(Match.Groups[Idx].Value);
                        OutputName.Append(ToFragments[Idx]);
                    }
                    RenameFiles[InputFile] = FileReference.Combine(InputFile.Directory, OutputName.ToString());
                }
            }

            // Print out everything we're going to do
            foreach (KeyValuePair <FileReference, FileReference> Pair in RenameFiles)
            {
                CommandUtils.RenameFile(Pair.Key.FullName, Pair.Value.FullName, true);
            }

            // Add the build product
            BuildProducts.UnionWith(RenameFiles.Values);

            // Apply the optional output tag to them
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(RenameFiles.Values);
            }
        }