public void vidThread(object sender, DoWorkEventArgs e)
        {
            if (sourceList.Count == 0 && insertTransitionClips == false)
            {
                Console.WriteLine("No sources added...");
                return;
            }

            if (File.Exists(OUTPUT_FILE))
            {
                File.Delete(OUTPUT_FILE);
            }

            try
            {
                Directory.CreateDirectory(toolBox.TEMP);
                int endofclips = MAX_CLIPS - 1;
                failed = false;
                for (int i = 0; i < MAX_CLIPS; i++)
                {
                    Console.WriteLine("STARTING CLIP " + "video" + i);
                    if (i == 0 && intro)
                    {
                        MAX_CLIPS++;
                        Console.WriteLine("Intro clip enabled, adding 1 to max clips. New max clips is " + MAX_CLIPS + ".");
                        Console.WriteLine("Done: " + Decimal.Divide(i, MAX_CLIPS));
                        vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(i, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                        Console.WriteLine(toolBox.intro);
                        toolBox.copyVideo(toolBox.intro, toolBox.TEMP + "video" + i, width, height);
                    }
                    else
                    {
                        Console.WriteLine("Done: " + Decimal.Divide(i, MAX_CLIPS));
                        vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(i, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                        if ((randomInt(0, 15) == 15 && insertTransitionClips == true) || sourceList.Count == 0)
                        {
                            Console.WriteLine("Tryina use a diff source");
                            toolBox.copyVideo(toolBox.SOURCES + effectsFactory.pickSource(), toolBox.TEMP + "video" + i, width, height);
                        }
                        else
                        {
                            string sourceToPick = sourceList[randomInt(0, sourceList.Count - 1)].ToString();
                            Console.WriteLine(sourceToPick);
                            decimal source = decimal.Parse(toolBox.getLength(sourceToPick), NumberStyles.Any, new CultureInfo("en-US"));
                            string  output = source.ToString("0.#########################", new CultureInfo("en-US"));
                            Console.WriteLine(toolBox.getLength(sourceToPick) + " -> " + output + " -> " + double.Parse(output, NumberStyles.Any, new CultureInfo("en-US")));
                            double boy = double.Parse(output, NumberStyles.Any, new CultureInfo("en-US"));
                            Console.WriteLine(boy);
                            double startOfClip = randomDouble(0.0, boy - MAX_STREAM_DURATION);
                            double endOfClip   = startOfClip + randomDouble(MIN_STREAM_DURATION, MAX_STREAM_DURATION);
                            Console.WriteLine("Beginning of clip " + i + ": " + startOfClip.ToString("0.#########################", new CultureInfo("en-US")));
                            Console.WriteLine("Ending of clip " + i + ": " + endOfClip.ToString("0.#########################", new CultureInfo("en-US")) + ", in seconds: ");
                            toolBox.snipVideo(sourceToPick, startOfClip, endOfClip, toolBox.TEMP + "video" + i, width, height);
                        }
                        //Add a random effect to the video
                        int effect = 0;
                        if (pluginTest)
                        {
                            effect = 28;
                        }
                        else
                        {
                            effect = randomInt(0, 27 + pluginCount);
                            if (effect > 0)
                            {
                                Console.WriteLine("STARTING EFFECT ON CLIP " + i + " EFFECT" + effect);
                            }
                        }
                        String clipToWorkWith = toolBox.TEMP + "video" + i + ".mp4";
                        switch (effect)
                        {
                        case 1:
                            if (effect1 == true)
                            {
                                effectsFactory.effect_RandomSound(clipToWorkWith);
                            }
                            break;

                        case 2:
                            if (effect2 == true)
                            {
                                effectsFactory.effect_RandomSoundMute(clipToWorkWith);
                            }
                            break;

                        case 3:
                            if (effect3 == true)
                            {
                                effectsFactory.effect_Reverse(clipToWorkWith);
                            }
                            break;

                        case 4:
                            if (effect4 == true)
                            {
                                effectsFactory.effect_SpeedUp(clipToWorkWith);
                            }
                            break;

                        case 5:
                            if (effect5 == true)
                            {
                                effectsFactory.effect_SlowDown(clipToWorkWith);
                            }
                            break;

                        case 6:
                            if (effect6 == true)
                            {
                                effectsFactory.effect_Chorus(clipToWorkWith);
                            }
                            break;

                        case 7:
                            if (effect7 == true)
                            {
                                effectsFactory.effect_Vibrato(clipToWorkWith);
                            }
                            break;

                        case 8:
                            if (effect8 == true)
                            {
                                effectsFactory.effect_Tremolo(clipToWorkWith);
                            }
                            break;

                        case 9:
                            if (effect9 == true)
                            {
                                effectsFactory.effect_Earrape(clipToWorkWith);
                            }
                            break;

                        case 10:
                            if (effect10 == true)
                            {
                                effectsFactory.effect_SpeedUpHighPitch(clipToWorkWith);
                            }
                            break;

                        case 11:
                            if (effect11 == true)
                            {
                                effectsFactory.effect_SlowDownLowPitch(clipToWorkWith);
                            }
                            break;

                        case 12:
                            if (effect12 == true)
                            {
                                effectsFactory.effect_HighPitch(clipToWorkWith);
                            }
                            break;

                        case 13:
                            if (effect13 == true)
                            {
                                effectsFactory.effect_LowPitch(clipToWorkWith);
                            }
                            break;

                        case 14:
                            if (effect14 == true)
                            {
                                effectsFactory.effect_ForwardReverse(clipToWorkWith);
                            }
                            break;

                        case 15:
                            if (effect15 == true)
                            {
                                effectsFactory.effect_ReverseForward(clipToWorkWith);
                            }
                            break;

                        case 16:
                            if (effect16 == true)
                            {
                                effectsFactory.effect_Pixelate(clipToWorkWith, width, height);
                            }
                            break;

                        case 17:
                            if (effect17 == true)
                            {
                                effectsFactory.effect_BadQuality(clipToWorkWith, width, height);
                            }
                            break;

                        case 18:
                            if (effect18 == true)
                            {
                                effectsFactory.effect_Emboss(clipToWorkWith);
                            }
                            break;

                        case 19:
                            if (effect19 == true)
                            {
                                effectsFactory.effect_SymmetryHorizontal1(clipToWorkWith);
                            }
                            break;

                        case 20:
                            if (effect20 == true)
                            {
                                effectsFactory.effect_SymmetryHorizontal2(clipToWorkWith);
                            }
                            break;

                        case 21:
                            if (effect21 == true)
                            {
                                effectsFactory.effect_SymmetryVertical1(clipToWorkWith);
                            }
                            break;

                        case 22:
                            if (effect22 == true)
                            {
                                effectsFactory.effect_SymmetryVertical2(clipToWorkWith);
                            }
                            break;

                        case 23:
                            if (effect23 == true)
                            {
                                effectsFactory.effect_GMajor(clipToWorkWith);
                            }
                            break;

                        case 24:
                            if (effect24 == true)
                            {
                                effectsFactory.effect_Dance(clipToWorkWith);
                            }
                            break;

                        case 25:
                            if (effect25 == true)
                            {
                                effectsFactory.effect_Squidward(clipToWorkWith, width, height);
                            }
                            break;

                        case 26:
                            if (effect26 == true)
                            {
                                effectsFactory.effect_SpartaRemix(clipToWorkWith, width, height);
                            }
                            break;

                        default:
                            if (effect >= 28 && effect <= 27 + pluginCount)
                            {
                                effectsFactory.effect_Plugin(clipToWorkWith, width, height, plugins[rnd.Next(plugins.Count)]);
                            }
                            break;
                        }
                    }
                }
                if (outro)
                {
                    Console.WriteLine("Outro clip enabled.");
                    Console.WriteLine("Done: " + Decimal.Divide(MAX_CLIPS - 1, MAX_CLIPS));
                    vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(MAX_CLIPS - 1, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                    Console.WriteLine(toolBox.outro);
                    Console.WriteLine("STARTING CLIP " + "video" + MAX_CLIPS);
                    toolBox.copyVideo(toolBox.outro, toolBox.TEMP + "video" + MAX_CLIPS, width, height);
                    MAX_CLIPS++;
                }
                toolBox.concatenateVideo(MAX_CLIPS, OUTPUT_FILE);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                exc    = ex;
                failed = true;
            }
            cleanUp();
            rmDir(toolBox.TEMP);
        }
        public void vidThread(object sender, DoWorkEventArgs e)
        {
            if (sourceList.Count == 0)
            {
                Console.WriteLine("No sources added...");
                return;
            }

            Console.WriteLine("poop_1");

            if (File.Exists(OUTPUT_FILE))
            {
                File.Delete(OUTPUT_FILE);
            }

            try
            {
                Directory.CreateDirectory(toolBox.TEMP);
                int endofclips = MAX_CLIPS - 1;
                failed = false;
                for (int i = 0; i < MAX_CLIPS; i++)
                {
                    if (i == 0 && intro)
                    {
                        MAX_CLIPS++;
                        Console.WriteLine("Intro clip enabled, adding 1 to max clips. New max clips is " + MAX_CLIPS + ".");
                        Console.WriteLine("Done: " + Decimal.Divide(i, MAX_CLIPS));
                        vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(i, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                        Console.WriteLine(toolBox.intro);
                        Console.WriteLine("STARTING CLIP " + "video" + i);
                        toolBox.copyVideo(toolBox.intro, toolBox.TEMP + "video" + i, width, height);
                    }
                    else
                    {
                        Console.WriteLine("Done: " + Decimal.Divide(i, MAX_CLIPS));
                        vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(i, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                        string sourceToPick = sourceList[randomInt(0, sourceList.Count - 1)].ToString();
                        Console.WriteLine(sourceToPick);

                        decimal source = decimal.Parse(toolBox.getLength(sourceToPick), NumberStyles.Any, new CultureInfo("en-US"));
                        string  output = source.ToString("0.#########################", new CultureInfo("en-US"));
                        Console.WriteLine(toolBox.getLength(sourceToPick) + " -> " + output + " -> " + double.Parse(output, NumberStyles.Any, new CultureInfo("en-US")));
                        double boy = double.Parse(output, NumberStyles.Any, new CultureInfo("en-US"));
                        Console.WriteLine(boy);
                        Console.WriteLine("STARTING CLIP " + "video" + i);
                        double startOfClip = randomDouble(0.0, boy - MAX_STREAM_DURATION);
                        //Console.WriteLine("boy seconds = "+  boy.getLengthSec());
                        double endOfClip = startOfClip + randomDouble(MIN_STREAM_DURATION, MAX_STREAM_DURATION);
                        Console.WriteLine("Beginning of clip " + i + ": " + startOfClip.ToString("0.#########################", new CultureInfo("en-US")));
                        Console.WriteLine("Ending of clip " + i + ": " + endOfClip.ToString("0.#########################", new CultureInfo("en-US")) + ", in seconds: ");
                        if (randomInt(0, 15 + pluginCount) == 15 && insertTransitionClips == true)
                        {
                            Console.WriteLine("Tryina use a diff source");
                            toolBox.copyVideo(toolBox.SOURCES + effectsFactory.pickSource(), toolBox.TEMP + "video" + i, width, height);
                        }
                        else
                        {
                            toolBox.snipVideo(sourceToPick, startOfClip, endOfClip, toolBox.TEMP + "video" + i, width, height);
                        }
                        //Add a random effect to the video
                        int effect = giveProbability(0, 15 + pluginCount);
                        if (pluginTest)
                        {
                            effect = 16;
                        }
                        Console.WriteLine("STARTING EFFECT ON CLIP " + i + " EFFECT" + effect);
                        String clipToWorkWith = toolBox.TEMP + "video" + i + ".mp4";
                        switch (effect)
                        {
                        case 1:
                            //random sound
                            if (effect1 == true)
                            {
                                effectsFactory.effect_RandomSound(clipToWorkWith, width, height);
                            }
                            break;

                        case 2:
                            if (effect2 == true)
                            {
                                //random sound
                                effectsFactory.effect_RandomSoundMute(clipToWorkWith, width, height);
                            }
                            break;

                        case 3:
                            if (effect3 == true)
                            {
                                effectsFactory.effect_Reverse(clipToWorkWith, width, height);
                            }
                            break;

                        case 4:
                            if (effect4 == true)
                            {
                                effectsFactory.effect_SpeedUp(clipToWorkWith, width, height);
                            }
                            break;

                        case 5:
                            if (effect5 == true)
                            {
                                effectsFactory.effect_SlowDown(clipToWorkWith, width, height);
                            }
                            break;

                        case 6:
                            if (effect6 == true)
                            {
                                effectsFactory.effect_Chorus(clipToWorkWith, width, height);
                            }
                            break;

                        case 7:
                            if (effect7 == true)
                            {
                                effectsFactory.effect_Vibrato(clipToWorkWith, width, height);
                            }
                            break;

                        case 8:
                            if (effect8 == true)
                            {
                                effectsFactory.effect_HighPitch(clipToWorkWith, width, height);
                            }
                            break;

                        case 9:
                            if (effect9 == true)
                            {
                                effectsFactory.effect_LowPitch(clipToWorkWith, width, height);
                            }
                            break;

                        case 10:
                            if (effect10 == true)
                            {
                                effectsFactory.effect_Dance(clipToWorkWith, width, height);
                            }
                            break;

                        case 11:
                            if (effect11 == true)
                            {
                                effectsFactory.effect_Squidward(clipToWorkWith, width, height);
                            }
                            break;

                        /*case 12:
                         *  if (effect12 == true)
                         *  {
                         *      effectsFactory.effect_RainbowTrail(clipToWorkWith, width, height, startOfClip, endOfClip);
                         *  }
                         *  break;*/
                        default:
                            if (effect > 15)
                            {
                                if (effect <= 15 + pluginCount)
                                {
                                    effectsFactory.effect_Plugin(clipToWorkWith, width, height, plugins[rnd.Next(plugins.Count)], startOfClip, endOfClip);
                                }
                            }
                            break;
                        }
                    }
                }
                if (outro)
                {
                    MAX_CLIPS++;
                    Console.WriteLine("Outro clip enabled.");
                    Console.WriteLine("Done: " + Decimal.Divide(MAX_CLIPS - 1, MAX_CLIPS));
                    vidThreadWorker.ReportProgress(Convert.ToInt32(Decimal.Divide(MAX_CLIPS - 1, MAX_CLIPS) * 100, new CultureInfo("en-US")));
                    Console.WriteLine(toolBox.outro);
                    Console.WriteLine("STARTING CLIP " + "video" + MAX_CLIPS);
                    toolBox.copyVideo(toolBox.outro, toolBox.TEMP + "video" + MAX_CLIPS, width, height);
                    MAX_CLIPS++;
                }

                /*for (int i = 0; i < MAX_CLIPS; i++)
                 * {
                 *  if (File.Exists(toolBox.TEMP + "video" + i + ".mp4"))
                 *  {
                 *      writer.WriteLineAsync("file 'video" + i + ".mp4'\n"); //writing to same folder
                 *  }
                 * }*/
                //Thread.sleep(10000);
                toolBox.concatenateVideo(MAX_CLIPS, OUTPUT_FILE);
                //Thread.sleep(4000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                exc    = ex;
                failed = true;
            }
            //for (int i=0; i<100; i++) {
            cleanUp();
            rmDir(toolBox.TEMP);
        }