www.jetdv.com Forum Index Edward Troxel
Vegas Scripting and Newsletters
Home of Excalibur and Montage Magic
 
 FAQ   Search   Memberlist   Usergroups   Register   Profile 
 Log in to check your private messagesLog in to check your private messages   Log inLog in 

Save Snapshot at Cursor

 
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Free Scripts
View previous topic :: View next topic  
Author Message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Tue Jul 05, 2005 8:18 pm    Post subject: Save Snapshot at Cursor Reply with quote

This script will save a snapshot at the cursor location. It will give you the option of browsing to a save location, name the file, and choose between PNG and JPG.

http://www.jetdv.com/scripts/SnapshotToFile.js
Back to top
View user's profile Send private message Send e-mail
cooldraft



Joined: 09 Dec 2004
Posts: 249
Location: Oklahoma City

PostPosted: Tue Feb 21, 2006 2:34 am    Post subject: at what quality? Reply with quote

I realize that the preview window whas everything to do with the size and quality of the jpg. Thats why I usually turn draft on then find the desired still and turn best quality back on and then snap a pic. Is there a way to make the pic BEST quality in a script?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Tue Feb 21, 2006 2:47 am    Post subject: Reply with quote

Quote:
Is there a way to make the pic BEST quality in a script?


That's the REASON for using a script! Don't worry about changing anything. Just run the script.

The script automatically changes several settings to give you the absolute best image you can get (including changing the preview mode to "Best (Full)").

When finished, it changes all the settings back to your original settings so you won't be wondering why your settings all changed.
Back to top
View user's profile Send private message Send e-mail
BScott



Joined: 24 Feb 2006
Posts: 40
Location: Charlotte, NC

PostPosted: Wed Jun 13, 2007 3:32 pm    Post subject: Reply with quote

Is there a line I can add to the script to place the new still in the Project Media?
_________________
Brian W. Scott
President
Image Design
Back to top
View user's profile Send private message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Wed Jun 13, 2007 8:45 pm    Post subject: Reply with quote

It's a little more complicated than "1 line". It can be done but it would take several lines of code.
Back to top
View user's profile Send private message Send e-mail
antonbeard



Joined: 01 Apr 2006
Posts: 7
Location: Latvia, Riga

PostPosted: Wed Oct 31, 2007 9:18 pm    Post subject: Reply with quote

Why does this script work wrong in vegas 8? a picture is saved at first, and only after set FullSize?
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Wed Oct 31, 2007 9:32 pm    Post subject: Reply with quote

I haven't actually tested it in Vegas 8 but it should work the same as it did in all previous versions. What do you see it doing/not doing so I can test it out on this end?

Here's what it should be doing:

    Ask for output save location/name
    Set preview and other settings for best optimal image
    Save the snapshot
    Reset preview and other settings
Back to top
View user's profile Send private message Send e-mail
antonbeard



Joined: 01 Apr 2006
Posts: 7
Location: Latvia, Riga

PostPosted: Mon Nov 12, 2007 1:33 pm    Post subject: Reply with quote

Yes, in Vegas 7 this script work this way, but in Vegas 8 this work:

Ask for output save location/name
Save the snapshot
Set preview and other settings for best optimal image
Reset preview and other settings
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Mon Nov 12, 2007 5:32 pm    Post subject: Reply with quote

It can't do it out of order because it actually changes the preview for best optimal output BEFORE it even asks where to save the file.
Back to top
View user's profile Send private message Send e-mail
antonbeard



Joined: 01 Apr 2006
Posts: 7
Location: Latvia, Riga

PostPosted: Thu Nov 15, 2007 12:59 am    Post subject: Reply with quote

well, just test it in Vegas 8 Very Happy
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Thu Nov 15, 2007 2:17 pm    Post subject: Reply with quote

Interesting........ it came out small.

Here's a small change that will allow it to work correctly again:

Between

Vegas.Project.Video.DeinterlaceMethod = VideoDeinterlaceMethod.InterpolateFields;

and

// Show the script's dialog box.


Add this line:

Vegas.UpdateUI();



That let it generate the proper sized image for me.

Download the updated script here!

So the final script will now read:



Code:
/*******************************************
 * This script will save a snapshot from the timeline
 *
 * Written By: Edward Troxel - partially modified from the script by Joe Satcher
 * www.jetdv.com
 *******************************************/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

// Where should the file be saved?
var destdir = "C:\\";

// What is the file name?
var destname = "MyPic";


// Save the current settings
var origPreviewRenderQuality = Vegas.Project.Preview.RenderQuality;
var origPreviewFillSize = Vegas.Project.Preview.FullSize;
var origFieldOrder = Vegas.Project.Video.FieldOrder;
var origProjectDeinterlaceMethod = Vegas.Project.Video.DeinterlaceMethod;
var currentTime = Vegas.Cursor;


try {
  var imageFileName = destdir + destname + ".png";


  // Set for the best quality.
  Vegas.Project.Preview.RenderQuality = VideoRenderQuality.Best;
  Vegas.Project.Preview.FullSize = true;
  Vegas.Project.Video.FieldOrder = VideoFieldOrder.ProgressiveScan;
  Vegas.Project.Video.DeinterlaceMethod = VideoDeinterlaceMethod.InterpolateFields;

  Vegas.UpdateUI();

  // Show the script's dialog box.
  var dialog = new SaveFileDialog();
  dialog.Filter = "PNG File (*.png)|*.png|JPEG File (*.jpg)|*.jpg";
  dialog.CheckPathExists = true;
  dialog.AddExtension = true;
  if (Directory.Exists(destdir)) {
    dialog.InitialDirectory = destdir;
  }
  dialog.DefaultExt = Path.GetExtension(imageFileName);
  dialog.FileName = Path.GetFileNameWithoutExtension(imageFileName);

  // if the OK button was pressed...
  if (dialog.ShowDialog() == DialogResult.OK) {
  // Get the basis for output image file names
    imageFileName = Path.GetFullPath(dialog.FileName);

    // Get the output image file name extension
    var imageFileNameExt = Path.GetExtension(imageFileName);
    var imageFormat = ImageFileFormat.PNG;
    if (0 == String.Compare(imageFileNameExt, ".jpg", true)) {
      imageFormat = ImageFileFormat.JPEG;
    }

    // save a snapshot.
    if (Vegas.SaveSnapshot(imageFileName, imageFormat, Vegas.Cursor) == RenderStatus.Complete) {
      Vegas.UpdateUI();
    }
  }
} catch (e) {
  MessageBox.Show(e);
}

// restore the project and preview settings
Vegas.Project.Preview.RenderQuality = origPreviewRenderQuality;
Vegas.Project.Preview.FullSize = origPreviewFillSize;
Vegas.Project.Video.FieldOrder = origFieldOrder;
Vegas.Project.Video.DeinterlaceMethod = origProjectDeinterlaceMethod;


Last edited by Edward Troxel on Wed Feb 20, 2008 8:34 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
antonbeard



Joined: 01 Apr 2006
Posts: 7
Location: Latvia, Riga

PostPosted: Fri Nov 16, 2007 6:00 pm    Post subject: Reply with quote

Yes, it works, many thanks Edward! Very Happy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Free Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group