public void GenerateScript(MediaEncoderSettings settings, bool preview, bool multiThreaded) {
     AviSynthScriptBuilder Script = new AviSynthScriptBuilder(settings.CustomScript);
     if (Script.IsEmpty)
         Script = MediaEncoderScript.GenerateVideoScript(settings, GetPreviewSourceFile(settings), preview, multiThreaded);
     else if (preview) {
         Script.RemoveMT();
         Script.AppendLine(@"ConvertToRGB32(matrix=""Rec709"")");
     } else if (!multiThreaded)
         Script.RemoveMT();
     Script.WriteToFile(PathManager.PreviewScriptFile);
     settings.Save(PathManager.PreviewSettingsFile);
 }
 /// <summary>
 /// Moves specified settings file as preview files.
 /// </summary>
 /// <param name="settings">The settings to use for re-encoding.</param>
 public async Task MovePreviewFilesAsync(MediaEncoderSettings settings) {
     await DeletePreviewFilesAsync();
     if (settings.ConvertToAvi)
         File.Move(settings.InputFile, PathManager.PreviewSourceFile);
     if (settings.Deshaker && File.Exists(settings.DeshakerLog))
         File.Move(settings.DeshakerLog, PathManager.PreviewDeshakerLog);
     if (!string.IsNullOrEmpty(settings.CustomScript) && (settings.ConvertToAvi || settings.Deshaker)) {
         AviSynthScriptBuilder Script = new AviSynthScriptBuilder(settings.CustomScript);
         if (settings.ConvertToAvi)
             Script.Replace(Script.GetAsciiPath(settings.InputFile), Script.GetAsciiPath(PathManager.PreviewSourceFile));
         if (settings.Deshaker)
             Script.Replace(Script.GetAsciiPath(settings.DeshakerLog), Script.GetAsciiPath(PathManager.PreviewDeshakerLog));
         settings.CustomScript = Script.Script;
     }
     settings.Save(PathManager.PreviewSettingsFile);
 }
 public void PrepareJobFiles(MediaEncoderSettings settings) {
     settings.JobIndex = ++JobIndex;
     // Files must be prepared before adding to queue so that user can replace preview files.
     PathManager.DeleteJobFiles(settings.JobIndex);
     File.Delete(PathManager.PreviewScriptFile);
     File.Delete(PathManager.PreviewSettingsFile);
     if (settings.ConvertToAvi)
         PathManager.SafeMove(PathManager.PreviewSourceFile, settings.InputFile);
     if (settings.Deshaker)
         PathManager.SafeMove(PathManager.PreviewDeshakerLog, settings.DeshakerLog);
     settings.Save(settings.SettingsFile);
     AviSynthScriptBuilder Script = new AviSynthScriptBuilder(settings.CustomScript);
     if (Script.IsEmpty)
         Script = MediaEncoderScript.GenerateVideoScript(settings, settings.InputFile, false, true);
     else {
         Script.Replace(Script.GetAsciiPath(PathManager.PreviewSourceFile), Script.GetAsciiPath(settings.InputFile));
         Script.Replace(Script.GetAsciiPath(PathManager.PreviewDeshakerLog), Script.GetAsciiPath(settings.DeshakerLog));
     }
     Script.WriteToFile(settings.ScriptFile);
     // if (settings.DeshakerSettings.PrescanAction == PrescanType.Full)
 }