From 43fa613fffc46d5781c4a8e9165275274e6bc1d1 Mon Sep 17 00:00:00 2001 From: delthas Date: Sun, 11 Oct 2020 16:26:48 +0200 Subject: [PATCH] fix Xvid detection on systems with custom Program Files path also render clips from the Render script to aa user-chosen folder instead of the default Vegas local folder. closes #4 --- Datamix.cs | 14 +++++++++++--- Datamosh.cs | 12 ++++++++++-- Render.cs | 7 ++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Datamix.cs b/Datamix.cs index d5cbee6..064175c 100644 --- a/Datamix.cs +++ b/Datamix.cs @@ -134,8 +134,8 @@ private void Encode(Vegas vegas, string scriptDirectory, RenderArgs renderArgs, } }; encode.Start(); - var output = encode.StandardOutput.ReadToEnd(); var error = encode.StandardError.ReadToEnd(); + var output = encode.StandardOutput.ReadToEnd(); Debug.WriteLine(output); Debug.WriteLine("---------------------"); Debug.WriteLine(error); @@ -168,8 +168,16 @@ public void FromVegas(Vegas vegas) { return; } - const string xvidCheckPath = @"C:\Program Files (x86)\Xvid\uninstall.exe"; - if (!File.Exists(xvidCheckPath)) { + var xvidPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); + if (string.IsNullOrEmpty(xvidPath)) { + xvidPath = Environment.GetEnvironmentVariable("ProgramFiles"); + } + if (string.IsNullOrEmpty(xvidPath)) { + MessageBox.Show("Couldn't get Xvid install path!"); + return; + } + xvidPath += @"\Xvid\uninstall.exe"; + if (!File.Exists(xvidPath)) { MessageBox.Show( "Xvid codec not installed. The script will install it now and may ask for admin access to install it."); var xvid = new Process { diff --git a/Datamosh.cs b/Datamosh.cs index c41a502..b207ff1 100644 --- a/Datamosh.cs +++ b/Datamosh.cs @@ -127,8 +127,16 @@ public void FromVegas(Vegas vegas) { return; } - const string xvidCheckPath = @"C:\Program Files (x86)\Xvid\uninstall.exe"; - if (!File.Exists(xvidCheckPath)) { + var xvidPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); + if (string.IsNullOrEmpty(xvidPath)) { + xvidPath = Environment.GetEnvironmentVariable("ProgramFiles"); + } + if (string.IsNullOrEmpty(xvidPath)) { + MessageBox.Show("Couldn't get Xvid install path!"); + return; + } + xvidPath += @"\Xvid\uninstall.exe"; + if (!File.Exists(xvidPath)) { MessageBox.Show( "Xvid codec not installed. The script will install it now and may ask for admin access to install it."); var xvid = new Process { diff --git a/Render.cs b/Render.cs index 94d192b..6e09a67 100644 --- a/Render.cs +++ b/Render.cs @@ -188,13 +188,10 @@ public void FromVegas(Vegas vegas) { "RenderClipFolder", finalFolder, RegistryValueKind.String); } - var path = Path.Combine(vegas.TemporaryFilesPath, Path.GetFileNameWithoutExtension(vegas.Project.FilePath) + + var path = Path.Combine(finalFolder, Path.GetFileNameWithoutExtension(vegas.Project.FilePath) + "-" + Guid.NewGuid().ToString("B").ToUpper().Substring(1, 8) + ".avi"); - var pathEncoded = Path.Combine(vegas.TemporaryFilesPath, - Path.GetFileNameWithoutExtension(vegas.Project.FilePath) + "-" + - Guid.NewGuid().ToString("B").ToUpper().Substring(1, 8) + ".avi"); var renderArgs = new RenderArgs { OutputFile = path, @@ -208,7 +205,7 @@ public void FromVegas(Vegas vegas) { return; } - File.Delete(pathEncoded + ".sfl"); + File.Delete(path + ".sfl"); var media = vegas.Project.MediaPool.AddMedia(path);