Beispiel #1
0
        /// <summary>
        /// Return FFmpeg CLI arguments based on the current configuration as a string.
        /// </summary>
        /// <returns></returns>
        public string GetFFmpegCommandLineAsString()
        {
            string command = string.Empty;

            if (FFmpegService.IsFFmpegInstalled())
            {
                command += FFmpegService.GetFFmpegExePath();
                List <string> args = GetFFmpegArgs();
                command += " " + String.Join(" ", args.ToArray());
            }

            return(command);
        }
Beispiel #2
0
        /// <summary>
        /// Callback when the game is closed.
        /// </summary>
        private async Task HandleGameClosed()
        {
            OnGameClosed?.Invoke();

            // delete VDM file, we don't need it anymore
            string vdmPath = _config.Demo.GetVdmFilePath();

            if (File.Exists(vdmPath))
            {
                File.Delete(vdmPath);
            }

            // delete the CFG file, we don't need it anymore
            string cfgPath = GetCfgPath();

            if (File.Exists(cfgPath))
            {
                File.Delete(cfgPath);
            }

            // do not continue if TGA file not present, user may have close the game prematurely
            if (!IsFirstTgaExists())
            {
                return;
            }

            // generate a video file if the user want it
            if (_config.GenerateVideoFile)
            {
                if (_config.UseVirtualDub)
                {
                    // VirtualDub
                    GenerateVirtualDubScript();
                    ProcessStartInfo psi = new ProcessStartInfo
                    {
                        Arguments        = "/s csgodm.jobs /x",
                        FileName         = VirtualDubService.GetVirtualDubExePath(),
                        WorkingDirectory = VirtualDubService.GetVirtualDubPath(),
                    };
                    Process p = new Process
                    {
                        StartInfo = psi,
                    };
                    p.Start();
                    OnVirtualDubStarted?.Invoke();
                    await p.WaitForExitAsync();

                    OnVirtualDubClosed?.Invoke();
                    HandleEncodingEnded();
                }
                else
                {
                    // FFmpeg
                    List <string>    argsList = GetFFmpegArgs();
                    string           args     = string.Join(" ", argsList.ToArray());
                    ProcessStartInfo psi      = new ProcessStartInfo
                    {
                        Arguments       = args,
                        FileName        = FFmpegService.GetFFmpegExePath(),
                        UseShellExecute = false
                    };
                    Process p = new Process
                    {
                        StartInfo = psi,
                    };
                    OnFFmpegStarted?.Invoke();
                    p.Start();
                    await p.WaitForExitAsync();

                    OnFFmpegClosed?.Invoke();
                    HandleEncodingEnded();
                }
            }
        }