Skip to content

Commit

Permalink
v1.0.4:简易压制自动判断是否需要反交错的判断不容易做到精确,所以现在是否反交错不再自动判断,在简易压制中增加一项设置,由用户自行选择。
Browse files Browse the repository at this point in the history
  • Loading branch information
YohoYang committed Dec 12, 2023
1 parent e3efe41 commit 255f3b3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
20 changes: 17 additions & 3 deletions VSGUI/API/QueueApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static string GetDefaultEncoderP(string encodertype, string encodername,
return returnStr;
}

public static void AddQueueList(string type, int encoderid, string[] input, string output, string chapinput = "", string group = "", string deletefile = "", string resolution = "", string subtitle = "", string audiocuttext = "", string audiofpstext = "", string audiodelaytext = "")
public static void AddQueueList(string type, int encoderid, string[] input, string output, string chapinput = "", string group = "", string deletefile = "", string resolution = "", string subtitle = "", string audiocuttext = "", string audiofpstext = "", string audiodelaytext = "", string tfmenable = "")
{
JsonArray queueJobj = GetQueueList();
int newid;
Expand Down Expand Up @@ -256,6 +256,7 @@ public static void AddQueueList(string type, int encoderid, string[] input, stri
newqueue.Add("audiocuttext", audiocuttext);
newqueue.Add("audiofpstext", audiofpstext);
newqueue.Add("audiodelaytext", audiodelaytext);
newqueue.Add("tfmenable", tfmenable);

queueJobj.Add(newqueue);

Expand Down Expand Up @@ -600,7 +601,14 @@ public static string GetQueueListitem(string queueid, string key)
{
if (item["queueid"].ToString() == queueid)
{
return item[key].ToString();
if (item[key] != null)
{
return item[key].ToString();
}
else
{
return null;
}
}
}
return null;
Expand Down Expand Up @@ -670,9 +678,15 @@ public static void MakeScriptFile(string queueid)
//生成文件 v0.2.1
if (GetQueueListitem(queueid, "type") == "video")
{
//简易压制用
if (Path.GetExtension(GetQueueListitem(queueid, "input")) != ".vpy")
{
string script = VideoApi.MakeVideoScript(GetQueueListitem(queueid, "input"), GetQueueListitem(queueid, "resolution"), GetQueueListitem(queueid, "subtitle"));
bool tfmEnable = false;
if (GetQueueListitem(queueid, "tfmenable") != null && GetQueueListitem(queueid, "tfmenable") == "true")
{
tfmEnable = true;
}
string script = VideoApi.MakeVideoScript(GetQueueListitem(queueid, "input"), GetQueueListitem(queueid, "resolution"), GetQueueListitem(queueid, "subtitle"), tfmEnable);
string scriptpath = CommonApi.GetAppTempPath() + "Job_" + queueid + ".vpy";
string command = ProcessCommandStr(int.Parse(queueid), "video", int.Parse(GetQueueListitem(queueid, "encoderid")), new string[] { GetQueueListitem(queueid, "input") }, "", GetQueueListitem(queueid, "output"), scriptpath, out string temp1, out string temp2);
SetQueueListitem(queueid, "script", script);
Expand Down
14 changes: 7 additions & 7 deletions VSGUI/API/VideoApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace VSGUI.API
{
internal class VideoApi
{
public static string MakeVideoScript(string videoinputpath, string resolution, string subpath)
public static string MakeVideoScript(string videoinputpath, string resolution, string subpath, bool tfmEnable=false)
{
//输入视频信息检测
int sourceWidth = 0;
int sourceHeight = 0;
bool tfm = false;
//bool tfm = false;
if (!string.IsNullOrEmpty(videoinputpath) && File.Exists(videoinputpath))
{
string result = ProcessApi.RunSyncProcess(MainWindow.binpath + @"\encoder\ffmpeg\", @"ffmpeg.exe" + " -hide_banner -y -i " + "\"" + videoinputpath + "\"");
Expand All @@ -37,10 +37,10 @@ public static string MakeVideoScript(string videoinputpath, string resolution, s
{
sourceWidth = (int)Math.Round((sourceWidth * (double.Parse(sarInfo[0].Groups[1].ToString()) / double.Parse(sarInfo[0].Groups[2].ToString()))) / 2, MidpointRounding.AwayFromZero) * 2;
}
if (!result.Contains("progressive"))
{
tfm = true;
}
//if (!result.Contains("progressive"))
//{
// tfm = true;
//}
}
}
else
Expand All @@ -55,7 +55,7 @@ public static string MakeVideoScript(string videoinputpath, string resolution, s
scriptstr += @"videosrc = r" + "\"" + videoinputpath + "\"" + "\r\n";
scriptstr += @"video = core.lsmas.LWLibavSource(videosrc)" + "\r\n";
scriptstr += "\r\n";
if (tfm)
if (tfmEnable)
{
scriptstr += @"video = core.tivtc.TFM(video, order=-1, mode=1, PP=5, slow=2, chroma=False)" + "\r\n";
scriptstr += @"video = core.tivtc.TDecimate(video, mode=1, cycle=5)" + "\r\n";
Expand Down
13 changes: 11 additions & 2 deletions VSGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</hc:ButtonGroup>
</WrapPanel>
<!--简易压制-->
<StackPanel x:Name="simpleEncodePanel" Grid.Row="1" Visibility="Collapsed">
<StackPanel x:Name="simpleEncodePanel" Grid.Row="1" Visibility="Visible">
<TextBlock Text="{DynamicResource input}" Margin="5,3,0,6" Foreground="#a3a3a3"/>
<Border Style="{StaticResource BorderRegion}">
<hc:UniformSpacingPanel Spacing="6" Orientation="Vertical">
Expand Down Expand Up @@ -140,6 +140,15 @@
<ComboBoxItem Content="mkv"/>
</ComboBox>
</Grid>
<!--其他设置-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" VerticalAlignment="Center" Text="{DynamicResource p034}" Margin="0,0,6,0"/>
<CheckBox x:Name="tfmCheckBox" Grid.Column="1" Content="{DynamicResource p035}" MinHeight="30"/>
</Grid>
</hc:UniformSpacingPanel>
</Border>
<TextBlock Text="{DynamicResource output}" Margin="5,10,0,6" Foreground="#a3a3a3"/>
Expand Down Expand Up @@ -172,7 +181,7 @@
</Border>
</StackPanel>
<!--手动压制-->
<StackPanel x:Name="advancedEncodePanel" Grid.Row="1" Visibility="Visible">
<StackPanel x:Name="advancedEncodePanel" Grid.Row="1" Visibility="Collapsed">
<!--视频区-->
<TextBlock Text="{DynamicResource video}" Margin="5,3,0,6" Foreground="#a3a3a3"/>
<Border x:Name="videoborder" Style="{StaticResource BorderRegion}" AllowDrop="True" PreviewDrop="Border_Drop">
Expand Down
16 changes: 13 additions & 3 deletions 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.3";
private string coreversion = "v1.0.4";
public static string logBoxStr = "";
private string[] videoMultiInputLists, audioMultiInputLists;

Expand Down Expand Up @@ -1006,12 +1006,17 @@ private void SimpleAutoEncodeButton_Click(object sender, RoutedEventArgs e)
}
}
}
string tfmEnable = "false";
if (tfmCheckBox.IsChecked == true)
{
tfmEnable = "true";
}

//生成groud名
string groupname = CommonApi.GetNewSeed();
string tempvideopath = Path.GetDirectoryName(simplevideooutputbox.Text) + @"\" + groupname + "_v" + EncoderApi.GetEncoderSuffix("video", simplevideoencoderbox.SelectedIndex);
string tempaudiopath = Path.GetDirectoryName(simplevideooutputbox.Text) + @"\" + groupname + "_a" + EncoderApi.GetEncoderSuffix("audio", simpleaudioencoderbox.SelectedIndex);
QueueApi.AddQueueList("video", simplevideoencoderbox.SelectedIndex, new string[] { simplevideoinputbox.Text }, tempvideopath, resolution: simpleresolutionbox.Text.ToUpper(), subtitle: simpleasspathinputbox.Text, group: groupname);
QueueApi.AddQueueList("video", simplevideoencoderbox.SelectedIndex, new string[] { simplevideoinputbox.Text }, tempvideopath, resolution: simpleresolutionbox.Text.ToUpper(), subtitle: simpleasspathinputbox.Text, group: groupname, tfmenable: tfmEnable);
QueueApi.AddQueueList("audio", simpleaudioencoderbox.SelectedIndex, new string[] { simpleaudioinputbox.Text }, tempaudiopath, deletefile: simpleaudioinputbox.Text + ".lwi", group: groupname);
//再添加一个混流任务
QueueApi.AddQueueList("mux", 0, new string[] { tempvideopath, tempaudiopath }, Path.GetDirectoryName(simplevideooutputbox.Text) + @"\" + Path.GetFileNameWithoutExtension(simplevideooutputbox.Text) + @"_mux." + simplemuxsuffixbox.Text.ToLower(), chapinput: simplecapinputbox.Text, deletefile: tempvideopath + "|" + tempaudiopath, group: groupname);
Expand Down Expand Up @@ -1760,7 +1765,12 @@ private void SimpleOpenEditorButton_Click(object sender, RoutedEventArgs e)
{
return;
}
string script = VideoApi.MakeVideoScript(simplevideoinputbox.Text, simpleresolutionbox.Text.ToUpper(), simpleasspathinputbox.Text);
bool tfmEnable = false;
if (tfmCheckBox.IsChecked == true)
{
tfmEnable = true;
}
string script = VideoApi.MakeVideoScript(simplevideoinputbox.Text, simpleresolutionbox.Text.ToUpper(), simpleasspathinputbox.Text, tfmEnable);
if (script == null)
{
MessageBoxApi.Show("DEBUG ERROR: 视频信息读取错误,麻烦提供视频文件协助调试", LanguageApi.FindRes("error"));
Expand Down
2 changes: 2 additions & 0 deletions VSGUI/Properties/Langs/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,7 @@
<system:String x:Key="p031">Go to advanced suppression</system:String>
<system:String x:Key="p032">[xxx:xxx]+[xxx:xxx]</system:String>
<system:String x:Key="p033">The update has been downloaded and will be updated after the next restart</system:String>
<system:String x:Key="p034">Other settings</system:String>
<system:String x:Key="p035">Video deinterlacing</system:String>

</ResourceDictionary>
2 changes: 2 additions & 0 deletions VSGUI/Properties/Langs/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,7 @@
<system:String x:Key="p031">转到高级压制</system:String>
<system:String x:Key="p032">[xxx:xxx]+[xxx:xxx]</system:String>
<system:String x:Key="p033">更新已下载完成,下次重新启动后更新</system:String>
<system:String x:Key="p034">其他设置</system:String>
<system:String x:Key="p035">视频反交错</system:String>

</ResourceDictionary>

0 comments on commit 255f3b3

Please sign in to comment.