private void StartNewMove() { if (CurTrack.HasValidPath && !CurTrack.ShouldStopCart) { destination = CurTrack.NextTrack(direction, previousTrack); if (destination != null && destination.CanBeTravelledTo) { SetupNewMove(); previousTrack = CurTrack; direction = CurTrack.DirectionTo(destination); if (Direction != Direction.Any && Direction != Direction.Invalid) { moving = true; } } } }
public void FromVegas(Vegas vegas) { if (vegas.Project.Length.ToMilliseconds() == 0) { return; } SetDllDirectory(VegasDir + "\\Script Depends"); string RegKey = "HKEY_CURRENT_USER\\Software\\Sony Creative Software\\Vegas Pro\\frameserver"; int AddBuffer = 1; int RenderLoop = 1; string outputDirectory = ""; try { AddBuffer = (int)Registry.GetValue(RegKey, "AddBuffer", 1); RenderLoop = (int)Registry.GetValue(RegKey, "RenderLoopRegion", 1); outputDirectory = (string)Registry.GetValue(RegKey, "TempDir", ""); } catch {} string outDirDefualt = Environment.GetEnvironmentVariable("TEMP") + "\\frameserver"; if (outputDirectory == "") { outputDirectory = outDirDefualt; } if (!Directory.Exists(outputDirectory)) { try { Directory.CreateDirectory(outputDirectory); } catch { outputDirectory = outDirDefualt; Directory.CreateDirectory(outputDirectory); } } // Start virtual file system, AviSynth and HandBrake ahktextdll(Unzip(Convert.FromBase64String(StartScriptData)), "", ""); while (!ahkReady()) { Thread.Sleep(100); } ahkassign("TempFileDir", outputDirectory); ahkassign("AddBuffer", AddBuffer.ToString()); ahkassign("RegKey", RegKey); ahkassign("VegasDir", VegasDir); ahkPause("Off"); Regex videoRendererRegexp = new Regex(@"DebugMode FrameServer", RegexOptions.Compiled | RegexOptions.IgnoreCase); Regex videoTemplateRegexp = new Regex(@"Project Default", RegexOptions.Compiled | RegexOptions.IgnoreCase); try { //Add an empty event to first video track to solve frameserver audio bug if (AddBuffer > 0) { foreach (Track CurTrack in vegas.Project.Tracks) { if (CurTrack.IsVideo()) { TargetTrack = CurTrack; emptyEvent = new VideoEvent(vegas.Project, vegas.Project.Length, Timecode.FromMilliseconds(1000), null); CurTrack.Events.Add(emptyEvent); break; } } } // Check timeline's loop-region Timecode renderStart = new Timecode(); Timecode renderLength = vegas.Project.Length; if (RenderLoop > 0) { renderStart = vegas.SelectionStart; if (AddBuffer > 0) { renderLength = vegas.SelectionLength + Timecode.FromMilliseconds(1000); } else { renderLength = vegas.SelectionLength; } } //Define export path and file name string projDir, projName, videoOutputFile; string projFile = vegas.Project.FilePath; if ((null == projFile) || (0 == projFile.Length)) { projDir = ""; projName = "Untitled"; } else { projDir = Path.GetDirectoryName(projFile) + Path.DirectorySeparatorChar; projName = Path.GetFileNameWithoutExtension(projFile); } videoOutputFile = outputDirectory + "\\" + OutFileName + ".avi"; if (null == videoOutputFile) { throw new Exception("Process terminated"); } Renderer aviRenderer = FindRenderer(videoRendererRegexp, vegas); if (null == aviRenderer) { throw new Exception("Could not find DebugMode FrameServer"); } // Start export RenderTemplate videoTemplate = FindRenderTemplate(aviRenderer, videoTemplateRegexp, vegas); if (null == videoTemplate) { throw new Exception("Could not find the render preset defined by the script"); } RenderStatus renderStatus = vegas.Render(videoOutputFile, videoTemplate, renderStart, renderLength); if (AddBuffer > 0) { TargetTrack.Events.Remove(emptyEvent); } } catch (Exception ex) { if (AddBuffer > 0) { TargetTrack.Events.Remove(emptyEvent); } MessageBox.Show(ex.ToString()); } }