ADBaseLibrary.BaseDownloadPlugin.ReMux C# (CSharp) Method

ReMux() public method

public ReMux ( string inputfile, string inputs, string subtileargs, Format formats, string audiolanguagecode, string audiolanguage, double initialPercent, double percentIncrement, DownloadInfo dinfo, IProgress progress, CancellationToken token ) : Task
inputfile string
inputs string
subtileargs string
formats Format
audiolanguagecode string
audiolanguage string
initialPercent double
percentIncrement double
dinfo DownloadInfo
progress IProgress
token System.Threading.CancellationToken
return Task
        public async Task<string> ReMux(string inputfile, string inputs, string subtileargs, Format formats,
            string audiolanguagecode, string audiolanguage, double initialPercent, double percentIncrement,
            DownloadInfo dinfo, IProgress<DownloadInfo> progress, CancellationToken token)
        {
            int formatcnt = 0;
            foreach (Format fol in Enum.GetValues(typeof(Format)))
            {
                if ((fol & formats) == fol)
                {
                    formatcnt++;
                }
            }

            percentIncrement /=(2*formatcnt);
            string size = string.Empty;
            string intermediatefile = dinfo.FullPath + ".tm2";
            foreach (Format fol in Enum.GetValues(typeof(Format)))
            {
                if ((fol & formats) == fol)
                {
                    string ffmpegargs = string.Format(LibSet[FFMPEGArgsS], inputfile, inputs, subtileargs, intermediatefile, fol == Format.Mkv ? string.Empty : "-c:s mov_text ", audiolanguagecode, audiolanguage, fol == Format.Mkv ? "-f matroska" : "-f mp4");
                    token.ThrowIfCancellationRequested();
                    dinfo.Percent = initialPercent;
                    initialPercent += percentIncrement;
                    dinfo.Status = "Muxing Video";
                    progress.Report(dinfo);
                    ShellParser ffm = new ShellParser();
                    await ffm.Start(LibSet[FFMPEGEXES], ffmpegargs, token);
                    dinfo.Percent = initialPercent;
                    initialPercent += percentIncrement;
                    dinfo.Status = "Unique Hashing";
                    progress.Report(dinfo);

                    if (fol == Format.Mkv)
                        Matroska.Matroska.MatroskaHash(intermediatefile, dinfo.FullPath + "." + fol.ToExtension());
                    else
                        Mp4.Mp4.Mp4Hash(intermediatefile, dinfo.FullPath + "." + fol.ToExtension());
                    try
                    {
                        File.Delete(intermediatefile);
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                    FileInfo f = new FileInfo(dinfo.FullPath + "." + fol.ToExtension());
                    if (formatcnt == 1)
                    {
                        size = f.Length.ToString();
                    }
                    else
                    {
                        size += f.Length.ToString() + " (" + fol.ToExtension() + "), ";
                    }
                }
            }
            try
            {
                File.Delete(inputfile);
            }
            catch (Exception)
            {
                // ignored
            }
            if (formatcnt > 1)
                size = size.Substring(0, size.Length - 2);
            return size;
        }