Add Media FX to selected files in media pool

cold-ones wrote on 2/10/2011, 12:26 PM
To match several different cameras during a multicam shoot, I'd like to be able to easily add Media FX filters to my files. It's a simple rewrite of the "Add Timecode to All Media" script, but try as I might I can't figure out why it stops at line 23. For anyone who has a moment, I'd appreciate a look:

/**
* This script will add a video effect to each selected item
* in the current project's media pool.
*
* Revision Date:
**/

using System;
using Sony.Vegas;

class EntryPoint
{
//name of desired FX plugin
string plugInName = "Sony Brightness and Contrast";

// presetName is the name of the preset you want to use. Set it to
// null if you want the default preset.
string presetName = "Brighter";

public void FromVegas(Vegas vegas)
{

PlugInNode fx = Vegas.VideoFX;

PlugInNode plugIn = fx.GetChildByName.plugInName.presetName;
if (null == plugIn)
{
throw new ArgumentException("could not find a plug-in", plugInName);
}

foreach (Media media in vegas.Project.MediaPool.GetSelectedMedia())
{
// only add the effect if the media object has video
if (!media.HasVideo())
continue;
// and if it does not already have the effect
if (MediaHasEffect(media, plugIn))
continue;
Effect effect = new Effect(plugIn);
media.Effects.Add(effect);
if (null != presetName)
effect.Preset = presetName;
}
}

public bool MediaHasEffect(Media media, PlugInNode plugIn)
{
foreach (Effect effect in media.Effects)
{
if (effect.PlugIn == plugIn)
return true;
}
return false;
}

}


Sorry I can't format this code properly, the Sony Forum Preview Tool site doesn't seem to exist anymore...

Comments

jetdv wrote on 2/10/2011, 12:41 PM
You have a capital V on "Vegas" instead of a lower-case v "vegas".
cold-ones wrote on 2/10/2011, 12:55 PM
Thanksfor taking a look, Edward

I changed to a lower case "V":
PlugInNode fx = vegas.VideoFX;

Still get an error message:
(25) : 'Sony.Vegas.PlugInNode.GetChildByName(string)' is a 'method', which is not valid in the given context

Afraid I'm in over my head...
jetdv wrote on 2/11/2011, 7:59 AM
I did not look at the content of the actual script - just what would be causing that one line to error. The problem is now on the next line of the script. You have:

PlugInNode plugIn = fx.GetChildByName.plugInName.presetName;

Instead, it should be:

PlugInNode plugIn = fx.GetChildByName(plugInName);
cold-ones wrote on 2/11/2011, 11:20 AM
Works great, I tip my hat to you!