public void FromVegas(Vegas vegas) { string rendererName = Script.Args.ValueOf("renderer"); string templateName = Script.Args.ValueOf("template"); Renderer renderer = vegas.Renderers.FindByName(rendererName); RenderTemplate template = null; if (renderer != null) { template = renderer.Templates.FindByName(templateName); } if (template == null) { vegas.ShowError("Render template not found."); return; } string path = vegas.Project.FilePath; string saveas = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + ".rendered.mp4"; RenderStatus status = vegas.Render(saveas, template); if (status == RenderStatus.Complete || status == RenderStatus.Canceled || status == RenderStatus.Quit) { vegas.Exit(); } else { vegas.ShowError("Render incomplete. Please try again."); return; } }
public void FromVegas(Vegas vegas) { string rendererName = Script.Args.ValueOf("renderer"); string templateName = Script.Args.ValueOf("template"); string saveas = Script.Args.ValueOf("saveas", true); Renderer renderer = vegas.Renderers.FindByName(rendererName); RenderTemplate template = null; if (renderer != null) { template = renderer.Templates.FindByName(templateName); } if (template == null) { vegas.ShowError("Render template not found."); return; } if (string.IsNullOrWhiteSpace(saveas)) { SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = ".mp4 file (*.mp4)|*.mp4", Title = "Select render location", InitialDirectory = vegas.Project.FilePath, CheckPathExists = true, AddExtension = true }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { saveas = Path.GetFullPath(saveFileDialog.FileName); } } if (string.IsNullOrWhiteSpace(saveas)) { vegas.ShowError("No valid save path exists."); return; } RenderStatus status = vegas.Render(saveas, template); if (status == RenderStatus.Complete || status == RenderStatus.Canceled || status == RenderStatus.Quit) { vegas.Exit(); } else { vegas.ShowError("Render incomplete. Please try again."); return; } }
public void FromVegas(Vegas vegas) { try { _vegas = vegas; Track track = vegas.Project.AddVideoTrack(); PlugInNode generator = vegas.Generators.GetChildByName("VEGAS Titles & Text"); foreach (var region in vegas.Project.Regions) { string text = region.Label; VideoEvent e = new VideoEvent(vegas.Project, Timecode.FromMilliseconds(region.Position.ToMilliseconds()), region.Length, null); track.Events.Add(e); e.FadeIn.Curve = CurveType.Linear; e.FadeOut.Curve = CurveType.Linear; text = HandleAegisubTags(e, text); CreateTextPreset("RegionsToTextbox", "Impress BT", 14, 0.5, 0.08, 10.0, text); Media media = new Media(generator, "RegionsToTextbox"); MediaStream stream = media.Streams[0]; Take take = new Take(stream); e.Takes.Add(take); } } catch (Exception e) { vegas.ShowError(e); } }
/// Implementation /// /// private void RegionsNudge(Timecode Time, bool Cumulative) { Timecode ZeroTime = myVegas.Project.Ruler.StartTime; Timecode Adjustment = Time; if (Cumulative) { Adjustment = Timecode.FromSeconds(0); } var Groups = myVegas.GetRegionGroups(); using (var undo = new UndoBlock("Nudge regions by " + Time)) { foreach (var group in Groups) { Timecode newTime = group.Region.Position + Adjustment; Timecode localAdjustment = Timecode.FromSeconds(0); // zero time detection if (newTime < ZeroTime) { if (ScriptOptions.GetValue(Strings.ScriptName, "ShowZeroTimeWarning", true)) { myVegas.ShowError("Cannot move beyond start of timeline", "Your operation was aborted to avoid moving events outside the timeline"); } return; } // collision detection foreach (var grp in Groups) { if (!grp.Equals(@group)) { if (newTime <= grp.Region.End && newTime >= grp.Region.Position) { localAdjustment = newTime - grp.Region.End; break; } } } group.MoveTo(newTime - localAdjustment); if (Cumulative) { Adjustment += Time; } } } }
public void FromVegas(Vegas vegas) { Settings = new Settings(); // ********* Change default script paremeters here Settings.CrossFadeLength = 500; // Set default crossfade lenght here Settings.TimeUnit = TimeUnit.Milliseconds; // Set crossfade's time unit: milliseconds or frames Settings.ScriptMode = ScriptMode.CreateNewCrossfades; Settings.ChangeCurveType = false; // Set to true to be able to change curve types Settings.LeftCurveType = CurveType.Slow; // Left curve type: Fast, Linear, Sharp, Slow, Smooth. Vegas's default is Slow for audio and Smooth for video Settings.RightCurveType = CurveType.Fast; // Right curve type: Fast, Linear, Sharp, Slow, Smooth. Vegas's default is Fast for audio and Smooth for video Settings.TransitionMode = TransitionMode.NoTransition; // Add/Remove transision to video events. Chose NoTransition, AddTransition, RemoveTransition of Scanning for available transition presets for the first time may be slow Settings.AllowLoops = false; // Allow crossfades to expand beyond clip's original length Settings.ShowDialog = true; // Show dialog window or run the script with these settings without user prompt Settings.TransitionAndPresetName = ""; //Put transition and preset names here, e.g. "VEGAS Portals\\Mondrian" if you use the script non-interactively by changing Settings.ShowDialog to true // ********* Do no change anything below unless you know what you're doing Settings.Vegas = vegas; try { if (Settings.ShowDialog) { var form = new CrossFaderForm(Settings); var dialogResult = form.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } } if (Settings.TransitionMode == TransitionMode.AddTransition && Settings.ShowDialog == false && string.IsNullOrEmpty(Settings.TransitionAndPresetName)) { throw new Exception("The script needs to know what transition preset to use. To apply video transitions in silent mode edit TransitionAndPresetName settings property, for example:\n\n" + "Settings.TransitionAndPresetName = \"VEGAS Portals\\\\Mondrian\";"); } if (Settings.TransitionMode == TransitionMode.AddTransition) { FindTransition(); } Timecode CrossFade = null; Timecode HalfCrossFade = null; switch (Settings.TimeUnit) { case TimeUnit.Milliseconds: CrossFade = Timecode.FromMilliseconds(Settings.CrossFadeLength); HalfCrossFade = Timecode.FromMilliseconds(Settings.CrossFadeLength / 2); break; case TimeUnit.Frames: CrossFade = Timecode.FromFrames(Settings.CrossFadeLength); HalfCrossFade = Timecode.FromFrames(Settings.CrossFadeLength / 2); break; } foreach (Track track in vegas.Project.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if (trackEvent.Selected) { switch (Settings.ScriptMode) { case ScriptMode.CreateNewCrossfades: CreateCrossFades(trackEvent, track, HalfCrossFade); break; case ScriptMode.ChangeExistingCrossfades: ChangeExistingCrossFades(trackEvent, track); break; case ScriptMode.RemoveCrossfades: RemoveCrossFades(trackEvent, track); break; } if (trackEvent.IsVideo()) { switch (Settings.TransitionMode) { case TransitionMode.AddTransition: AddTransition(trackEvent); break; case TransitionMode.RemoveTransition: trackEvent.FadeIn.RemoveTransition(); break; } } } } } } catch (Exception ex) { vegas.ShowError(ex); } }