Example #1
0
 public AMGMuxer(string executablePath)
 {
     UpdateCacher.CheckPackage("avimux_gui");
     this.executable = executablePath;
 }
Example #2
0
        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);
        }
Example #3
0
 public tsMuxeR(string executablePath)
 {
     UpdateCacher.CheckPackage("tsmuxer");
     this.executable = executablePath;
 }
Example #4
0
        public static UpdateWindow.ErrorState PreparePackageFolder(string packageName)
        {
            ProgramSettings oPackage = UpdateCacher.GetPackage(packageName);

            if (oPackage == null)
            {
                return(UpdateWindow.ErrorState.Successful);
            }

            string packagePath = Path.GetDirectoryName(oPackage.Path);

            if (MainForm.Instance.Settings.AlwaysBackUpFiles)
            {
                try
                {
                    // remove all old backup files found
                    Array.ForEach(Directory.GetFiles(packagePath, "*.backup", SearchOption.AllDirectories), delegate(string path) { File.Delete(path); });
                }
                catch (Exception ex)
                {
                    MainForm.Instance.UpdateHandler.AddTextToLog("Outdated backup version of " + oPackage.DisplayName + " could not be deleted. Check if it is in use. " + ex.Message, ImageType.Error, true);
                    return(UpdateWindow.ErrorState.CouldNotCreateBackup);
                }
            }

            try
            {
                DirectoryInfo fi    = new DirectoryInfo(packagePath);
                FileInfo[]    files = fi.GetFiles("*.*", SearchOption.AllDirectories);
                foreach (FileInfo f in files)
                {
                    // only continue when file can be deleted/renamed
                    bool bFound = false;
                    foreach (string strFile in oPackage.DoNotDeleteFilesOnUpdate)
                    {
                        if (f.FullName.ToLowerInvariant().Equals(strFile.ToLowerInvariant()))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    foreach (string strFolder in oPackage.DoNotDeleteFoldersOnUpdate)
                    {
                        if (f.DirectoryName.ToLowerInvariant().StartsWith(strFolder.ToLowerInvariant()))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (bFound)
                    {
                        continue;
                    }

                    if (!MainForm.Instance.Settings.AlwaysBackUpFiles)
                    {
                        f.Delete();
                    }
                    else
                    {
                        f.MoveTo(Path.Combine(f.Directory.FullName, f.Name + ".backup"));
                    }
                }
            }
            catch (Exception ex)
            {
                MainForm.Instance.UpdateHandler.AddTextToLog("Old version of " + oPackage.DisplayName + " could not be accessed correctly. Check if it is in use. " + ex.Message, ImageType.Error, true);
                return(UpdateWindow.ErrorState.CouldNotCreateBackup);
            }

            return(UpdateWindow.ErrorState.Successful);
        }
Example #5
0
        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:
                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.dga:
                UpdateCacher.CheckPackage("dgavcindex");
                if (String.IsNullOrEmpty(indexFile))
                {
                    indexFile = input;
                }
                strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGAVCIndex.Path), "DGAVCDecode.dll");
                inputLine  = "LoadPlugin(\"" + strDLLPath + "\")\r\nAVCSource(\"" + indexFile + "\")";
                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";
                }
                else
                {
                    inputLine += ",fieldop=0";
                }
                break;

            case PossibleSources.ffindex:
                inputLine = VideoUtil.getFFMSVideoInputLine(input, indexFile, fps);
                break;

            case PossibleSources.lsmash:
                inputLine = VideoUtil.getLSMASHVideoInputLine(input, indexFile, fps);
                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 && File.Exists(Path.Combine(MeGUISettings.HaaliMSPath, "avss.dll")))
                    {
                        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 = 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 (flipVertical)
                    {
                        inputLine = inputLine + "\r\nFlipVertical()";
                    }
                }
                break;
            }
            return(inputLine);
        }
Example #6
0
 public LSMASHIndexer()
 {
     UpdateCacher.CheckPackage("lsmash");
 }
Example #7
0
 public static string getLSMASHAudioInputLine(string inputFile, string indexFile, int track)
 {
     UpdateCacher.CheckPackage("lsmash");
     return(getLSMASHBasicInputLine(inputFile, indexFile, track, 0, 0, 0, false, 8));
 }
Example #8
0
 public FFMSIndexer(string executableName)
 {
     UpdateCacher.CheckPackage("ffms");
     executable = executableName;
 }
Example #9
0
 public static string getFFMSVideoInputLine(string inputFile, string indexFile, double fps)
 {
     UpdateCacher.CheckPackage("ffms");
     GetFPSDetails(fps, inputFile, out int fpsnum, out int fpsden, true, out bool variableFrameRate);
     return(GetFFMSBasicInputLine(!isFFMSDefaultPluginRequired(), inputFile, indexFile, -1, 0, fpsnum, fpsden, true, variableFrameRate));
 }
Example #10
0
 public MP4FpsMod()
 {
     UpdateCacher.CheckPackage("mp4box");
     executable = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.Mp4Box.Path), @"mp4fpsmod\mp4fpsmod.exe");
 }
Example #11
0
 public HDStreamExtractorIndexer(string executablePath)
 {
     UpdateCacher.CheckPackage("eac3to");
     this.executable = executablePath;
 }
Example #12
0
 public ffmpegEncoder(string encoderPath)
     : base()
 {
     UpdateCacher.CheckPackage("ffmpeg");
     executable = encoderPath;
 }
Example #13
0
        public bool extractChapters(String strChapterFile)
        {
            _strResult = null;
            bool bResult = false;

            using (Process mkvinfo = new Process())
            {
                UpdateCacher.CheckPackage("mkvmerge");
                mkvinfo.StartInfo.FileName               = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.MkvMerge.Path), "mkvextract.exe");
                mkvinfo.StartInfo.Arguments              = string.Format("chapters \"{0}\" --ui-language en --simple", _strFile);
                mkvinfo.StartInfo.CreateNoWindow         = true;
                mkvinfo.StartInfo.UseShellExecute        = false;
                mkvinfo.StartInfo.RedirectStandardOutput = true;
                mkvinfo.StartInfo.RedirectStandardError  = true;
                mkvinfo.StartInfo.ErrorDialog            = false;
                mkvinfo.EnableRaisingEvents              = true;
                mkvinfo.ErrorDataReceived  += new DataReceivedEventHandler(backgroundWorker_ErrorDataReceived);
                mkvinfo.OutputDataReceived += new DataReceivedEventHandler(backgroundWorker_OutputDataReceived);
                try
                {
                    mkvinfo.Start();
                    mkvinfo.BeginErrorReadLine();
                    mkvinfo.BeginOutputReadLine();
                    while (!mkvinfo.HasExited) // wait until the process has terminated without locking the GUI
                    {
                        System.Windows.Forms.Application.DoEvents();
                        System.Threading.Thread.Sleep(100);
                    }
                    mkvinfo.WaitForExit();

                    if (mkvinfo.ExitCode != 0)
                    {
                        _oLog.LogValue("MkvExtract", _strResult, ImageType.Error);
                    }
                    else
                    {
                        _oLog.LogValue("MkvExtract", _strResult);
                        try
                        {
                            StreamWriter sr = new StreamWriter(strChapterFile, false);
                            sr.Write(_strResult);
                            sr.Close();
                            bResult = true;
                        }
                        catch (Exception e)
                        {
                            _oLog.LogValue("MkvExtract - Unhandled Error", e, ImageType.Error);
                        }
                    }
                    parseResult();
                }
                catch (Exception ex)
                {
                    _oLog.LogValue("MkvExtract - Unhandled Error", ex, ImageType.Error);
                }
                finally
                {
                    mkvinfo.ErrorDataReceived  -= new DataReceivedEventHandler(backgroundWorker_ErrorDataReceived);
                    mkvinfo.OutputDataReceived -= new DataReceivedEventHandler(backgroundWorker_OutputDataReceived);
                }
                return(bResult);
            }
        }
Example #14
0
        public static UpdateWindow.ErrorState DownloadFile(string url, Uri serverAddress,
                                                           out Stream str, DownloadProgressChangedEventHandler wc_DownloadProgressChanged, UpdateWindow oUpdate)
        {
            ensureSensibleCacheFolderExists();
            UpdateWindow.ErrorState er = UpdateWindow.ErrorState.Successful;
            string updateCache         = MainForm.Instance.Settings.MeGUIUpdateCache;

            string localFilename = Path.Combine(updateCache, url);

            if (File.Exists(localFilename))
            {
                FileInfo finfo = new FileInfo(localFilename);
                if (finfo.Length == 0)
                {
                    oUpdate.AddTextToLog(localFilename + " is empty. Deleting file.", ImageType.Information);
                    UpdateCacher.FlushFile(localFilename, oUpdate);
                }

                // check the zip file
                if (localFilename.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".zip"))
                {
                    try
                    {
                        ZipFile zipFile = new ZipFile(localFilename);
                        if (zipFile.TestArchive(true) == false)
                        {
                            oUpdate.AddTextToLog("Could not unzip " + localFilename + ". Deleting file.", ImageType.Information);
                            UpdateCacher.FlushFile(localFilename, oUpdate);
                        }
                        else
                        {
                            goto gotLocalFile;
                        }
                    }
                    catch
                    {
                        oUpdate.AddTextToLog("Could not unzip " + localFilename + ". Deleting file.", ImageType.Error);
                        UpdateCacher.FlushFile(localFilename, oUpdate);
                    }
                }
                else if (localFilename.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".7z")) // check the 7-zip file
                {
                    try
                    {
                        SevenZipExtractor oArchive = new SevenZipExtractor(localFilename);
                        if (oArchive.Check() == false)
                        {
                            oUpdate.AddTextToLog("Could not extract " + localFilename + ". Deleting file.", ImageType.Information);
                            UpdateCacher.FlushFile(localFilename, oUpdate);
                        }
                        else
                        {
                            goto gotLocalFile;
                        }
                    }
                    catch
                    {
                        oUpdate.AddTextToLog("Could not extract " + localFilename + ". Deleting file.", ImageType.Error);
                        UpdateCacher.FlushFile(localFilename, oUpdate);
                    }
                }
                else
                {
                    goto gotLocalFile;
                }
            }

            WebClient wc = new WebClient();

            // check for proxy authentication...
            if (MainForm.Instance.Settings.UseHttpProxy == true)
            {
                WebProxy     wprox = null;
                ICredentials icred = null;

                if (MainForm.Instance.Settings.HttpProxyUid != null)
                {
                    icred = new NetworkCredential(MainForm.Instance.Settings.HttpProxyUid, MainForm.Instance.Settings.HttpProxyPwd);
                }

                wprox = new WebProxy(MainForm.Instance.Settings.HttpProxyAddress + ":" + MainForm.Instance.Settings.HttpProxyPort, true, null, icred);

                WebRequest.DefaultWebProxy = wprox;
                wc.Proxy = wprox;
            }
            else
            {
                wc.Proxy = null;
            }

            ManualResetEvent mre = new ManualResetEvent(false);

            wc.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e)
            {
                if (e.Error != null)
                {
                    er = UpdateWindow.ErrorState.CouldNotDownloadFile;
                }

                mre.Set();
            };

            wc.DownloadProgressChanged += wc_DownloadProgressChanged;

            wc.DownloadFileAsync(new Uri(serverAddress, url), localFilename);
            mre.WaitOne();

gotLocalFile:
            try
            {
                str = File.OpenRead(localFilename);
            }
            catch (IOException)
            {
                str = null;
                return(UpdateWindow.ErrorState.CouldNotDownloadFile);
            }

            return(er);
        }
Example #15
0
 public XviDEncoder(string exePath)
     : base()
 {
     UpdateCacher.CheckPackage("xvid_encraw");
     executable = exePath;
 }
Example #16
0
 public static string getFFMSAudioInputLine(string inputFile, string indexFile, int track)
 {
     UpdateCacher.CheckPackage("ffms");
     return(GetFFMSBasicInputLine(!isFFMSDefaultPluginRequired(), inputFile, indexFile, track, 0, 0, 0, false, false));
 }
Example #17
0
 public MkvMergeMuxer(string executablePath)
 {
     UpdateCacher.CheckPackage("mkvmerge");
     this.executable = executablePath;
 }
Example #18
0
 public DGIIndexer(string executableName)
 {
     UpdateCacher.CheckPackage("dgindexnv");
     executable = executableName;
 }