internal static void AddToQueue(ThumbnailQueueItem thumbnailQueueItem)
        {
            Debug.WriteLine("AddToQueue");

            lock (locker)
            {
                ThumbnailQueue.Enqueue(thumbnailQueueItem);

                if (_isWorking == false)
                {
                    _isWorking = true;
                    RunWorker();
                }

                //GeneratorTimer_Elapsed(null, null);
            }
        }
        private static Image GenerateThumbnail(ThumbnailQueueItem thumbnailQueueItem)
        {
            Image ret = null;

            Guid guid = Guid.NewGuid();
            string thumbFilePath = Path.Combine(Path.GetTempPath(), "HH-thumbs-" + guid.ToString() + ".png");

            Logger.Info("Generating: " + thumbFilePath);

            var thumbnailProcess = new Process();
            thumbnailProcess.StartInfo.FileName = MainModel.GetPathToFFmpeg();
            thumbnailProcess.StartInfo.Arguments = "-ss " + thumbnailQueueItem.SeekInSeconds.ToString(CultureInfo.InvariantCulture) + " -t 1 " +
                "-i \"" + thumbnailQueueItem.SourceFileInfo.FullName + "\" -y -vframes 1 -filter:v yadif -an " +
                "-s " + thumbnailQueueItem.Size.Width.ToString(CultureInfo.InvariantCulture) + "x" + thumbnailQueueItem.Size.Height.ToString(CultureInfo.InvariantCulture) + " \"" + thumbFilePath + "\"";
            /*
             * -t 1         duration of 1 second
             * -y           overwrite existing file
             * -filter:v yadif  deinterlace
             * -vframes 1   record 1 video frame
             * -an          disable audio recording
             * -s           size of thumbnail
             */
            thumbnailProcess.StartInfo.UseShellExecute = false;
            thumbnailProcess.StartInfo.CreateNoWindow = true;
            thumbnailProcess.StartInfo.RedirectStandardError = true;
            try
            {
                Logger.Debug("Starting with arguments: " + thumbnailProcess.StartInfo.Arguments);
                thumbnailProcess.Start();
                thumbnailProcess.WaitForExit();
                //Logger.Debug("FFmpeg output: " + thumbnailProcess.StandardError.ReadToEnd());

                byte[] buffer = File.ReadAllBytes(thumbFilePath);
                MemoryStream ms = new MemoryStream(buffer);
                ret = Image.FromStream(ms);
                File.Delete(thumbFilePath);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                // ret = backup image
            }

            return ret;
        }