コード例 #1
0
        private static void Getx265Line(FileConfig fileConfig, int pass, out string x264Line, out string outputpath)
        {
            VedioConfig vedioConfig = fileConfig.VedioConfig;

            x264Line = x265Args;
            x264Line = x264Line.Replace("$preset$", vedioConfig.preset);
            if (string.IsNullOrEmpty(vedioConfig.tune))
            {
                x264Line = x264Line.Replace("$tune$", "");
            }
            else
            {
                x264Line = x264Line.Replace("$tune$", "--tune " + vedioConfig.tune);
            }
            if (vedioConfig.BitType == EncoderBitrateType.crf)
            {
                x264Line = x264Line.Replace("$crf$", "--crf " + vedioConfig.crf.ToString());
            }
            else
            {
                string          twopassstr = "--pass " + pass + " --bitrate " + vedioConfig.bitrate.ToString();
                x264ArgsManager manager    = new x264ArgsManager(x264Line);

                x264Line = x264Line.Replace("$crf$", twopassstr);
            }


            x264Line = x264Line.Replace("$profile$", "");

            outputpath = string.Empty;

            string fileExtension = "." + fileConfig.Muxer;

            string inputArg = "";

            if (fileConfig.AudioConfig.CopyStream || !fileConfig.AudioConfig.Enabled)
            {
                outputpath = fileConfig.OutputFile + fileExtension;
            }
            else
            {//临时目录
                outputpath = FileUtility.RandomName(Config.Temp) + ".h265";
            }
            if (fileConfig.InputType == InputType.AvisynthScriptFile)
            {
                x264Line = x264Line.Replace("$input$", fileConfig.AvsFileFullName.Maohao());
            }
            else if (fileConfig.InputType == InputType.AvisynthScript || fileConfig.InputType == InputType.VapoursynthScriptFile)
            {
                x264Line = x264Line.Replace("$input$", "");
            }
            else
            {
                if (fileConfig.UseBat)
                {
                    x264Line = x264Line.Replace("$input$", "");
                    inputArg = " --input - --y4m ";
                }
                else
                {
                    x264Line = x264Line.Replace("$input$", "--input " + fileConfig.VedioFileFullName.Maohao());
                }
            }

            x264Line = x264Line.Replace("$outputfile$", FileUtility.GetNoSameNameFile(outputpath));
            if (fileConfig.UseBat)
            {
                x264Line = x264Line.Replace("$userargs$", vedioConfig.UserArgs + inputArg);
            }
            else
            {
                x264Line = x264Line.Replace("$userargs$", vedioConfig.UserArgs);
            }
        }
コード例 #2
0
        private static void Getx265Line(FileConfig fileConfig, int pass, out string x265Line, out string outputpath)
        {
            VedioConfig vedioConfig = fileConfig.VedioConfig;

            x265Line = x265Args;
            x265Line = x265Line.Replace("$preset$", vedioConfig.preset);
            if (string.IsNullOrEmpty(vedioConfig.tune))
            {
                x265Line = x265Line.Replace("$tune$", "");
            }
            else
            {
                x265Line = x265Line.Replace("$tune$", "--tune " + vedioConfig.tune);
            }
            if (vedioConfig.BitType == EncoderBitrateType.crf)
            {
                x265Line = x265Line.Replace("$crf$", "--crf " + vedioConfig.crf.ToString());
            }
            else
            {
                string          twopassstr = "--pass " + pass + " --bitrate " + vedioConfig.bitrate.ToString();
                x264ArgsManager manager    = new x264ArgsManager(x265Line);

                x265Line = x265Line.Replace("$crf$", twopassstr);
            }


            x265Line = x265Line.Replace("$profile$", "");

            outputpath = string.Empty;

            string fileExtension = "." + fileConfig.Muxer;

            string inputArg = "";

            //if (fileConfig.AudioConfig.CopyStream || !fileConfig.AudioConfig.Enabled)
            //{
            //    outputpath = fileConfig.OutputFile + fileExtension;
            //}
            //else
            //{//临时目录
            outputpath = FileUtility.AppendRandomName(Config.Temp, Path.GetFileNameWithoutExtension(fileConfig.VedioFileFullName) + ".h265");

            //}
            if (fileConfig.InputType == InputType.AvisynthScriptFile)
            {
                x265Line = x265Line.Replace("$input$", fileConfig.AvsFileFullName.Maohao());
            }
            else if (fileConfig.InputType == InputType.AvisynthScript || fileConfig.InputType == InputType.VapoursynthScriptFile)
            {
                x265Line = x265Line.Replace("$input$", "");
            }
            else
            {
                if (fileConfig.VedioConfig.decoderMode == DecoderMode.pipe)
                {
                    x265Line = x265Line.Replace("$input$", "");
                    inputArg = " --input - --y4m ";
                }
                else
                {
                    x265Line = x265Line.Replace("$input$", "--input " + fileConfig.VedioFileFullName.Maohao());
                }
            }

            x265Line = x265Line.Replace("$outputfile$", outputpath);
            if (fileConfig.VedioConfig.decoderMode == "pipe")
            {
                x265Line = x265Line.Replace("$userargs$", vedioConfig.UserArgs + inputArg);
            }
            else
            {
                x265Line = x265Line.Replace("$userargs$", vedioConfig.UserArgs);
            }

            if (vedioConfig.Is_x265_GHFLY_MOD && vedioConfig.depth != 10)
            {
                x265Line = $"-D {vedioConfig.depth} {x265Line}";
            }
        }