Esempio n. 1
0
    private void ThreadMethod()
    {
        _currentFileListCount  = MoviesInfo.Count;
        _currentFileListNumber = -1;

        foreach (var kvp in MoviesInfo)
        {
            if (kvp.Value == null)
            {
                break;
            }

            _currentConvertingMovie = kvp.Value;
            var info = _currentConvertingMovie.FirstVideoTrack;

            _currentFileListNumber++;

            _currentPass = 1;

            if (_processAbortRequest)
            {
                break;
            }

            var cmd1 = MediaInfoBase.MakeFFMpegCommand(kvp.Key, kvp.Value, 1);
            ExecutFFMpegCommand(cmd1, kvp.Value.FFMPEGOutputFileName);

            if (info != null &&
                _currentConvertingMovie.TargetVideoCodec != MediaConvertGUIConfiguration.GetVideoCodecByName("none"))
            {
                // converting 2 pass video
                var cmd2 = MediaInfoBase.MakeFFMpegCommand(kvp.Key, kvp.Value, 2);

                if (_processAbortRequest)
                {
                    break;
                }

                _currentPass = 2;

                if (!String.IsNullOrEmpty(cmd2))
                {
                    ExecutFFMpegCommand(cmd2, kvp.Value.FFMPEGOutputFileName);
                }
            }
        }

        Application.Invoke((_, __) =>
        {
            applyAction.Sensitive           = true;
            widgetTargetMovieTrack.Editable = true;
            widgetTargetContainer.Editable  = true;
            widgetSourceContainer.Editable  = true;
            _processthread.Join();
            _processthread = null;
        });
    }
Esempio n. 2
0
    protected void OnPreviwButtonClicked(object sender, EventArgs e)
    {
        // creating preview string

        using (var tw = new TextWin())
        {
            tw.Title = "FFmpeg command preview";
            tw.Text  = MediaInfoBase.MakeFFMpegCommandsAsString(MoviesInfo);
            tw.Show();
        }
    }
Esempio n. 3
0
    public void ShowProgress()
    {
        _proressWindow.Show();
        _proressWindow.SetPercents(0, 0, 0, _processStartedAt);

        while (_processthread != null && _processthread.IsAlive)
        {
            if (_proressWindow.AbortRequest)
            {
                if (SupportMethods.RunningPlatform == SupportMethods.RunningPlatformEnum.Unix)
                {
                    SupportMethods.ExecuteAndReturnOutput("killall", "ffmpeg");
                }
                else
                {
                    SupportMethods.ExecuteAndReturnOutput("taskkill", "/f /im ffmpeg.exe");
                }
                _processAbortRequest = true;
            }

            var percentsCurrentFilePass = 0d;
            var percentsCurrentFile     = 0d;
            var percentsTotal           = 0d;

            var fName              = String.Empty;
            var passAsString       = String.Empty;
            var totalFilesAsString = String.Empty;

            if (_currentConvertingMovie != null && _currentPass > 0)
            {
                decimal totalTime = _currentConvertingMovie.DurationMS / 1000m;
                percentsCurrentFile = 0;
                fName = System.IO.Path.GetFileName(_currentConvertingMovie.FileName);

                if (_currentConvertingMovie.FirstVideoTrack != null)
                {
                    decimal time = MediaInfoBase.GetLastTimeFromConvertLogFile(_outputFile);

                    if (time > 0)
                    {
                        percentsCurrentFilePass = percentsCurrentFile = Convert.ToDouble(time / (totalTime / 100m));
                        percentsCurrentFile     = percentsCurrentFilePass / 2;
                        percentsCurrentFile    += (_currentPass - 1) * 50;
                    }

                    /*
                     * var frames = Convert.ToDouble (_currentConvertingMovie.DurationMS / 1000m * _currentConvertingMovie.FirstVideoTrack.FrameRate);
                     *
                     * // detecting progress from text file
                     * var lastFrame = MediaInfoBase.GetLastFrameFromConvertLogFile (_outputFile);
                     * if ((frames > 0) && (lastFrame != -1))
                     * {
                     *      percentsCurrentFilePass = Convert.ToInt32 (lastFrame / (frames / (double)100));
                     * }
                     *
                     * // computing current file progress
                     * if (_currentPass > 0)
                     * {
                     *
                     *      var correctedFrame = lastFrame;
                     *      if (correctedFrame < 0)
                     *              correctedFrame = 0;
                     *
                     *
                     *      passAsString = "Pass: "******"/" + (_currentFileListCount).ToString();

                    // adding actual file progress fraction
                    if (percentsCurrentFile > 0)
                    {
                        var onePart = 1d / (double)_currentFileListCount;
                        percentsTotal = percentsTotal + percentsCurrentFile * onePart;
                    }
                }

                _proressWindow.SetPercents(Math.Round(percentsTotal, 2),
                                           Math.Round(percentsCurrentFile, 2),
                                           Math.Round(percentsCurrentFilePass, 2),
                                           _processStartedAt,
                                           fName,
                                           passAsString,
                                           totalFilesAsString);

                while (GLib.MainContext.Iteration())
                {
                    ;
                }
                Thread.Sleep(500);
            }
        }

        _proressWindow.SetPercents(100,
                                   100,
                                   100,
                                   _processStartedAt);
    }