public static string createSimpleAvisynthScript(string filename) { PossibleSources sourceType = PossibleSources.directShow; if (filename.ToLower().EndsWith(".vdr")) { sourceType = PossibleSources.vdr; } string outputFile = filename + ".avs"; if (File.Exists(outputFile)) { DialogResult response = MessageBox.Show("The file, '" + outputFile + "' already exists.\r\n Do you want to overwrite it?", "File already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (response == DialogResult.No) { return(null); } } try { StreamWriter output = new StreamWriter(outputFile); output.WriteLine( ScriptServer.GetInputLine(filename, false, sourceType, false, false, false, -1)); output.Close(); } catch (IOException) { return(null); } return(outputFile); }
public static string GetInputLine(string input, bool interlaced, PossibleSources sourceType, bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps) { string inputLine = "#input"; // FileInfo fi = new FileInfo(input); // long size = fi.Length; switch (sourceType) { case PossibleSources.d2v: inputLine = "DGDecode_mpeg2source(\"" + input + "\""; if (mpeg2deblock) { inputLine += ",cpu=4"; } if (colormatrix) { inputLine += ",info=3"; } inputLine += ")"; if (colormatrix) { inputLine += string.Format("\r\nColorMatrix(hints=true{0})", interlaced ? ",interlaced=true" : ""); } break; case PossibleSources.vdr: inputLine = "AVISource(\"" + input + "\", audio=false)"; break; case PossibleSources.directShow: if (input.ToLower().EndsWith(".avi")) { if (input.Length >= 268435456) // 1GB = 134217728 bytes { inputLine = "OpenDMLSource(\"" + input + "\", audio=false)"; } else { inputLine = "AVISource(\"" + input + "\", audio=false)"; } } else { inputLine = "DirectShowSource(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ", audio=false)"; if (flipVertical) { inputLine = inputLine + "\r\nFlipVertical()"; } } break; } return(inputLine); }
public static string GetInputLine(string input, PossibleSources sourceType, bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps) { string inputLine = "#input"; switch (sourceType) { case PossibleSources.d2v: inputLine = "DGDecode_mpeg2source(\"" + input + "\""; if (mpeg2deblock) { inputLine += ",cpu=4"; } if (colormatrix) { inputLine += ",info=3"; } inputLine += ")"; if (colormatrix) { inputLine += "\r\nColorMatrix(hints=true)"; } break; case PossibleSources.vdr: inputLine = "AviSource(\"" + input + "\")"; break; case PossibleSources.directShow: inputLine = "DirectShowSource(\"" + input + "\"" + ((fps > 0) ? ",fps=" + fps.ToString(new CultureInfo("en-us")) : string.Empty) + ",audio=false)"; if (flipVertical) { inputLine = inputLine + "\r\nFlipVertical()"; } break; } return(inputLine); }
public static string GetInputLine(string input, string indexFile, bool interlaced, PossibleSources sourceType, bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps, bool dss2) { string inputLine = "#input"; string strDLLPath = ""; switch (sourceType) { case PossibleSources.avs: inputLine = "Import(\"" + input + "\")"; break; case PossibleSources.d2v: if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgIndexPath), "DGDecode.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGDecode_mpeg2source(\"" + indexFile + "\""; if (mpeg2deblock) { inputLine += ", cpu=4"; } if (colormatrix) { inputLine += ", info=3"; } inputLine += ")"; if (colormatrix) { inputLine += string.Format("\r\nLoadPlugin(\"" + Path.Combine(MainForm.Instance.Settings.AvisynthPluginsPath, "ColorMatrix.dll") + "\")\r\nColorMatrix(hints=true{0}, threads=0)", interlaced ? ", interlaced=true" : ""); } break; case PossibleSources.dga: if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgavcIndexPath), "DGAVCDecode.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nAVCSource(\"" + indexFile + "\")"; break; case PossibleSources.dgi: if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgnvIndexPath), "DGDecodeNV.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSource(\"" + indexFile + "\""; if (MainForm.Instance.Settings.AutoForceFilm && MainForm.Instance.Settings.ForceFilmThreshold <= (decimal)dgiFile.GetFilmPercent(indexFile)) { inputLine += ",fieldop=1"; } else { inputLine += ",fieldop=0"; } break; case PossibleSources.ffindex: strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.FFMSIndexPath), "ffms2.dll"); if (input.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".ffindex")) { inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input.Substring(0, input.Length - 8) + "\"" + (MainForm.Instance.Settings.FFMSThreads > 0 ? ", threads=" + MainForm.Instance.Settings.FFMSThreads : String.Empty) + ")"; } else if (!String.IsNullOrEmpty(indexFile)) { inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input + "\"" + (!string.IsNullOrEmpty(indexFile) ? ", cachefile=\"" + indexFile + "\"" : String.Empty) + (MainForm.Instance.Settings.FFMSThreads > 0 ? ", threads=" + MainForm.Instance.Settings.FFMSThreads : String.Empty) + ")"; } else { inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input + "\"" + (MainForm.Instance.Settings.FFMSThreads > 0 ? ", threads=" + MainForm.Instance.Settings.FFMSThreads : String.Empty) + ")"; } break; case PossibleSources.vdr: inputLine = "AVISource(\"" + input + "\", audio=false)" + VideoUtil.getAssumeFPS(fps, input); break; case PossibleSources.directShow: if (input.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".avi")) { inputLine = "AVISource(\"" + input + "\", audio=false)" + VideoUtil.getAssumeFPS(fps, input); } else { if (dss2) { inputLine = "LoadPlugin(\"" + MeGUISettings.HaaliMSPath + "\\avss.dll" + "\")\r\ndss2(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ")" + VideoUtil.getAssumeFPS(fps, input); } else { inputLine = "LoadPlugin(\"" + Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.AviSynthPath), "directshowsource.dll") + "\")\r\nDirectShowSource(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ", audio=false, convertfps=true)" + VideoUtil.getAssumeFPS(fps, input); } if (flipVertical) { inputLine = inputLine + "\r\nFlipVertical()"; } } break; } return(inputLine); }
/// <summary> /// Opens a video source using the correct method based on the extension of the file name /// </summary> /// <param name="videoInput"></param> private void openVideoSource(string videoInput) { string projectPath; string fileNameNoPath = Path.GetFileName(videoInput); if (string.IsNullOrEmpty(projectPath = mainForm.Settings.DefaultOutputDir)) projectPath = Path.GetDirectoryName(videoInput); videoOutput.Filename = Path.Combine(projectPath, Path.ChangeExtension(fileNameNoPath, ".avs")); if (File.Exists(videoInput + ".ffindex")) { sourceType = PossibleSources.ffindex; openVideo(videoInput + ".ffindex"); } else { string ext = Path.GetExtension(videoInput).ToLower(); switch (ext) { case ".avs": sourceType = PossibleSources.avs; videoOutput.Filename = Path.Combine(projectPath, Path.ChangeExtension(fileNameNoPath, "_new.avs")); // to avoid overwritten openAVSScript(videoInput); break; case ".d2v": sourceType = PossibleSources.d2v; openVideo(videoInput); break; case ".dga": sourceType = PossibleSources.dga; openVideo(videoInput); break; case ".dgi": sourceType = PossibleSources.dgi; if (VideoUtil.manageCUVIDServer()) openVideo(videoInput); break; case ".ffindex": sourceType = PossibleSources.ffindex; openVideo(videoInput); break; case ".mpeg": // include case variants case ".mpg": case ".m2v": case ".m2p": case ".mpv": case ".ts": case ".tp": case ".vob": sourceType = PossibleSources.mpeg2; if (gotoD2vCreator(videoInput) == DialogResult.Cancel ) { sourceType = PossibleSources.directShow; openDirectShow(videoInput); } break; case ".vdr": sourceType = PossibleSources.vdr; openVDubFrameServer(videoInput); break; default: sourceType = PossibleSources.directShow; openDirectShow(videoInput); break; } } setSourceInterface(); }
public static string GetInputLine(string input, bool interlaced, PossibleSources sourceType, bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps, bool dss2) { string inputLine = "#input"; string strDLLPath = ""; switch (sourceType) { case PossibleSources.avs: inputLine = "Import(\"" + input + "\")"; break; case PossibleSources.d2v: strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgIndexPath), "DGDecode.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGDecode_mpeg2source(\"" + input + "\""; if (mpeg2deblock) inputLine += ", cpu=4"; if (colormatrix) inputLine += ", info=3"; inputLine += ")"; if (colormatrix) inputLine += string.Format("\r\nLoadPlugin(\"" + Path.Combine(MainForm.Instance.Settings.AvisynthPluginsPath, "ColorMatrix.dll") + "\")\r\nColorMatrix(hints=true{0}, threads=0)", interlaced ? ", interlaced=true" : ""); break; case PossibleSources.dga: strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgavcIndexPath), "DGAVCDecode.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nAVCSource(\"" + input + "\")"; break; case PossibleSources.ffindex: strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.FFMSIndexPath), "ffms2.dll"); if (input.ToLower().EndsWith(".ffindex")) inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input.Substring(0, input.Length - 8) + "\",colorspace=\"YV12\")"; else inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input + "\",colorspace=\"YV12\")"; if (input.ToLower().EndsWith(".ffindex")) inputLine = "LoadCPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input.Substring(0, input.Length - 8) + "\",colorspace=\"YV12\")"; else inputLine = "LoadCPlugin(\"" + strDLLPath + "\")\r\nFFVideoSource(\"" + input + "\",colorspace=\"YV12\")"; break; case PossibleSources.dgi: if (MainForm.Instance.Settings.UseCUVIDserver == true) { strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgnvIndexPath), "DGDecodeNV.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSource(\"" + input + "\""; } else { strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DgnvIndexPath), "DGMultiDecodeNV.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGMultiSource(\"" + input + "\""; } if (MainForm.Instance.Settings.AutoForceFilm && MainForm.Instance.Settings.ForceFilmThreshold <= (decimal)dgiFile.GetFilmPercent(input)) inputLine += ",fieldop=1"; else inputLine += ",fieldop=0"; break; case PossibleSources.vdr: inputLine = "AVISource(\"" + input + "\", audio=false)"; break; case PossibleSources.directShow: if (input.ToLower().EndsWith(".avi")) { inputLine = "AVISource(\"" + input + "\", audio=false)"; } else { if (dss2) inputLine = "LoadPlugin(\"" + MeGUISettings.HaaliMSPath + "\\avss.dll" + "\")\r\ndss2(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ")"; else inputLine = "DirectShowSource(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ", audio=false, convertfps=true)"; if (flipVertical) inputLine = inputLine + "\r\nFlipVertical()"; } break; } return inputLine; }
public static string GetInputLine(string input, string indexFile, bool interlaced, PossibleSources sourceType, bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps, bool dss2, NvDeinterlacerType nvDeintType, int nvHorizontalResolution, int nvVerticalResolution, CropValues nvCropValues) { string inputLine = "#input"; string strDLLPath = ""; switch (sourceType) { case PossibleSources.avs: inputLine = "Import(\"" + input + "\")"; break; case PossibleSources.d2v: UpdateCacher.CheckPackage("dgindex"); if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndex.Path), "DGDecode.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGDecode_mpeg2source(\"" + indexFile + "\""; if (mpeg2deblock) { inputLine += ", cpu=4"; } if (colormatrix) { inputLine += ", info=3"; } inputLine += ")"; if (colormatrix) { inputLine += string.Format("\r\nLoadPlugin(\"" + Path.Combine(MainForm.Instance.Settings.AvisynthPluginsPath, "ColorMatrix.dll") + "\")\r\nColorMatrix(hints=true{0}, threads=0)", interlaced ? ", interlaced=true" : ""); } break; case PossibleSources.dgm: UpdateCacher.CheckPackage("dgindexim"); if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndexIM.Path), "dgdecodeim.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSourceIM(\"" + indexFile + "\", silent=true)"; if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit) { inputLine += "\r\nConvertBits(8)"; } break; case PossibleSources.dgi: UpdateCacher.CheckPackage("dgindexnv"); if (String.IsNullOrEmpty(indexFile)) { indexFile = input; } strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndexNV.Path), "DGDecodeNV.dll"); inputLine = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSource(\"" + indexFile + "\""; if (MainForm.Instance.Settings.AutoForceFilm && MainForm.Instance.Settings.ForceFilmThreshold <= (decimal)dgiFile.GetFilmPercent(indexFile)) { inputLine += ",fieldop=1"; // fieldop=0 is the default value } if (nvDeintType != NvDeinterlacerType.nvDeInterlacerNone) { inputLine += ScriptServer.GetNvDeInterlacerLine(true, nvDeintType); } if (nvCropValues != null && nvCropValues.isCropped()) { GetMod4Cropping(ref nvCropValues); inputLine += ", ct=" + nvCropValues.top + ", cb=" + nvCropValues.bottom + ", cl=" + nvCropValues.left + ", cr=" + nvCropValues.right; } if (nvHorizontalResolution > 0 && nvVerticalResolution > 0) { inputLine += ", rw=" + nvHorizontalResolution + ", rh=" + nvVerticalResolution; } inputLine += ")"; if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit) { inputLine += "\r\nConvertBits(8)"; } break; case PossibleSources.ffindex: inputLine = VideoUtil.getFFMSVideoInputLine(input, indexFile, fps); break; case PossibleSources.lsmash: MediaInfoFile oInfo = null; inputLine = VideoUtil.getLSMASHVideoInputLine(input, indexFile, fps, ref oInfo); if (oInfo != null) { oInfo.Dispose(); } break; case PossibleSources.vdr: case PossibleSources.avisource: inputLine = "AVISource(\"" + input + "\", audio=false)" + VideoUtil.getAssumeFPS(fps, input); if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit) { inputLine += "\r\nConvertBits(8)"; } break; case PossibleSources.directShow: if (dss2) { string path = MeGUI.core.util.FileUtil.GetHaaliInstalledPath(); if (!File.Exists(Path.Combine(path, "avss.dll"))) { UpdateCacher.CheckPackage("haali"); path = Path.GetDirectoryName(MainForm.Instance.Settings.Haali.Path); } inputLine = "LoadPlugin(\"" + path + "\\avss.dll" + "\")\r\ndss2(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ")" + VideoUtil.getAssumeFPS(fps, input); } else { inputLine = String.Empty; if (MainForm.Instance.Settings.PortableAviSynth) { inputLine = "LoadPlugin(\"" + Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.AviSynth.Path), @"plugins\directshowsource.dll") + "\")\r\n"; } inputLine += "DirectShowSource(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ", audio=false, convertfps=true)" + VideoUtil.getAssumeFPS(fps, input); } if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit) { inputLine += "\r\nConvertBits(8)"; } if (flipVertical) { inputLine = inputLine + "\r\nFlipVertical()"; } break; } return(inputLine); }