예제 #1
0
        /// <summary>
        /// Execute a BDSup2Sub demux process.
        /// This should only be called from the UI thread.
        /// </summary>
        /// <param name="encodeQueueTask">
        /// The encodeQueueTask.
        /// </param>
        public override void Start(EncodeInfo encodeQueueTask)
        {
            try
            {
                if (IsEncoding)
                {
                    encodeQueueTask.ExitCode = -1;
                    throw new Exception("BDSup2Sub is already running");
                }

                IsEncoding   = true;
                _currentTask = encodeQueueTask;

                var query   = GenerateCommandLine();
                var cliPath = _appConfig.JavaInstallPath;

                var cliStart = new ProcessStartInfo(cliPath, query)
                {
                    WorkingDirectory       = _appConfig.DemuxLocation,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true
                };

                EncodeProcess = new Process {
                    StartInfo = cliStart
                };
                Log.Info($"start parameter: {cliPath} {query}");

                EncodeProcess.Start();

                _startTime = DateTime.Now;

                EncodeProcess.OutputDataReceived += EncodeProcessDataReceived;
                EncodeProcess.BeginOutputReadLine();

                _encoderProcessId = EncodeProcess.Id;

                // Set the encoder process exit trigger
                if (_encoderProcessId != -1)
                {
                    EncodeProcess.EnableRaisingEvents = true;
                    EncodeProcess.Exited += EncodeProcessExited;
                }

                EncodeProcess.PriorityClass = _appConfig.GetProcessPriority();

                // Fire the Encode Started Event
                InvokeEncodeStarted(EventArgs.Empty);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                _currentTask.ExitCode = -1;
                IsEncoding            = false;
                InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, exc.Message));
            }
        }
예제 #2
0
        /// <summary>
        /// Execute a ffmpeg crop detection process.
        /// This should only be called from the UI thread.
        /// </summary>
        /// <param name="encodeQueueTask">
        /// The encodeQueueTask.
        /// </param>
        public override void Start(EncodeInfo encodeQueueTask)
        {
            try
            {
                if (IsEncoding)
                {
                    encodeQueueTask.ExitCode = -1;
                    throw new Exception("ffmpeg is already running");
                }

                IsEncoding   = true;
                _currentTask = encodeQueueTask;

                var query   = GenerateCommandLine();
                var cliPath = Path.Combine(_appConfig.ToolsPath, Executable);

                var cliStart = new ProcessStartInfo(cliPath, query)
                {
                    WorkingDirectory      = _appConfig.DemuxLocation,
                    CreateNoWindow        = true,
                    UseShellExecute       = false,
                    RedirectStandardError = true,
                };
                DecodeProcess = new Process {
                    StartInfo = cliStart
                };
                Log.Info($"start parameter: ffmpeg {query}");

                DecodeProcess.Start();

                _startTime = DateTime.Now;

                DecodeProcess.ErrorDataReceived += DecodeProcessDataReceived;
                DecodeProcess.BeginErrorReadLine();

                _decoderProcessId = DecodeProcess.Id;

                if (_decoderProcessId != -1)
                {
                    DecodeProcess.EnableRaisingEvents = true;
                    DecodeProcess.Exited += DecodeProcessExited;
                }

                DecodeProcess.PriorityClass = _appConfig.GetProcessPriority();

                // Fire the Encode Started Event
                InvokeEncodeStarted(EventArgs.Empty);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                _currentTask.ExitCode = -1;
                IsEncoding            = false;
                InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, exc.Message));
            }
        }
예제 #3
0
        /// <summary>
        /// Execute a neroaacenc process.
        /// This should only be called from the UI thread.
        /// </summary>
        /// <param name="encodeQueueTask">
        /// The encodeQueueTask.
        /// </param>
        public override void Start(EncodeInfo encodeQueueTask)
        {
            try
            {
                if (IsEncoding)
                {
                    encodeQueueTask.ExitCode = -1;
                    throw new Exception("neroAacEnc is already running");
                }

                IsEncoding   = true;
                _currentTask = encodeQueueTask;

                var query   = GenerateCommandLine();
                var cliPath = Path.Combine(_appConfig.ToolsPath, Executable);

                var cliStart = new ProcessStartInfo(cliPath, query)
                {
                    WorkingDirectory      = _appConfig.DemuxLocation,
                    CreateNoWindow        = true,
                    UseShellExecute       = false,
                    RedirectStandardError = true,
                    RedirectStandardInput = true
                };

                EncodeProcess = new Process {
                    StartInfo = cliStart
                };
                Log.Info($"start parameter: neroAacEnc {query}");

                DecodeProcess = DecoderBePipe.CreateDecodingProcess(_inputFile, _appConfig.AvsPluginsPath);

                _encodePipe = new NamedPipeServerStream(_appConfig.EncodeNamedPipeName,
                                                        PipeDirection.InOut,
                                                        3,
                                                        PipeTransmissionMode.Byte,
                                                        PipeOptions.Asynchronous);

                _encodePipeState = _encodePipe.BeginWaitForConnection(EncoderConnected, null);

                EncodeProcess.Start();
                DecodeProcess.Start();

                _startTime = DateTime.Now;

                EncodeProcess.ErrorDataReceived += EncodeProcessDataReceived;
                EncodeProcess.BeginErrorReadLine();

                DecodeProcess.ErrorDataReceived += DecodeProcessDataReceived;
                DecodeProcess.BeginErrorReadLine();

                _encoderProcessId = EncodeProcess.Id;
                _decoderProcessId = DecodeProcess.Id;

                if (_encoderProcessId != -1)
                {
                    EncodeProcess.EnableRaisingEvents = true;
                    EncodeProcess.Exited += EncodeProcessExited;
                    _encoderIsRunning     = true;
                }

                if (_decoderProcessId != -1)
                {
                    DecodeProcess.EnableRaisingEvents = true;
                    DecodeProcess.Exited += DecodeProcessExited;
                    _decoderIsRunning     = true;
                }

                EncodeProcess.PriorityClass = _appConfig.GetProcessPriority();
                DecodeProcess.PriorityClass = _appConfig.GetProcessPriority();

                // Fire the Encode Started Event
                InvokeEncodeStarted(EventArgs.Empty);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                _currentTask.ExitCode = -1;
                IsEncoding            = false;
                _encoderIsRunning     = false;
                _decoderIsRunning     = false;
                InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, exc.Message));
            }
        }
예제 #4
0
        /// <summary>
        /// Execute a ffmpeg demux process.
        /// This should only be called from the UI thread.
        /// </summary>
        /// <param name="encodeQueueTask">
        /// The encodeQueueTask.
        /// </param>
        public override void Start(EncodeInfo encodeQueueTask)
        {
            try
            {
                if (IsEncoding)
                {
                    encodeQueueTask.ExitCode = -1;
                    throw new Exception("ffmpeg is already running");
                }

                IsEncoding   = true;
                _currentTask = encodeQueueTask;

                var use64BitEncoder = _appConfig.Use64BitEncoders &&
                                      _appConfig.Ffmpeg64Installed &&
                                      Environment.Is64BitOperatingSystem;

                if (_currentTask.Input == InputType.InputDvd)
                {
                    _inputFile = _currentTask.DumpOutput;
                }
                else
                {
                    _inputFile = string.IsNullOrEmpty(_currentTask.TempInput)
                                ? _currentTask.InputFile
                                : _currentTask.TempInput;
                }
                _currentTask.VideoStream.TempFile = _inputFile;

                try
                {
                    _currentTask.MediaInfo = GenHelper.GetMediaInfo(_inputFile);
                    if (_currentTask.Input == InputType.InputDvd)
                    {
                        _currentTask.VideoStream = VideoHelper.GetStreamInfo(_currentTask.MediaInfo,
                                                                             _currentTask.VideoStream,
                                                                             false);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }

                var query         = GenerateCommandLine();
                var ffmpegCliPath = Path.Combine(_appConfig.ToolsPath,
                                                 use64BitEncoder ? Executable64 : Executable);

                var cliStart = new ProcessStartInfo(ffmpegCliPath, query)
                {
                    WorkingDirectory      = _appConfig.DemuxLocation,
                    CreateNoWindow        = true,
                    UseShellExecute       = false,
                    RedirectStandardError = true
                };
                DemuxProcess = new Process {
                    StartInfo = cliStart
                };
                Log.Info($"start parameter: ffmpeg {query}");

                DemuxProcess.Start();

                _startTime = DateTime.Now;

                DemuxProcess.ErrorDataReceived += DemuxDataReceived;
                DemuxProcess.BeginErrorReadLine();

                _demuxerProcessId = DemuxProcess.Id;

                // Set the encoder process exit trigger
                if (_demuxerProcessId != -1)
                {
                    DemuxProcess.EnableRaisingEvents = true;
                    DemuxProcess.Exited += DemuxProcessExited;
                }

                DemuxProcess.PriorityClass = _appConfig.GetProcessPriority();

                // Fire the Encode Started Event
                InvokeEncodeStarted(EventArgs.Empty);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                _currentTask.ExitCode = -1;
                IsEncoding            = false;
                InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, exc.Message));
            }
        }
예제 #5
0
        /// <summary>
        /// Execute a spumux process.
        /// This should only be called from the UI thread.
        /// </summary>
        /// <param name="encodeQueueTask">
        /// The encodeQueueTask.
        /// </param>
        public override void Start(EncodeInfo encodeQueueTask)
        {
            try
            {
                if (IsEncoding)
                {
                    encodeQueueTask.ExitCode = -1;
                    throw new Exception("spumux is already running");
                }

                IsEncoding   = true;
                _currentTask = encodeQueueTask;

                var query   = GenerateCommandLine();
                var cliPath = Path.Combine(_appConfig.ToolsPath, Executable);

                var cliStart = new ProcessStartInfo(cliPath, query)
                {
                    WorkingDirectory       = _appConfig.DemuxLocation,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardInput  = true
                };
                EncodeProcess = new Process {
                    StartInfo = cliStart
                };
                Log.Info($"start parameter: spumux {query}");

                _readStream  = new FileStream(_inputFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                _writeStream = new FileStream(_outputFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

                _readFileThread  = new Thread(StartReadFile);
                _writeFileThread = new Thread(StartWriteFile);

                EncodeProcess.Start();

                _readFileThread.Start();
                _writeFileThread.Start();

                EncodeProcess.ErrorDataReceived += EncodeProcessDataReceived;
                EncodeProcess.BeginErrorReadLine();

                _encoderProcessId = EncodeProcess.Id;

                if (_encoderProcessId != -1)
                {
                    EncodeProcess.EnableRaisingEvents = true;
                    EncodeProcess.Exited += EncodeProcessExited;
                }

                EncodeProcess.PriorityClass = _appConfig.GetProcessPriority();

                // Fire the Encode Started Event
                InvokeEncodeStarted(EventArgs.Empty);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                _currentTask.ExitCode = -1;
                IsEncoding            = false;
                InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, exc.Message));
            }
        }