Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mediaFile"></param>
        private void ConvertMedia(MediaFile mediaFile)
        {
            string strFileName       = mediaFile.StrName;
            string strOutputFilePath = mediaFile.StrOutputFilePath;
            string strOriginFilePath = mediaFile.StrOriginFilePath;

            UpdateStatusStrip(SystemStatus.Converting, strFileName);

            try
            {
                //Setup FFMPEG with params etc
                Process          process   = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo();

                startInfo.CreateNoWindow  = true;
                startInfo.UseShellExecute = false;
                startInfo.FileName        = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg\\ffmpeg.exe");
                startInfo.Arguments       = @" -i " + @"""" + strOriginFilePath + @"""" + " -y -vcodec copy -acodec copy " + @" """ +
                                            strOutputFilePath + @""" ";


                startInfo.CreateNoWindow         = true;
                startInfo.UseShellExecute        = false;
                startInfo.RedirectStandardError  = true;
                startInfo.RedirectStandardOutput = true;

                process.StartInfo           = startInfo;
                process.ErrorDataReceived  += ConsoleDataReceived;
                process.OutputDataReceived += ConsoleDataReceived;

                process.Start();

                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                process.WaitForExit();

                //Delete original mkv?
                if (deleteOldFileToolStripMenuItem.Checked)
                {
                    File.Delete(strOriginFilePath);
                }
            }
            catch (Exception ex)
            {
                //Invoke LstOutput and write exception to it.
                LstOutput.BeginInvoke((Action)(() =>
                {
                    LstOutput.BeginUpdate();
                    LstOutput.Items.Add(ex.ToString());
                    LstOutput.EndUpdate();
                }));
            }

            UpdateStatusStrip(SystemStatus.FinishedConverting, strFileName);
            UpdateConvertedFilesLog(strFileName);
        }
Пример #2
0
        /// <summary>
        /// Check if there are updates pending to be logged
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_Tick(object sender, EventArgs e)
        {
            if (_isBusy)
            {
                LstOutput.BeginUpdate();
                LstOutput.Items.Add(_sb.ToString());
                LstOutput.EndUpdate();
                _isBusy = false;
            }

            if (BtnWatch.Text == @"Stop")
            {
                //uptime calc
                statusStrip.BeginInvoke((Action)(() =>
                {
                    TimeSpan span = (DateTime.Now - _tsTimeSpan);
                    toolStripStatusLabel2.Text = String.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds",
                                                               span.Days, span.Hours, span.Minutes, span.Seconds);
                    statusStrip.Refresh();
                    statusStrip.Update();
                }));
            }
        }