Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
修改cut的读取方法,现在更笨,但不会报错
修正老编码器配置的兼容性,现在不会报错了,#8
  • Loading branch information
YohoYang committed Dec 17, 2023
1 parent a282d14 commit a88d3c1
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 66 deletions.
10 changes: 9 additions & 1 deletion VSGUI/API/EncoderApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ public static string GetEncoderPath(string type, int encoderid)
{
var encoderJson = GetEncoderJson();
JsonObject thisJobj = encoderJson[type][encoderid].AsObject();
return thisJobj["encoderpath"].ToString();
if (thisJobj.ContainsKey("encoderpath"))
{
return thisJobj["encoderpath"].ToString();
}
else
{
string codepath = EncoderWindow.GetEncoderPathByCode(type, GetEncoderName(type, encoderid));
return codepath;
}
}

public static string GetName(string type, int encoderid)
Expand Down
168 changes: 106 additions & 62 deletions VSGUI/API/QueueApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static string ProcessCommandStr(int queueid, string type, int encoderid,
string encoderpath;
if (!thisJobj.ContainsKey("encoderpath"))
{
encoderpath = "\"" + Directory.GetCurrentDirectory() + GetDefaultEncoderP(type, pEncoderName, "encoderpath") + "\"" + " ";
encoderpath = "\"" + GetDefaultEncoderP(type, pEncoderName, "encoderpath") + "\"" + " ";
}
else
{
Expand Down Expand Up @@ -800,52 +800,25 @@ public static void VpyFileInputCheck(string videoinputboxText, out string cuttex
//获取fps
fpstextboxText = x[1].Groups[2].Value;
//cut检测
string autoGenCutConfig = IniApi.IniReadValue("AutoGenerateCut");
if (autoGenCutConfig == "") autoGenCutConfig = "true";
if (bool.Parse(autoGenCutConfig))
try
{
//获取vpy脚本及每行内容
string vpyfilestr = File.ReadAllText(inputpath);
string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n");
//获取最终输出
string finaloutVar = "";
var xo0 = Regex.Matches(vpyfilestr, @"(.*?)\.set_output");
if (xo0.Count > 0)
{
finaloutVar = xo0[0].Groups[1].Value;
}
//创建键值对
Dictionary<string, string> cutmap = new Dictionary<string, string>();
//定义最终str
string finalcutstr = "";
//错误标记
bool isCutError = false;
//遍历每一行
foreach (var listitem in vpyfilestrlist)
string autoGenCutConfig = IniApi.IniReadValue("AutoGenerateCut");
if (autoGenCutConfig == "") autoGenCutConfig = "true";
if (bool.Parse(autoGenCutConfig))
{
//判断非注释
if (!listitem.TrimStart().StartsWith("#"))
//改成简单版本的判断
string vpyfilestr = File.ReadAllText(inputpath);
string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n");
string finalcutstr = "";
foreach (string listitem in vpyfilestrlist)
{
//获取被赋值变量
string assigned = "";
var x0 = Regex.Matches(listitem, @"(.*?)\s*?=");
if (x0.Count > 0)
if (!listitem.TrimStart().StartsWith("#"))
{
if (x0[0].Groups.Count > 0)
var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]");
string linecutstr = "";
if (x1.Count > 0)
{
assigned = x0[0].Groups[1].Value;
}
}
//获取裁剪参数
var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]");
string linecutstr = "";
if (x1.Count > 0)
{
for (int i = 0; i < x1.Count; i++)
{
string assign = x1[i].Groups[1].Value;
if (assign == "") assign = x1[i].Groups[3].Value;
if (assigned == assign) // ?最简单的保护,如果是复合变量直接放弃
for (int i = 0; i < x1.Count; i++)
{
string cutmessagestr = x1[i].Groups[2].Value;
if (cutmessagestr == "") cutmessagestr = x1[i].Groups[4].Value;
Expand All @@ -856,32 +829,103 @@ public static void VpyFileInputCheck(string videoinputboxText, out string cuttex
linecutstr += "+";
}
}
else
if (finalcutstr != "")
{
isCutError = true;
finalcutstr += "&";
}
}
//处理变量map
if (cutmap.ContainsKey(assigned))
{
cutmap[assigned] = cutmap[assigned] + @"&" + linecutstr;
}
else
{
cutmap.Add(assigned, linecutstr);
finalcutstr += linecutstr;
}
}
}
cuttextboxText = finalcutstr;
if (finalcutstr != "")
{
cutischeckedIsChecked = true;
}

////获取vpy脚本及每行内容
//string vpyfilestr = File.ReadAllText(inputpath);
//string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n");
////获取最终输出
//string finaloutVar = "";
//var xo0 = Regex.Matches(vpyfilestr, @"(.*?)\.set_output");
//if (xo0.Count > 0)
//{
// finaloutVar = xo0[0].Groups[1].Value;
//}
////创建键值对
//Dictionary<string, string> cutmap = new Dictionary<string, string>();
////定义最终str
//string finalcutstr = "";
////错误标记
//bool isCutError = false;
////遍历每一行
//foreach (var listitem in vpyfilestrlist)
//{
// //判断非注释
// if (!listitem.TrimStart().StartsWith("#"))
// {
// //获取被赋值变量
// string assigned = "";
// var x0 = Regex.Matches(listitem, @"(.*?)\s*?=");
// if (x0.Count > 0)
// {
// if (x0[0].Groups.Count > 0)
// {
// assigned = x0[0].Groups[1].Value;
// }
// }
// //获取裁剪参数
// var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]");
// string linecutstr = "";
// if (x1.Count > 0)
// {
// for (int i = 0; i < x1.Count; i++)
// {
// string assign = x1[i].Groups[1].Value;
// if (assign == "") assign = x1[i].Groups[3].Value;
// if (assigned == assign) // ?最简单的保护,如果是复合变量直接放弃
// {
// string cutmessagestr = x1[i].Groups[2].Value;
// if (cutmessagestr == "") cutmessagestr = x1[i].Groups[4].Value;
// string[] cutmessagelist = cutmessagestr.Replace(":", ",").Replace(" ", "").Replace("(", "").Replace(")", "").Replace("[", "").Replace("]", "").Split(",");//获得cut的前后帧
// linecutstr += "[" + cutmessagelist[0] + ":" + cutmessagelist[1] + "]";
// if (i != x1.Count - 1)
// {
// linecutstr += "+";
// }
// }
// else
// {
// isCutError = true;
// }
// }
// //处理变量map
// if (cutmap.ContainsKey(assigned))
// {
// cutmap[assigned] = cutmap[assigned] + @"&" + linecutstr;
// }
// else
// {
// cutmap.Add(assigned, linecutstr);
// }
// }
// }
//}
//if (!isCutError && cutmap.Count > 0)
//{
// finalcutstr = cutmap[finaloutVar];
//}
//cuttextboxText = finalcutstr;
//if (finalcutstr != "")
//{
// cutischeckedIsChecked = true;
//}
}
if (!isCutError && cutmap.Count > 0)
{
finalcutstr = cutmap[finaloutVar];
}
cuttextboxText = finalcutstr;
if (finalcutstr != "")
{
cutischeckedIsChecked = true;
}
}
catch (Exception)
{
//cut判断失败
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion VSGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class MainWindow
{
public static string binpath = Directory.GetCurrentDirectory() + @"\bin";
private bool forcedStop = false;
private string coreversion = "v1.0.4";
private string coreversion = "v1.0.5";
public static string logBoxStr = "";
private string[] videoMultiInputLists, audioMultiInputLists;

Expand Down
2 changes: 1 addition & 1 deletion VSGUI/Properties/Langs/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<system:String x:Key="nomoreprompts">No More Prompts</system:String>
<system:String x:Key="netEncoderProtectDesc">The profile is NetEncoder. Editing is not allowed.</system:String>
<system:String x:Key="autoGenerateCut">When entering the vpy script, automatically read the Cuts information</system:String>
<system:String x:Key="autoGenerateCutDesc">In advanced Encode mode, when inputting a vpy script, the clip script is automatically read from the script and filled in the audio information area (only single variable is supported).</system:String>
<system:String x:Key="autoGenerateCutDesc">In advanced Encode mode, when inputting a vpy script, the clip script is automatically read from the script and filled in the audio information area (Complex scripts are not supported).</system:String>
<system:String x:Key="queueDeleteCacheTipsDesc">The following temporary files exist in the task. Do you want to delete them?</system:String>
<system:String x:Key="notInstalled">Not Installed</system:String>
<system:String x:Key="useSystemEnvironment">Use system environment</system:String>
Expand Down
2 changes: 1 addition & 1 deletion VSGUI/Properties/Langs/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<system:String x:Key="nomoreprompts">不再提示</system:String>
<system:String x:Key="netEncoderProtectDesc">该配置为网络配置,不允许修改</system:String>
<system:String x:Key="autoGenerateCut">输入vpy脚本时,自动读取Cuts信息</system:String>
<system:String x:Key="autoGenerateCutDesc">在高级压制模式下,输入vpy脚本时,自动从脚本中读取剪辑脚本,并填写到音频信息区(仅支持单变量)。</system:String>
<system:String x:Key="autoGenerateCutDesc">在高级压制模式下,输入vpy脚本时,自动从脚本中读取剪辑脚本,并填写到音频信息区(不支持复杂脚本)。</system:String>
<system:String x:Key="queueDeleteCacheTipsDesc">任务存在如下临时文件,是否删除?</system:String>
<system:String x:Key="notInstalled">未安装</system:String>
<system:String x:Key="useSystemEnvironment">使用系统环境</system:String>
Expand Down
12 changes: 12 additions & 0 deletions VSGUI/Windows/EncoderWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ private string GetEncoderPath(string encodername)
return "";
}

public static string GetEncoderPathByCode(string type,string name)
{
for (int i = 0; i < encoders.GetLength(0); i++)
{
if (encoders[i, 0].Equals(type) && encoders[i, 1].Equals(name))
{
return encoders[i, 3];
}
}
return "";
}

private string GetEncoderPipeinputformat(string encodername)
{

Expand Down

0 comments on commit a88d3c1

Please sign in to comment.