protected override void RunInThread() { try { // job output file in case of LWLibavVideoSource() base.jobOutputFile = job.Input + ".lwi"; // generate the avs script StringBuilder strAVSScript = new StringBuilder(); MediaInfoFile oInfo = null; strAVSScript.Append(VideoUtil.getLSMASHVideoInputLine(job.Input, job.Output, 0, ref oInfo)); if (oInfo != null) { oInfo.Dispose(); } base.log.LogValue("AviSynth script", strAVSScript.ToString(), ImageType.Information); // check if the script has a video track, also this call will create the index file if there is one string strErrorText = "no video track found"; bool openSuccess = false; try { strErrorText = String.Empty; using (AviSynthScriptEnvironment env = new AviSynthScriptEnvironment()) using (AviSynthClip a = env.ParseScript(strAVSScript.ToString(), false, false)) openSuccess = a.HasVideo; } catch (Exception ex) { strErrorText = ex.Message; } if (!openSuccess) { // avs script has no video track or an error has been thrown base.log.LogEvent(strErrorText, ImageType.Error); su.HasError = true; } } catch (Exception ex) { base.log.LogValue("Error: ", ex.Message, ImageType.Error); su.HasError = true; } }
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); }