public static void FillFileConfig(this MediaInfo info, FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; vedioConfig.deinterlace = fileConfig.mediaInfo.ScanType == ScanType.Interlaced ? true : false; vedioConfig.scanorder = fileConfig.mediaInfo.ScanOrder == ScanOrder.TopFieldFirst ? true : false; }
public static string ffmpegPipex265Args = " -i \"{0}\" -f yuv4mpegpipe -an -v 0 {1} -|";//-deinterlace public static string GetFfmpegArgs(FileConfig fileconfig) { VedioConfig vedioConfig = fileconfig.VedioConfig; string args = ""; if (vedioConfig.deinterlace) { args += "-deinterlace "; } if (vedioConfig.csp == "i444") { args += "-pix_fmt yuv444p "; } else if (vedioConfig.csp == "i420") { args += "-pix_fmt yuv420p "; } else if (vedioConfig.csp == "i422") { args += "-pix_fmt yuv422p "; } else if (vedioConfig.csp == "rgb") { args += "-pix_fmt argb "; } if (vedioConfig.Resize) { args += string.Format("-s {0}x{1}", vedioConfig.Width, vedioConfig.Height); } var result = string.Format(ffmpegPipex265Args, fileconfig.VedioFileFullName.Maohao(), args); return(result); }
private static string GetX265exeFullName(VedioConfig vedioConfig) { string x265exe = ""; if (Config.IsWindows) { if (vedioConfig.depth == 10) { x265exe = "tools" + Path.DirectorySeparatorChar + x265Excute10 + ".exe"; } else { x265exe = "tools" + Path.DirectorySeparatorChar + x265Excute8 + ".exe"; } if (!File.Exists(x265exe)) { throw new EncoderException("找不到指定程序:" + x265exe); } } else { if (vedioConfig.depth == 10) { x265exe = x265Excute10; } else { x265exe = x265Excute8; } } return(x265exe); }
private void SetVedioConfigByControl(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; if (!string.IsNullOrEmpty(textBox3.Text)) { vedioConfig.crf = float.Parse(textBox3.Text); vedioConfig.BitType = EncoderBitrateType.crf; } else { vedioConfig.bitrate = int.Parse(txtbitrate.Text); vedioConfig.BitType = EncoderBitrateType.twopass; } if (cbEnableQpmod.Checked) { vedioConfig.BitType = EncoderBitrateType.qp; } //if (cbEnableX265.Checked) //vedioConfig.ffmpeg4x265Args = txtffmpeg4x265.Text; vedioConfig.Encoder = (Encoder)Enum.Parse(typeof(Encoder), comboBox2.Text); if (vedioConfig.Encoder == Encoder.x265_GHFLY_MOD) { vedioConfig.Encoder = Encoder.x265; vedioConfig.Is_x265_GHFLY_MOD = true; } vedioConfig.UserArgs = txtUserArgs.Text; vedioConfig.depth = int.Parse(cbColorDepth.Text); vedioConfig.preset = cbpreset.Text; vedioConfig.tune = comboBox1.Text; vedioConfig.Resize = checkBox1.Checked; vedioConfig.csp = cbcsp.Text; vedioConfig.Width = textBox4.Text == "" ? 0 : int.Parse(textBox4.Text); vedioConfig.Height = textBox5.Text == "" ? 0 : int.Parse(textBox5.Text); if (cbUseAvsTemplete.Checked) {//处理自定义avs模板 fileConfig.InputType = InputType.AvisynthScript; string avsscript = txtAvsScript.Text; avsscript = avsscript.Replace("$InputVedio$", fileConfig.VedioFileFullName) .Replace("$avisynth_plugin$", Path.Combine(Application.StartupPath, "tools\\avsplugin")); vedioConfig.AvsScript = avsscript; } else if (cbUseVSTemplete.Checked) {//处理自定义vs模板 fileConfig.InputType = InputType.VapoursynthScript; string avsscript = txtVsScript.Text; avsscript = avsscript.Replace("$InputVedio$", fileConfig.VedioFileFullName) .Replace("$vapoursynth_plugin$", Config.VsPluginPath) .Replace("$InputVedioWithoutExtension$", FileUtility.GetFullNameWithoutExtension(fileConfig.VedioFileFullName)); var dgipath = Path.ChangeExtension(fileConfig.VedioFileFullName, ".dgi"); avsscript = avsscript.Replace("$InputDgi$", dgipath); vedioConfig.VapoursynthScript = avsscript; } vedioConfig.decoderMode = cbdecoderMode.SelectedItem.ToString(); }
public static string RunX265Command(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; ProcessStartInfo processinfo = new ProcessStartInfo(); string x264exe = GetX265exeFullName(vedioConfig); if (!File.Exists(x264exe)) { throw new EncoderException("找不到指定程序:" + x264exe); } processinfo.FileName = x264exe; //processinfo.FileName = Environment.GetEnvironmentVariable("ComSpec"); string x264Line; string outputpath = "";; //processinfo.Arguments = "/c \"" + Path.Combine(Application.StartupPath, "tools\\avs4x264mod.exe") + "\" " + x264Line; //processinfo.UseShellExecute = false; //输出信息重定向 //processinfo.CreateNoWindow = true; //processinfo.RedirectStandardInput = true; //processinfo.RedirectStandardOutput = true; //processinfo.RedirectStandardError = false; //processinfo.WindowStyle = ProcessWindowStyle.Hidden; Process avsx264mod = new Process(); fileConfig.FillMediaInfo(); if (vedioConfig.BitType == EncoderBitrateType.crf) { Getx265Line(fileConfig, 0, out x264Line, out outputpath); processinfo.Arguments = x264Line; avsx264mod.StartInfo = processinfo; avsx264mod.Start(); avsx264mod.WaitForExit(); } else if (vedioConfig.BitType == EncoderBitrateType.twopass) { Getx265Line(fileConfig, 1, out x264Line, out outputpath); processinfo.Arguments = x264Line; avsx264mod.StartInfo = processinfo; avsx264mod.Start(); avsx264mod.WaitForExit(); Getx265Line(fileConfig, 2, out x264Line, out outputpath); processinfo.Arguments = x264Line; avsx264mod.StartInfo = processinfo; avsx264mod.Start(); avsx264mod.WaitForExit(); } avsx264mod.Dispose(); return(outputpath); }
public static string ffmpegPipeX265(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; ProcessStartInfo processinfo = new ProcessStartInfo(); string finalX265Path = ""; if (vedioConfig.depth == 8) { finalX265Path = x265Excute8lite; } else if (vedioConfig.depth == 10) { finalX265Path = x265Excute10lite; } if (!File.Exists(finalX265Path)) { throw new EncoderException("找不到指定程序:" + finalX265Path); } processinfo.FileName = Environment.GetEnvironmentVariable("ComSpec"); string x264Line; string outputpath = ""; Getx265Line(fileConfig, 1, out x264Line, out outputpath); string ffmpegline = TextManager.Mh + FFmpegCommand.FFmpegExecute + TextManager.Mh + FFmpegCommand.GetFfmpegArgs(fileConfig); var bat = ffmpegline + finalX265Path + " " + x264Line + " -"; //processinfo.UseShellExecute = false; //输出信息重定向 //processinfo.CreateNoWindow = true; //processinfo.RedirectStandardInput = true; //processinfo.RedirectStandardOutput = true; //processinfo.RedirectStandardError = false; //processinfo.WindowStyle = ProcessWindowStyle.Hidden; Process avsx264mod = new Process(); if (vedioConfig.BitType == EncoderBitrateType.crf) { ProcessCmd.RunBat(bat, Config.Temp); } else if (vedioConfig.BitType == EncoderBitrateType.twopass) { Getx265Line(fileConfig, 1, out x264Line, out outputpath); var bat1 = ffmpegline + finalX265Path + " " + x264Line + " -"; ProcessCmd.RunBat(bat1, Config.Temp); Getx265Line(fileConfig, 2, out x264Line, out outputpath); var bat2 = ffmpegline + finalX265Path + " " + x264Line + " -"; ProcessCmd.RunBat(bat2, Config.Temp); } avsx264mod.Dispose(); return(outputpath); }
private static string GetX265exeFullName(VedioConfig vedioConfig) { string x265exe = ""; if (vedioConfig.depth == 10) { x265exe = x265Excute10; } else { x265exe = x265Excute8; } return(x265exe); }
private void SetVedioConfigByControl(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; if (!string.IsNullOrEmpty(textBox3.Text)) { vedioConfig.crf = float.Parse(textBox3.Text); vedioConfig.BitType = EncoderBitrateType.crf; } else { vedioConfig.bitrate = int.Parse(txtbitrate.Text); vedioConfig.BitType = EncoderBitrateType.twopass; } if (cbEnableQpmod.Checked) { vedioConfig.BitType = EncoderBitrateType.qp; } //if (cbEnableX265.Checked) //vedioConfig.ffmpeg4x265Args = txtffmpeg4x265.Text; #if X265 vedioConfig.Encoder = Encoder.x265; #else #endif vedioConfig.UserArgs = txtUserArgs.Text; vedioConfig.depth = int.Parse(cbColorDepth.Text); vedioConfig.preset = cbpreset.Text; vedioConfig.tune = comboBox1.Text; vedioConfig.Resize = checkBox1.Checked; vedioConfig.csp = cbcsp.Text; vedioConfig.Width = textBox4.Text == "" ? 0 : int.Parse(textBox4.Text); vedioConfig.Height = textBox5.Text == "" ? 0 : int.Parse(textBox5.Text); if (cbUseAvsTemplete.Checked) {//处理自定义avs模板 fileConfig.InputType = InputType.AvisynthScript; string avsscript = txtAvsScript.Text; avsscript = avsscript.Replace("$InputVedio$", fileConfig.VedioFileFullName) .Replace("$avisynth_plugin$", Path.Combine(Application.StartupPath, "tools\\avsplugin")); vedioConfig.AvsScript = avsscript; } else if (cbUseVSTemplete.Checked) {//处理自定义avs模板 fileConfig.InputType = InputType.VapoursynthScript; string avsscript = txtVsScript.Text; avsscript = avsscript.Replace("$InputVedio$", fileConfig.VedioFileFullName) .Replace("$vapoursynth_plugin$", Path.Combine(Application.StartupPath, Config.VsPluginPath)); vedioConfig.VapoursynthScript = avsscript; } }
public static string ffmpegPipeX265(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; ProcessStartInfo processinfo = new ProcessStartInfo(); string finalX265Path = ""; finalX265Path = GetX265LiteFullName(vedioConfig); if (Config.IsWindows) { finalX265Path = Path.Combine(Application.StartupPath, finalX265Path); } string x264Line; string outputpath = ""; Getx265Line(fileConfig, 1, out x264Line, out outputpath); string ffmpegline = Path.Combine(Application.StartupPath, FFmpegCommand.FFmpegExecute).Maohao() + FFmpegCommand.GetFfmpegArgs(fileConfig); var bat = ffmpegline + finalX265Path.Maohao() + " " + x264Line; //bat += "\r\npause"; //processinfo.UseShellExecute = false; //输出信息重定向 //processinfo.CreateNoWindow = true; //processinfo.RedirectStandardInput = true; //processinfo.RedirectStandardOutput = true; //processinfo.RedirectStandardError = false; //processinfo.WindowStyle = ProcessWindowStyle.Hidden; Process avsx264mod = new Process(); if (vedioConfig.BitType == EncoderBitrateType.crf) { ProcessCmd.RunBat(bat, Config.Temp); } else if (vedioConfig.BitType == EncoderBitrateType.twopass) { Getx265Line(fileConfig, 1, out x264Line, out outputpath); var bat1 = ffmpegline + finalX265Path + " " + x264Line + " -"; ProcessCmd.RunBat(bat1, Config.Temp); Getx265Line(fileConfig, 2, out x264Line, out outputpath); var bat2 = ffmpegline + finalX265Path + " " + x264Line + " -"; ProcessCmd.RunBat(bat2, Config.Temp); } avsx264mod.Dispose(); return(outputpath); }
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); } }
public static string RunAvsx264mod(FileConfig fileConfig) { VedioConfig vedioConfig = fileConfig.VedioConfig; ProcessStartInfo processinfo = new ProcessStartInfo(); processinfo.UseShellExecute = false; //输出信息重定向 processinfo.CreateNoWindow = true; processinfo.RedirectStandardInput = true; processinfo.RedirectStandardOutput = true; processinfo.RedirectStandardError = true; processinfo.WindowStyle = ProcessWindowStyle.Hidden; processinfo.FileName = Path.Combine(Application.StartupPath, avs4x265); var finalX265Path = ""; if (!File.Exists(processinfo.FileName)) { throw new EncoderException("找不到指定程序:" + processinfo.FileName); } if (vedioConfig.depth == 8) { finalX265Path = x265Excute8lite; } else if (vedioConfig.depth == 10) { finalX265Path = x265Excute10lite; } if (!File.Exists(finalX265Path)) { throw new EncoderException("找不到指定程序:" + finalX265Path); } string x264Line; string outputpath = ""; Process avsx264mod = new Process(); if (vedioConfig.BitType == EncoderBitrateType.crf) { Getx265Line(fileConfig, 0, out x264Line, out outputpath); string avsx264modarg = string.Format("--x265-binary \"{0}\" ", Path.GetFileName(finalX265Path)); processinfo.Arguments = avsx264modarg + x264Line; avsx264mod.StartInfo = processinfo; OutputToText(fileConfig, avsx264mod); avsx264mod.Start(); avsx264mod.BeginOutputReadLine(); avsx264mod.BeginErrorReadLine(); avsx264mod.WaitForExit(); } else if (vedioConfig.BitType == EncoderBitrateType.twopass) { Getx265Line(fileConfig, 1, out x264Line, out outputpath); string avsx264modarg = string.Format("--x265-binary \"{0}\" ", finalX265Path); processinfo.Arguments = avsx264modarg + x264Line; avsx264mod.StartInfo = processinfo; OutputToText(fileConfig, avsx264mod); avsx264mod.Start(); avsx264mod.BeginOutputReadLine(); avsx264mod.BeginErrorReadLine(); avsx264mod.WaitForExit(); Getx265Line(fileConfig, 2, out x264Line, out outputpath); avsx264modarg = string.Format("--x265-binary \"{0}\" ", finalX265Path); processinfo.Arguments = avsx264modarg + x264Line; avsx264mod.StartInfo = processinfo; OutputToText(fileConfig, avsx264mod); avsx264mod.Start(); avsx264mod.BeginOutputReadLine(); avsx264mod.BeginErrorReadLine(); avsx264mod.WaitForExit(); } avsx264mod.Dispose(); return(outputpath); }
private void StartOneThread() { int isHandling = -1; while (true) { int thisstate = -1; ListViewItem item = null; FileConfig fileConfig = null; try { lock (handledlock) { if (isHandling >= listView2.Items.Count - 1) { return; } hasHandle++; isHandling = hasHandle; this.Invoke((Action) delegate() { item = listView2.Items[isHandling]; fileConfig = item.Tag as FileConfig; if (fileConfig.state != -1) { thisstate = -10; } listView2.Items[isHandling].SubItems["States"].Text = "视频转码中"; fileConfig.state++; }); if (thisstate == -10) { continue; } this.Invoke((Action) delegate() { if (fileConfig.InputType == InputType.AvisynthScriptFile || fileConfig.InputType == InputType.AvisynthScript) { EncoderTaskInfoForm form = new EncoderTaskInfoForm(); form.fileConfig = fileConfig; form.lbFile.Text = fileConfig.FullName; form.Text = fileConfig.FullName; fileConfig.EncoderTaskInfo.infoForm = form; form.Show(); } }); } string outputfile = ""; string copyto = string.Empty; string ralative = string.Empty; //仅输出视频部分 if (fileConfig.KeepDirection) {//保持目录树结构 ralative = FileUtility.MakeRelativePath(fileConfig.DirPath + "/", Path.GetDirectoryName(fileConfig.FullName)); string outpath = Path.Combine(fileConfig.OutputPath, ralative); outputfile = Path.Combine(outpath, Path.GetFileNameWithoutExtension(fileConfig.FullName)); } else if (fileConfig.OutputPath != "") {//有输出目录 outputfile = Path.Combine(fileConfig.OutputPath, Path.GetFileNameWithoutExtension(fileConfig.FullName)); } else {//输出原路径 outputfile = Path.Combine(Path.GetDirectoryName(fileConfig.FullName), Path.GetFileNameWithoutExtension(fileConfig.FullName)); } if (fileConfig.CompleteDo && !string.IsNullOrEmpty(fileConfig.CompleteActionDir)) { if (fileConfig.KeepDirection) {//保持目录树结构 copyto = Path.Combine(fileConfig.CompleteActionDir, ralative, Path.GetFileNameWithoutExtension(fileConfig.FullName)); } else { copyto = Path.Combine(fileConfig.CompleteActionDir, Path.GetFileNameWithoutExtension(fileConfig.FullName)); } } else { fileConfig.CompleteDo = false; } fileConfig.OutputFile = outputfile; VedioConfig vedioconfig = fileConfig.VedioConfig; string vedioOutputFile = string.Empty; try { if (vedioconfig.Encoder == Encoder.x264) { if (fileConfig.InputType == InputType.Vedio) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); vedioOutputFile = X264Command.RunX264Command(fileConfig); } else if (fileConfig.InputType == InputType.AvisynthScriptFile) { vedioOutputFile = X264Command.RunAvsx264mod(fileConfig); } else if (fileConfig.InputType == InputType.AvisynthScript) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); string avsfilename = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".avs")); File.WriteAllText(avsfilename, vedioconfig.AvsScript, System.Text.Encoding.Default); fileConfig.AvsFileFullName = avsfilename; fileConfig.InputType = InputType.AvisynthScriptFile; vedioOutputFile = X264Command.RunAvsx264mod(fileConfig); } else if (fileConfig.InputType == InputType.VapoursynthScriptFile) { vedioOutputFile = X264Command.RunVSx265(fileConfig); } else if (fileConfig.InputType == InputType.VapoursynthScript) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); string avsfilename = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".vpy")); File.WriteAllText(avsfilename, vedioconfig.VapoursynthScript, System.Text.Encoding.UTF8); fileConfig.VapoursynthFileFullName = avsfilename; fileConfig.InputType = InputType.VapoursynthScriptFile; vedioOutputFile = X264Command.RunVSx265(fileConfig); } } else if (vedioconfig.Encoder == Encoder.x265) { if (fileConfig.InputType == InputType.Vedio) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); vedioOutputFile = X265Command.RunX265Command(fileConfig); } else if (fileConfig.InputType == InputType.AvisynthScriptFile) { vedioOutputFile = X265Command.RunAvsx264mod(fileConfig); } else if (fileConfig.InputType == InputType.AvisynthScript) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); string avsfilename = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".avs")); File.WriteAllText(avsfilename, vedioconfig.AvsScript, System.Text.Encoding.Default); fileConfig.AvsFileFullName = avsfilename; fileConfig.InputType = InputType.AvisynthScriptFile; vedioOutputFile = X265Command.RunAvsx264mod(fileConfig); } else if (fileConfig.InputType == InputType.VapoursynthScriptFile) { vedioOutputFile = X265Command.RunVSx265(fileConfig); } else if (fileConfig.InputType == InputType.VapoursynthScript) { fileConfig.mediaInfo = new MediaInfo(fileConfig.FullName); string avsfilename = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".vpy")); File.WriteAllText(avsfilename, vedioconfig.VapoursynthScript, System.Text.Encoding.UTF8); fileConfig.VapoursynthFileFullName = avsfilename; fileConfig.InputType = InputType.VapoursynthScriptFile; vedioOutputFile = X265Command.RunVSx265(fileConfig); } } } catch (EncoderException e) { this.Invoke((Action) delegate() { listView2.Items[isHandling].SubItems["States"].Text = e.Message; }); fileConfig.state = -10; continue; } if (!File.Exists(vedioOutputFile)) { this.Invoke((Action) delegate() { listView2.Items[isHandling].SubItems["States"].Text = "视频编码失败"; }); fileConfig.state = -10; continue; } if (fileConfig.AudioConfig.Enabled && fileConfig.state != 10) { if (fileConfig.InputType == InputType.Vedio && fileConfig.AudioConfig.CopyStream) { //直接由x264处理掉了 } else { this.Invoke((Action) delegate() { item = listView2.Items[isHandling]; item.SubItems["States"].Text = "音频转码中"; }); string audiofile = string.Empty; if (fileConfig.AudioConfig.CopyStream) { audiofile = CommandHelper.DemuxAudio(fileConfig); } else { if (fileConfig.AudioConfig.UseEac3to) { if (fileConfig.AudioConfig.Encoder == AudioEncoder.aac) { audiofile = Eac3toCommand.ConvertMusic(fileConfig); } else { audiofile = Eac3toCommand.ConvertAudioTOpus(fileConfig); } } else { if (fileConfig.AudioConfig.Encoder == AudioEncoder.aac) { audiofile = CommandHelper.RunFFmpegToAAC(fileConfig); } else { audiofile = CommandHelper.RunFFmpegToOpus(fileConfig); } } } this.Invoke((Action) delegate() { item = listView2.Items[isHandling]; item.SubItems["States"].Text = "封装中"; }); int delay = 0; if (fileConfig.mediaInfo != null) { delay = fileConfig.mediaInfo.DelayRelativeToVideo; delay = delay - 67; } if (fileConfig.Muxer == "mkv") { vedioOutputFile = CommandHelper.MKVmergin(fileConfig, vedioOutputFile, audiofile, delay); } else if (fileConfig.Muxer == "mp4") { vedioOutputFile = CommandHelper.mp4box(fileConfig, vedioOutputFile, audiofile, delay); } else if (fileConfig.Muxer == "flv") { vedioOutputFile = CommandHelper.ffmpegmux(fileConfig, vedioOutputFile, audiofile, fileConfig.Muxer); if (fileConfig.sinablack) { FlvMain flvbugger = new FlvMain(); flvbugger.addFile(vedioOutputFile); flvbugger.ExecuteBlack(999d, -1, Path.ChangeExtension(vedioOutputFile, ".black.flv")); } else if (fileConfig.sinaPreblack) { FlvMain flvbugger = new FlvMain(); flvbugger.addFile(vedioOutputFile); flvbugger.ExecuteTime(999d, -1, Path.ChangeExtension(vedioOutputFile, ".speed.flv")); } } } } if (fileConfig.CompleteDo && fileConfig.state != 10) { try { copyto = copyto + Path.GetExtension(vedioOutputFile); copyto = FileUtility.GetNoSameNameFile(copyto); if (fileConfig.CompleteAction == "拷贝到") { this.Invoke((Action) delegate() { listView2.Items[isHandling].SubItems["States"].Text = "拷贝中"; }); File.Copy(vedioOutputFile, copyto, true); } else if (fileConfig.CompleteAction == "剪切到") { this.Invoke((Action) delegate() { listView2.Items[isHandling].SubItems["States"].Text = "剪切中"; }); File.Move(vedioOutputFile, copyto); } } catch { } } this.Invoke((Action) delegate() { if (fileConfig.state == -10) { listView2.Items[isHandling].SubItems["States"].Text = "失败"; } else { listView2.Items[isHandling].SubItems["States"].Text = "完成"; } }); } catch (Exception ex) { this.Invoke((Action) delegate() { listView2.Items[isHandling].SubItems["States"].Text = "失败:" + ex.Message; }); } } }
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}"; } }