private void PerformRequest()
        {
            bool   replace        = _overWrite;
            string filename       = _filename;
            string strFolderThumb = string.Empty;

            strFolderThumb = Util.Utils.GetLocalFolderThumbForDir(filename);

            string strRemoteFolderThumb = string.Empty;

            strRemoteFolderThumb = String.Format(@"{0}\folder.jpg", Util.Utils.RemoveTrailingSlash(filename));

            if (Utils.FileExistsInCache(strRemoteFolderThumb))
            {
                // if there was no cached thumb although there was a folder.jpg then the user didn't scan his collection:
                // -- punish him with slowness and create the thumbs for the next time...
                try
                {
                    Log.Info("FolderThumbCacher: Creating missing folder thumb cache for {0}", strRemoteFolderThumb);
                    string localFolderLThumb = Util.Utils.ConvertToLargeCoverArt(strFolderThumb);

                    if (!File.Exists(strFolderThumb) || replace)
                    {
                        Picture.CreateThumbnail(strRemoteFolderThumb, strFolderThumb, (int)Thumbs.ThumbResolution,
                                                (int)Thumbs.ThumbResolution, 0, true, false, false);
                        {
                            // Generate Large Thumb
                            Picture.CreateThumbnail(strRemoteFolderThumb, localFolderLThumb, (int)Thumbs.ThumbLargeResolution,
                                                    (int)Thumbs.ThumbLargeResolution, 0, true, true, false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("FolderThumbCacher: Error processing {0} - {1}", strRemoteFolderThumb, ex);
                }
            }
            else
            {
                Log.Debug("FolderThumbCacher: No folder thumb at {0}", strRemoteFolderThumb);
            }
        }
        public static bool CreateVideoThumb(string aVideoPath, string aThumbPath, bool aCacheThumb, bool aOmitCredits)
        {
            if (NeedsConfigRefresh)
            {
                LoadSettings();
            }

            if (String.IsNullOrEmpty(aVideoPath) || String.IsNullOrEmpty(aThumbPath))
            {
                Log.Warn("VideoThumbCreator: Invalid arguments to generate thumbnails of your video!");
                return(false);
            }
            if (!Util.Utils.FileExistsInCache(aVideoPath))
            {
                Log.Warn("VideoThumbCreator: File {0} not found!", aVideoPath);
                return(false);
            }
            if (!Util.Utils.FileExistsInCache(ExtractorPath))
            {
                Log.Warn("VideoThumbCreator: No {0} found to generate thumbnails of your video!", ExtractApp);
                return(false);
            }
            if (!LeaveShareThumb && !aCacheThumb)
            {
                Log.Warn(
                    "VideoThumbCreator: No share thumbs wanted by config option AND no caching wanted - where should the thumb go then? Aborting..");
                return(false);
            }

            IVideoThumbBlacklist blacklist = GlobalServiceProvider.Get <IVideoThumbBlacklist>();

            if (blacklist != null && blacklist.Contains(aVideoPath))
            {
                Log.Debug("Skipped creating thumbnail for {0}, it has been blacklisted because last attempt failed", aVideoPath);
                return(false);
            }

            // Params for ffmpeg
            // string ExtractorArgs = string.Format(" -i \"{0}\" -vframes 1 -ss {1} -s {2}x{3} \"{4}\"", aVideoPath, @"00:08:21", (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, aThumbPath);

            // Params for mplayer (outputs 00000001.jpg in video resolution into working dir) -vf scale=600:-3
            //string ExtractorArgs = string.Format(" -noconsolecontrols -nosound -vo jpeg:quality=90 -vf scale -frames 1 -ss {0} \"{1}\"", "501", aVideoPath);

            // Params for mtm (http://moviethumbnail.sourceforge.net/usage.en.html)
            //   -D 8         : edge detection; 0:off >0:on; higher detects more; try -D4 -D6 or -D8
            //   -B 420/E 600 : omit this seconds from the beginning / ending TODO: use pre- / postrecording values
            //   -c 2 / r 2   : # of column / # of rows
            //   -b 0.60      : skip if % blank is higher; 0:skip all 1:skip really blank >1:off
            //   -h 100       : minimum height of each shot; will reduce # of column to fit
            //   -t           : time stamp off
            //   -i           : info text off
            //   -w 0         : width of output image; 0:column * movie width
            //   -n           : run at normal priority
            //   -W           : dont overwrite existing files, i.e. update mode
            //   -P           : dont pause before exiting; override -p

            const double flblank = 0.6;
            string       blank   = flblank.ToString("F", CultureInfo.CurrentCulture);

            int preGapSec  = 5;
            int postGapSec = 5;

            if (aOmitCredits)
            {
                preGapSec  = 420;
                postGapSec = 600;
            }
            bool   Success       = false;
            string ExtractorArgs = string.Format(" -D 6 -B {0} -E {1} -c {2} -r {3} -b {4} -t -i -w {5} -n -P \"{6}\"",
                                                 preGapSec, postGapSec, PreviewColumns, PreviewRows, blank, 0, aVideoPath);
            string ExtractorFallbackArgs = string.Format(
                " -D 8 -B {0} -E {1} -c {2} -r {3} -b {4} -t -i -w {5} -n -P \"{6}\"", 0, 0, PreviewColumns, PreviewRows, blank,
                0, aVideoPath);

            // Honour we are using a unix app
            ExtractorArgs = ExtractorArgs.Replace('\\', '/');
            try
            {
                // Use this for the working dir to be on the safe side
                string TempPath    = Path.GetTempPath();
                string OutputThumb = string.Format("{0}_s{1}", Path.ChangeExtension(aVideoPath, null), ".jpg");
                string ShareThumb  = OutputThumb.Replace("_s.jpg", ".jpg");

                if ((LeaveShareThumb && !Util.Utils.FileExistsInCache(ShareThumb))
                    // No thumb in share although it should be there
                    || (!LeaveShareThumb && !Util.Utils.FileExistsInCache(aThumbPath)))
                // No thumb cached and no chance to find it in share
                {
                    //Log.Debug("VideoThumbCreator: No thumb in share {0} - trying to create one with arguments: {1}", ShareThumb, ExtractorArgs);
                    Success = Utils.StartProcess(ExtractorPath, ExtractorArgs, TempPath, 15000, true, GetMtnConditions());
                    if (!Success)
                    {
                        // Maybe the pre-gap was too large or not enough sharp & light scenes could be caught
                        Thread.Sleep(100);
                        Success = Utils.StartProcess(ExtractorPath, ExtractorFallbackArgs, TempPath, 30000, true, GetMtnConditions());
                        if (!Success)
                        {
                            Log.Info("VideoThumbCreator: {0} has not been executed successfully with arguments: {1}", ExtractApp,
                                     ExtractorFallbackArgs);
                        }
                    }
                    // give the system a few IO cycles
                    Thread.Sleep(100);
                    // make sure there's no process hanging
                    Utils.KillProcess(Path.ChangeExtension(ExtractApp, null));
                    try
                    {
                        // remove the _s which mdn appends to its files
                        File.Move(OutputThumb, ShareThumb);
                    }
                    catch (FileNotFoundException)
                    {
                        Log.Debug("VideoThumbCreator: {0} did not extract a thumbnail to: {1}", ExtractApp, OutputThumb);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            // Clean up
                            File.Delete(OutputThumb);
                            Thread.Sleep(50);
                        }
                        catch (Exception) {}
                    }
                }
                else
                {
                    // We have a thumbnail in share but the cache was wiped out - make sure it is recreated
                    if (LeaveShareThumb && Util.Utils.FileExistsInCache(ShareThumb) && !Util.Utils.FileExistsInCache(aThumbPath))
                    {
                        Success = true;
                    }
                }

                Thread.Sleep(30);

                if (aCacheThumb && Success)
                {
                    if (Picture.CreateThumbnail(ShareThumb, aThumbPath, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution,
                                                0, false))
                    {
                        Picture.CreateThumbnail(ShareThumb, Utils.ConvertToLargeCoverArt(aThumbPath),
                                                (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, false);
                    }
                }

                if (!LeaveShareThumb)
                {
                    try
                    {
                        File.Delete(ShareThumb);
                        Thread.Sleep(30);
                    }
                    catch (Exception) {}
                }
            }
            catch (Exception ex)
            {
                Log.Error("VideoThumbCreator: Thumbnail generation failed - {0}!", ex.ToString());
            }
            if (Util.Utils.FileExistsInCache(aThumbPath))
            {
                return(true);
            }
            else
            {
                if (blacklist != null)
                {
                    blacklist.Add(aVideoPath);
                }
                return(false);
            }
        }