private void SplitWithFadeout(string inputFile, List <double> splitPoints,
                                      string sFadeLength)
        {
            const int sampleRate  = 44100;
            string    outFilename = inputFile + "_fadeout.m4a";

            if (!double.TryParse(sFadeLength, out double fadeLength) || fadeLength <= 0)
            {
                throw new CsDownloadVidException("Invalid fadelength, expected a number of " +
                                                 "seconds like 4");
            }
            else if (splitPoints.Count == 0)
            {
                throw new CsDownloadVidException("Enter a time, in seconds");
            }
            else if (splitPoints.Count != 1)
            {
                throw new CsDownloadVidException("It looks like you have entered more than " +
                                                 "one time point. Please enter just one time, in seconds.");
            }
            else if (!inputFile.EndsWith(".m4a"))
            {
                throw new CsDownloadVidException("We currently only support adding fadeout " +
                                                 "for m4a files (if you have a .mp4 song, please rename it to .m4a first).");
            }
            else if (File.Exists(outFilename))
            {
                throw new CsDownloadVidException("Output file already exists " + outFilename);
            }

            // preemptively make sure we have a path to qaac.
            CsDownloadVidFilepaths.GetQaac();

            // run all in a separate thread, so that UI remains responsive.
            _runner.RunInThread(() =>
            {
                var log = "";
                new AddFadeoutUsingRawAacData().Go(inputFile, sampleRate, splitPoints[0],
                                                   fadeLength, outFilename, ref log);

                _runner.TraceFiltered(log.Replace("\n", Utils.NL));
                _runner.Trace(File.Exists(outFilename) ? "Successfully saved to " + outFilename :
                              "Error(s) occurred");
            });
        }
        private void LoadFormats_StartProc(string urlToGet, ProcessStartInfo info)
        {
            string log       = "";
            string stderr    = "";
            string stdout    = "";
            bool   succeeded = false;

            Process p = new Process();

            p.StartInfo = info;
            p.Start();
            p.ErrorDataReceived += (o, eparam) => { stderr += eparam.Data; };
            p.BeginErrorReadLine();
            p.WaitForExit();
            log   += "\nRan " + info.FileName + " " + info.Arguments;
            stdout = p.StandardOutput.ReadToEnd();
            if (p.ExitCode == 0)
            {
                succeeded = true;
            }
            else
            {
                log += "\nStdout:" + stdout;
                log += "\nStderr:" + stderr;
            }

            _runner.TraceFiltered(log.Replace("\n", Utils.NL));
            if (succeeded)
            {
                LoadFormats_ToUI(urlToGet, stdout);
            }
            else
            {
                Utils.MessageErr("Could not get formats");
                _runner.Trace("Could not get formats");
            }
        }