コード例 #1
0
        public static int GeneratePreview(string videoPath, string targetFilePath, Metadata metadata = null)
        {
            if (string.IsNullOrEmpty(videoPath) || !File.Exists(videoPath) || string.IsNullOrEmpty(targetFilePath))
            {
                return(0);
            }

            if (metadata?.Video == null)
            {
                using FastMetadataCommand command = new FastMetadataCommand
                      {
                          Input   = videoPath,
                          Timeout = TimeSpan.FromMinutes(3)
                      };
                if (!command.Run())
                {
                    return(0);
                }
                metadata = command.Metadata;
            }

            if (metadata?.Video == null)
            {
                return(0);
            }

            if (!File.Exists(targetFilePath))
            {
                try
                {
                    using ThumbnailCommand command = new ThumbnailCommand
                          {
                              Input       = videoPath,
                              Output      = targetFilePath,
                              PreviewMode = true,
                              Overwrite   = true,
                              Height      = THUMB_HEIGHT,
                              Timeout     = TimeSpan.FromMinutes(5)
                          };
                    if (metadata.Video.Size.Height > 0)
                    {
                        double factor = (double)metadata.Video.Size.Width / metadata.Video.Size.Height;
                        command.VideoThumbWidth = (int)Math.Ceiling(command.Height * factor);
                    }

                    if (!command.Run())
                    {
                        return(0);
                    }
                }
                catch
                {
                    FileHelper.Delete(targetFilePath);
                    return(0);
                }
            }

            int videoThumbWidth = 0;

            if (metadata.Video.Size.Height > 0)
            {
                double factor = (double)metadata.Video.Size.Width / metadata.Video.Size.Height;
                videoThumbWidth = (int)Math.Ceiling(THUMB_HEIGHT * factor);
            }

            return(videoThumbWidth);
        }
コード例 #2
0
        public static int GenerateThumbnail(string videoPath, string targetFilePath, Metadata metadata = null)
        {
            if (string.IsNullOrEmpty(videoPath) || !File.Exists(videoPath) || string.IsNullOrEmpty(targetFilePath))
            {
                return(0);
            }

            if (metadata?.Video == null)
            {
                using FastMetadataCommand command = new FastMetadataCommand
                      {
                          Input = videoPath
                      };
                if (!command.Run())
                {
                    return(0);
                }
                metadata = command.Metadata;
            }

            if (metadata?.Video == null)
            {
                return(0);
            }

            if (!File.Exists(targetFilePath))
            {
                try
                {
                    using ThumbnailCommand command = new ThumbnailCommand
                          {
                              Input     = videoPath,
                              Output    = targetFilePath,
                              Overwrite = true,
                              Height    = THUMB_HEIGHT,
                              Timeout   = TimeSpan.FromMinutes(5)
                          };
                    // this f**k twat didn't create the thumb! maybe the duration is too little or it didn't find scene changes (boring video!)
                    if (!command.Run() || !File.Exists(targetFilePath))
                    {
                        // OK, let's give it another try with fixed time scan
                        command.Seek        = TimeSpan.FromSeconds(1);
                        command.SceneFilter = -1.0f;
                        if (!command.Run() || !File.Exists(targetFilePath))
                        {
                            return(0);
                        }
                    }
                }
                catch
                {
                    FileHelper.Delete(targetFilePath);
                    return(0);
                }
            }

            int videoThumbWidth = 0;

            if (metadata.Video.Size.Height > 0)
            {
                double factor = (double)metadata.Video.Size.Width / metadata.Video.Size.Height;
                videoThumbWidth = (int)Math.Ceiling(THUMB_HEIGHT * factor);
            }

            return(videoThumbWidth);
        }
コード例 #3
0
	void HandleUpdateThumbnailCommand (object sender, EventArgs args)
	{
		ThumbnailCommand command = new ThumbnailCommand (main_window);

		int [] selected_ids = SelectedIds ();
		if (command.Execute (SelectedPhotos (selected_ids)))
#if MONO_1_9_0
			query.MarkChanged (selected_ids, new PhotoChanges {DataChanged = true});
#else
		{
			PhotoChanges changes = new PhotoChanges ();
			changes.DataChanged = true;
			query.MarkChanged (selected_ids, changes);
		}
#endif
	}
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: mono/f-spot
		void HandleUpdateThumbnailCommand (object sender, EventArgs args)
		{
			ThumbnailCommand command = new ThumbnailCommand (main_window);

			int[] selected_ids = SelectedIds ();
			if (command.Execute (SelectedPhotos (selected_ids)))
				query.MarkChanged (selected_ids, InvalidateData.Instance);
		}
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: iainlane/f-spot
        void HandleUpdateThumbnailCommand(object sender, EventArgs args)
        {
            ThumbnailCommand command = new ThumbnailCommand (main_window);

            int [] selected_ids = SelectedIds ();
            if (command.Execute (SelectedPhotos (selected_ids)))
                query.MarkChanged (selected_ids, new PhotoChanges {DataChanged = true});
        }
コード例 #6
0
	void HandleUpdateThumbnailCommand (object sende, EventArgs args)
	{
		ThumbnailCommand command = new ThumbnailCommand (main_window);

		int [] selected_ids = SelectedIds ();
		if (command.Execute (SelectedPhotos (selected_ids))) {
			foreach (int num in selected_ids)
				query.MarkChanged (num);
		}
	}