public void stop()
        {
            try
            {
                if (proc == null || proc.HasExited)
                {
                    return;
                }

                bWaitForExit = true;
                mre.Set(); // if it's paused, then unpause
                su.WasAborted = true;
                if (proc.StartInfo.FileName.ToLowerInvariant().Equals("cmd.exe"))
                {
                    foreach (Process oProc in OSInfo.GetChildProcesses(proc))
                    {
                        if (!oProc.ProcessName.ToLowerInvariant().Equals("conhost"))
                        {
                            try { OSInfo.KillProcess(oProc); } catch { }
                        }
                    }
                }
                proc.Kill();
                while (bWaitForExit) // wait until the process has terminated without locking the GUI
                {
                    MeGUI.core.util.Util.Wait(100);
                }
                proc.WaitForExit();
                return;
            }
            catch (Exception e)
            {
                throw new JobRunException(e);
            }
        }
Exemple #2
0
 private void ChapterCreator_Load(object sender, EventArgs e)
 {
     if (OSInfo.IsWindowsVistaOrNewer)
     {
         OSInfo.SetWindowTheme(chapterListView.Handle, "explorer", null);
     }
 }
        public bool resume()
        {
            bool bResult = OSInfo.ResumeProcess(proc);

            if (!mre.Set() || !bResult)
            {
                return(false);
            }
            return(true);
        }
        public bool pause()
        {
            bool bResult = OSInfo.SuspendProcess(proc);

            if (!mre.Reset() || !bResult)
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
 public void ChangePriority(WorkerPriorityType priority)
 {
     try
     {
         if (analyseThread != null && analyseThread.IsAlive)
         {
             analyseThread.Priority = OSInfo.GetThreadPriority(priority);
         }
     }
     catch (Exception)
     {
         // process could not be running anymore - ignore
     }
 }
Exemple #6
0
 public void start()
 {
     try
     {
         WorkerPriority.GetJobPriority(job, out WorkerPriorityType oPriority, out bool lowIOPriority);
         processThread          = new Thread(new ThreadStart(RunInThread));
         processThread.Priority = OSInfo.GetThreadPriority(oPriority);
         processThread.Start();
         new System.Windows.Forms.MethodInvoker(this.RunStatusCycle).BeginInvoke(null, null);
     }
     catch (Exception e)
     {
         throw new JobRunException(e);
     }
 }
Exemple #7
0
        /// <summary>
        /// changes the priority of the encoding process/thread
        /// </summary>
        /// <param name="priority">the priority to change to</param>
        /// <param name="error">output for any errors that might ocurr during this method</param>
        /// <returns>true if the priority has been changed, false if not</returns>
        public void changePriority(WorkerPriorityType priority)
        {
            if (this.processorThread == null || !processorThread.IsAlive)
            {
                return;
            }

            try
            {
                processorThread.Priority = OSInfo.GetThreadPriority(priority);
            }
            catch (Exception e) // process could not be running anymore
            {
                throw new JobRunException(e);
            }
        }
Exemple #8
0
        public virtual void changePriority(WorkerPriorityType priority)
        {
            if (!IsRunning())
            {
                return;
            }

            try
            {
                processThread.Priority = OSInfo.GetThreadPriority(priority);
            }
            catch (Exception e) // process could not be running anymore
            {
                throw new JobRunException(e);
            }
        }
        public void changePriority(WorkerPriorityType priority)
        {
            if (!isRunning())
            {
                return;
            }

            try
            {
                WorkerPriority.GetJobPriority(job, out WorkerPriorityType oPriority, out bool lowIOPriority);
                OSInfo.SetProcessPriority(proc, priority, lowIOPriority, iMinimumChildProcessCount);
                return;
            }
            catch (Exception e) // process could not be running anymore
            {
                throw new JobRunException(e);
            }
        }
Exemple #10
0
        public SettingsForm()
        {
            InitializeComponent();
            List <string> keys = new List <string>(LanguageSelectionContainer.Languages.Keys);

            defaultLanguage2.DataSource     = defaultLanguage1.DataSource = keys;
            defaultLanguage2.BindingContext = new BindingContext();
            defaultLanguage1.BindingContext = new BindingContext();
            SetToolTips();
#if x86
            if (!OSInfo.isWow64())
            {
                chkEnable64bitX264.Enabled = chkEnable64bitX264.Checked = false;
            }
#endif
#if x64
            chkEnable64bitX264.Enabled = false;
            chkEnable64bitX264.Checked = true;
            chkEnable64bitX264.Visible = false;
#endif
            ffmsThreads.Maximum = System.Environment.ProcessorCount;
        }
Exemple #11
0
        public static string genCommandline(string input, string output, Dar?d, int hres, int vres, int fps_n, int fps_d, x265Settings _xs, Zone[] zones, LogItem log)
        {
            int           qp;
            StringBuilder sb = new StringBuilder();
            CultureInfo   ci = new CultureInfo("en-us");
            x265Settings  xs = (x265Settings)_xs.Clone();

            // log
            if (log != null)
            {
                log.LogEvent("resolution: " + hres + "x" + vres);
                log.LogEvent("frame rate: " + fps_n + "/" + fps_d);
                if (d.HasValue)
                {
                    log.LogValue("aspect ratio", d.Value);
                }
                if (!String.IsNullOrEmpty(xs.CustomEncoderOptions))
                {
                    log.LogEvent("custom command line: " + xs.CustomEncoderOptions);
                }
                string path = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "tools\\x265");
#if x86
                if (OSInfo.isWow64())
                {
                    sb.Append("--x265-binary \"" + Path.Combine(path, "x64\\x265.exe") + "\" ");
                }
                else
                {
                    sb.Append("--x265-binary \"" + Path.Combine(path, "x86\\x265.exe") + "\" ");
                }
#else
                sb.Append("--x265-binary \"" + Path.Combine(path, "x64\\x265.exe") + "\" ");
#endif
            }

            #region main tab
            ///<summary>
            /// x265 Main Tab Settings
            ///</summary>

            // x265 Presets
            if (!xs.CustomEncoderOptions.Contains("--preset "))
            {
                switch (xs.x265PresetLevel)
                {
                case x265Settings.x265PresetLevelModes.ultrafast: sb.Append("--preset ultrafast "); break;

                case x265Settings.x265PresetLevelModes.superfast: sb.Append("--preset superfast "); break;

                case x265Settings.x265PresetLevelModes.veryfast: sb.Append("--preset veryfast "); break;

                case x265Settings.x265PresetLevelModes.faster: sb.Append("--preset faster "); break;

                case x265Settings.x265PresetLevelModes.fast: sb.Append("--preset fast "); break;

                //case x265Settings.x265PresetLevelModes.medium: sb.Append("--preset medium "); break; // default value
                case x265Settings.x265PresetLevelModes.slow: sb.Append("--preset slow "); break;

                case x265Settings.x265PresetLevelModes.slower: sb.Append("--preset slower "); break;

                case x265Settings.x265PresetLevelModes.veryslow: sb.Append("--preset veryslow "); break;

                case x265Settings.x265PresetLevelModes.placebo: sb.Append("--preset placebo "); break;
                }
            }

            // x265 Tunings
            if (!xs.CustomEncoderOptions.Contains("--tune "))
            {
                switch (xs.x265PsyTuning)
                {
                case x265Settings.x265PsyTuningModes.PSNR: sb.Append("--tune psnr "); break;

                case x265Settings.x265PsyTuningModes.SSIM: sb.Append("--tune ssim "); break;

                case x265Settings.x265PsyTuningModes.FastDecode: sb.Append("--tune fastdecode "); break;

                case x265Settings.x265PsyTuningModes.ZeroLatency: sb.Append("--tune zerolatency "); break;

                default: break;
                }
            }

            // Encoding Modes
            switch (xs.EncodingMode)
            {
            case 0:     // ABR
                if (!xs.CustomEncoderOptions.Contains("--bitrate "))
                {
                    sb.Append("--bitrate " + xs.BitrateQuantizer + " ");
                }
                break;

            case 1:     // CQ
                if (!xs.CustomEncoderOptions.Contains("--qp "))
                {
                    qp = (int)xs.QuantizerCRF;
                    sb.Append("--qp " + qp.ToString(ci) + " ");
                }
                break;

            /* case 2: // 2 pass first pass
             *   sb.Append("--pass 1 --bitrate " + xs.BitrateQuantizer + " --stats " + "\"" + xs.Logfile + "\" ");
             *   break;
             * case 3: // 2 pass second pass
             * case 4: // automated twopass
             *   sb.Append("--pass 2 --bitrate " + xs.BitrateQuantizer + " --stats " + "\"" + xs.Logfile + "\" ");
             *   break;
             * case 5: // 3 pass first pass
             *   sb.Append("--pass 1 --bitrate " + xs.BitrateQuantizer + " --stats " + "\"" + xs.Logfile + "\" ");
             *   break;
             * case 6: // 3 pass 2nd pass
             *   sb.Append("--pass 3 --bitrate " + xs.BitrateQuantizer + " --stats " + "\"" + xs.Logfile + "\" ");
             *   break;
             * case 7: // 3 pass 3rd pass
             * case 8: // automated threepass, show third pass options
             *   sb.Append("--pass 3 --bitrate " + xs.BitrateQuantizer + " --stats " + "\"" + xs.Logfile + "\" ");
             *   break;*/
            case 2:     // constant quality
                if (!xs.CustomEncoderOptions.Contains("--crf "))
                {
                    if (xs.QuantizerCRF != 28)
                    {
                        sb.Append("--crf " + xs.QuantizerCRF.ToString(ci) + " ");
                    }
                }
                break;
            }

            // Threads
            if (!xs.CustomEncoderOptions.Contains("--frame-threads "))
            {
                if (xs.NbThreads > 0)
                {
                    sb.Append("--frame-threads " + xs.NbThreads + " ");
                }
            }

            if (!String.IsNullOrEmpty(xs.CustomEncoderOptions)) // add custom encoder options
            {
                sb.Append(xs.CustomEncoderOptions + " ");
            }

            if (!String.IsNullOrEmpty(output))
            {
                sb.Append(" --output " + "\"" + output + "\" ");
            }

            if (!String.IsNullOrEmpty(input))
            {
                sb.Append("\"" + input + "\"");
            }

            #endregion

            return(sb.ToString());
        }
Exemple #12
0
        public MeGUISettings()
        {
            strMeGUIPath          = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
            autoscroll            = true;
            autoUpdateServerLists = new string[][] { new string[] { "Stable", "http://megui.org/auto/stable/", "http://megui.xvidvideo.ru/auto/stable/" },
                                                     new string[] { "Development", "http://megui.org/auto/", "http://megui.xvidvideo.ru/auto/" }, new string[] { "Custom" } };
            acceptableFPSError      = 0.01M;
            autoUpdateServerSubList = 0;
            autoUpdate            = true;
            dialogSettings        = new DialogSettings();
            sdSettings            = new SourceDetectorSettings();
            AedSettings           = new AutoEncodeDefaultsSettings();
            useadvancedtooltips   = true;
            audioSamplesPerUpdate = 100000;
            aviMuxGUIPath         = getDownloadPath(@"tools\avimux_gui\avimux_gui.exe");
#if x64
            qaacPath = getDownloadPath(@"tools\qaac\x64\qaac.exe");
#endif
#if x86
            qaacPath = getDownloadPath(@"tools\qaac\x86\qaac.exe");
#endif
            opusPath       = getDownloadPath(@"tools\opus\opusenc.exe");
            mp4boxPath     = getDownloadPath(@"tools\mp4box\mp4box.exe");
            mkvmergePath   = getDownloadPath(@"tools\mkvmerge\mkvmerge.exe");
            mkvExtractPath = getDownloadPath(@"tools\mkvmerge\mkvextract.exe");
            pgcDemuxPath   = getDownloadPath(@"tools\pgcdemux\pgcdemux.exe");
#if x64
            x264Path   = getDownloadPath(@"tools\x264\x264_64.exe");
            b64bitX264 = true;
#endif
#if x86
            x264Path = getDownloadPath(@"tools\x264\x264.exe");
            if (OSInfo.isWow64())
            {
                b64bitX264 = true;
            }
#endif
            dgIndexPath                        = getDownloadPath(@"tools\dgindex\dgindex.exe");
            ffmsIndexPath                      = getDownloadPath(@"tools\ffms\ffmsindex.exe");
            xvidEncrawPath                     = getDownloadPath(@"tools\xvid_encraw\xvid_encraw.exe");
            lamePath                           = getDownloadPath(@"tools\lame\lame.exe");
            neroAacEncPath                     = strMeGUIPath + @"\tools\eac3to\neroAacEnc.exe";
            oggEnc2Path                        = getDownloadPath(@"tools\oggenc2\oggenc2.exe");
            ffmpegPath                         = getDownloadPath(@"tools\ffmpeg\ffmpeg.exe");
            aftenPath                          = getDownloadPath(@"tools\aften\aften.exe");
            flacPath                           = getDownloadPath(@"tools\flac\flac.exe");
            yadifPath                          = getDownloadPath(@"tools\yadif\yadif.dll");
            vobSubPath                         = getDownloadPath(@"tools\vobsub\vobsub.dll");
            besplitPath                        = getDownloadPath(@"tools\besplit\besplit.exe");
            dgavcIndexPath                     = getDownloadPath(@"tools\dgavcindex\dgavcindex.exe");
            dgnvIndexPath                      = getDownloadPath(@"tools\dgindexnv\dgindexnv.exe");
            eac3toPath                         = getDownloadPath(@"tools\eac3to\eac3to.exe");
            tsmuxerPath                        = getDownloadPath(@"tools\tsmuxer\tsmuxer.exe");
            aviSynthPath                       = getDownloadPath(@"tools\avs\avisynth.dll");
            meguiupdatecache                   = System.IO.Path.Combine(strMeGUIPath, "update_cache");
            avisynthpluginspath                = System.IO.Path.Combine(strMeGUIPath, @"tools\avisynth_plugin");
            recalculateMainMovieBitrate        = false;
            autoForceFilm                      = true;
            bAutoLoadDG                        = true;
            autoStartQueue                     = true;
            bAlwaysMuxMKV                      = true;
            bAutoStartQueueStartup             = false;
            forceFilmThreshold                 = new decimal(95);
            defaultLanguage1                   = "";
            defaultLanguage2                   = "";
            defaultPriority                    = ProcessPriority.IDLE;
            acceptableAspectError              = 1;
            afterEncoding                      = AfterEncoding.DoNothing;
            autoOpenScript                     = true;
            enableMP3inMP4                     = false;
            overwriteStats                     = true;
            keep2of3passOutput                 = false;
            deleteCompletedJobs                = false;
            nbPasses                           = 2;
            deleteIntermediateFiles            = true;
            deleteAbortedOutput                = true;
            autoSelectHDStreams                = true;
            openProgressWindow                 = true;
            videoExtension                     = "";
            audioExtension                     = "";
            safeProfileAlteration              = false;
            alwaysOnTop                        = false;
            usehttpproxy                       = false;
            httpproxyaddress                   = "";
            httpproxyport                      = "";
            httpproxyuid                       = "";
            httpproxypwd                       = "";
            defaultOutputDir                   = "";
            tempDirMP4                         = "";
            addTimePosition                    = true;
            alwaysbackupfiles                  = true;
            forcerawavcextension               = false;
            strMainFileFormat                  = "";
            strMainAudioFormat                 = "";
            strLastSourcePath                  = "";
            strLastDestinationPath             = "";
            minComplexity                      = 72;
            maxComplexity                      = 78;
            mainFormLocation                   = new Point(0, 0);
            mainFormSize                       = new Size(524, 558);
            updateFormLocation                 = new Point(0, 0);
            updateFormSize                     = new Size(710, 313);
            updateFormSplitter                 = 180;
            updateFormUpdateColumnWidth        = 47;
            updateFormNameColumnWidth          = 105;
            updateFormLocalVersionColumnWidth  = 117;
            updateFormServerVersionColumnWidth = 117;
            updateFormLocalDateColumnWidth     = 70;
            updateFormServerDateColumnWidth    = 70;
            updateFormPlatformColumnWidth      = 52;
            updateFormStatusColumnWidth        = 111;
            jobWorkerSize                      = new Size(565, 498);
            jobColumnWidth                     = 40;
            inputColumnWidth                   = 89;
            outputColumnWidth                  = 89;
            codecColumnWidth                   = 43;
            ModeColumnWidth                    = 75;
            statusColumnWidth                  = 51;
            ownerColumnWidth                   = 60;
            startColumnWidth                   = 55;
            endColumnWidth                     = 55;
            fpsColumnWidth                     = 35;
            bEnsureCorrectPlaybackSpeed        = bUseDGIndexNV = bUseNeroAacEnc = bExternalProgramsSet = false;
            ffmsThreads                        = 1;
            appendToForcedStreams              = "";
            ocGUIMode                          = OCGUIMode.Default;
            bUseITU                = true;
            bOpenAVSInThread       = true;
            lastUsedOneClickFolder = "";
        }