Skip to content

Commit 84a0ab8

Browse files
committed
Added column for displaying chapter status
1 parent d6c913e commit 84a0ab8

File tree

11 files changed

+97
-28
lines changed

11 files changed

+97
-28
lines changed

OKEGui/OKEGui/Gui/MainWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
mc:Ignorable="d"
8-
Title="OKEGui" Height="500" Width="950" WindowStartupLocation="CenterScreen" Icon="App.ico">
8+
Title="OKEGui" Height="600" Width="1000" WindowStartupLocation="CenterScreen" Icon="App.ico">
99
<Window.Resources>
1010
<Style TargetType="ListViewItem">
1111
<Setter Property="HorizontalContentAlignment" Value="Center" />
@@ -24,15 +24,15 @@
2424
</GridViewColumn>
2525
<GridViewColumn Header="任务名称" Width="95" DisplayMemberBinding="{Binding Path=TaskName}">
2626
</GridViewColumn>
27-
<!--<GridViewColumn Header="ID" Width="30" DisplayMemberBinding="{Binding Path=Tid}">
28-
</GridViewColumn>-->
2927
<GridViewColumn Header="输入文件" Width="150">
3028
<GridViewColumn.CellTemplate>
3129
<DataTemplate>
3230
<TextBlock TextAlignment="Left" Text="{Binding Path=InputFile}"></TextBlock>
3331
</DataTemplate>
3432
</GridViewColumn.CellTemplate>
3533
</GridViewColumn>
34+
<GridViewColumn Header="章节" Width="50" DisplayMemberBinding="{Binding Path=ChapterStatus}">
35+
</GridViewColumn>
3636
<GridViewColumn Header="输出文件" Width="125">
3737
<GridViewColumn.CellTemplate>
3838
<DataTemplate>
@@ -86,7 +86,7 @@
8686
<Button Height="23" Grid.Column="0" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnNew" VerticalAlignment="Top" Click="BtnNew_Click" Content="新建任务" />
8787
<Button Height="23" Grid.Column="1" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnRun" VerticalAlignment="Top" Click="BtnRun_Click" Content="运行" />
8888
<Button Height="23" Grid.Column="2" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnStop" VerticalAlignment="Top" Click="BtnStop_Click" Content="停止" />
89-
<Button Height="23" Grid.Column="3" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnEdit" VerticalAlignment="Top" Click="BtnEdit_Click" Content="编辑" />
89+
<Button Height="23" Grid.Column="3" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnChap" VerticalAlignment="Top" Click="BtnChap_Click" Content="检查章节" />
9090
<Button Height="23" Grid.Column="4" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnMoveup" VerticalAlignment="Top" Click="BtnMoveup_Click" Content="上移" />
9191
<Button Height="23" Grid.Column="5" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnMoveDown" VerticalAlignment="Top" Click="BtnMoveDown_Click" Content="下移" />
9292
<Button Height="23" Grid.Column="6" Grid.Row="0" Margin="0,0,6,0" x:Name="BtnDelete" VerticalAlignment="Top" Click="BtnDelete_Click" Content="删除" />

OKEGui/OKEGui/Gui/MainWindow.xaml.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public MainWindow()
3939
BtnMoveDown.IsEnabled = false;
4040
BtnMoveup.IsEnabled = false;
4141
BtnStop.IsEnabled = false;
42-
BtnEdit.IsEnabled = false;
42+
BtnChap.IsEnabled = false;
4343

4444
// 初始的worker数量等于Numa数量。
4545
int numaCount = NumaNode.NumaCount;
@@ -54,6 +54,7 @@ public MainWindow()
5454
private void Checkbox_Changed(object sender, RoutedEventArgs e)
5555
{
5656
BtnRun.IsEnabled = tm.HasNextTask();
57+
BtnChap.IsEnabled = BtnRun.IsEnabled;
5758
}
5859

5960
private void BtnNew_Click(object sender, RoutedEventArgs e)
@@ -64,6 +65,7 @@ private void BtnNew_Click(object sender, RoutedEventArgs e)
6465
var wizard = new WizardWindow(wm);
6566
wizard.ShowDialog();
6667
BtnRun.IsEnabled = tm.HasNextTask();
68+
BtnChap.IsEnabled = BtnRun.IsEnabled;
6769
tm.IsCanStart = true;
6870
}
6971
catch (Exception ex)
@@ -104,9 +106,11 @@ private void BtnRun_Click(object sender, RoutedEventArgs e)
104106
}
105107
}
106108

107-
private void BtnEdit_Click(object sender, RoutedEventArgs e)
109+
private void BtnChap_Click(object sender, RoutedEventArgs e)
108110
{
109-
// TODO
111+
BtnChap.IsEnabled = false;
112+
tm.UpdateChapterStatus();
113+
BtnChap.IsEnabled = true;
110114
}
111115

112116
private void BtnMoveup_Click(object sender, RoutedEventArgs e)

OKEGui/OKEGui/Gui/WizardWindow.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ private void WizardFinish(object sender, RoutedEventArgs e)
239239
td.Taskfile.Config = config.Clone() as EpisodeConfig;
240240
}
241241
td.UpdateOutputFileName();
242+
243+
// 寻找章节
244+
td.ChapterStatus = ChapterService.GetChapterStatus(td);
242245
workerManager.AddTask(td);
243246
}
244247
}

OKEGui/OKEGui/JobProcessor/Demuxer/EACDemuxer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public EacOutputTrackType(TrackCodec codec, string rawOutput, string extension,
7171
new EacOutputTrackType(TrackCodec.H264_AVC, "h264/AVC", "h264", false, TrackType.Video),
7272
new EacOutputTrackType(TrackCodec.H265_HEVC, "h265/HEVC", "265", false, TrackType.Video),
7373
new EacOutputTrackType(TrackCodec.PGS, "Subtitle (PGS)", "sup", true, TrackType.Subtitle),
74-
new EacOutputTrackType(TrackCodec.Chapter, "Chapters", "txt", true, TrackType.Chapter),
74+
new EacOutputTrackType(TrackCodec.Chapter, "Chapters", "txt", false, TrackType.Chapter),
7575
};
7676

7777
public EACDemuxer(string eacPath, string fileName, TaskProfile jobProfile)

OKEGui/OKEGui/OKEGui.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<Compile Include="Model\Info\Info.cs" />
105105
<Compile Include="Model\Info\VideoInfo.cs" />
106106
<Compile Include="Task\AddTaskService.cs" />
107+
<Compile Include="Task\ChapterService.cs" />
107108
<Compile Include="Task\EpisodeProfile.cs" />
108109
<Compile Include="Task\TaskProfile.cs" />
109110
<Compile Include="Model\Track\AudioTrack.cs" />

OKEGui/OKEGui/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
4848
// 方法是按如下所示使用“*”: :
4949
// [assembly: AssemblyVersion("1.0.*")]
50-
[assembly: AssemblyVersion("5.1.*")]
50+
[assembly: AssemblyVersion("5.2.*")]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using OKEGui.JobProcessor;
2+
using OKEGui.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace OKEGui
11+
{
12+
class ChapterService
13+
{
14+
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
15+
16+
public static string GetChapterStatus(TaskDetail task)
17+
{
18+
bool hasChapter = HasChapterFile(task);
19+
return hasChapter ? "Yes" : "No";
20+
}
21+
public static bool HasChapterFile(TaskDetail task)
22+
{
23+
FileInfo txtChapter = new FileInfo(Path.ChangeExtension(task.InputFile, ".txt"));
24+
return txtChapter.Exists;
25+
}
26+
27+
public static TaskDetail AddChapter(TaskDetail task)
28+
{
29+
FileInfo txtChapter = new FileInfo(Path.ChangeExtension(task.InputFile, ".txt"));
30+
if (txtChapter.Exists)
31+
{
32+
OKEFile chapterFile = new OKEFile(txtChapter);
33+
ChapterChecker checker = new ChapterChecker(chapterFile, task.lengthInMiliSec);
34+
checker.RemoveUnnecessaryEnd();
35+
36+
if (checker.IsEmpty())
37+
{
38+
Logger.Info(txtChapter.Name + "为空,跳过封装。");
39+
}
40+
else
41+
{
42+
task.MediaOutFile.AddTrack(new ChapterTrack(chapterFile));
43+
}
44+
}
45+
return task;
46+
}
47+
}
48+
}

OKEGui/OKEGui/Task/TaskDetail.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class TaskDetail : TaskStatus
2121

2222
public bool IsRunning;
2323
public string Tid;
24+
public long lengthInMiliSec;
2425

2526
// 自动生成输出文件名
2627
public void UpdateOutputFileName()

OKEGui/OKEGui/Task/TaskManager.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,20 @@ public int GetActiveTaskCount()
146146
return activeTaskCount;
147147
}
148148
}
149+
150+
public void UpdateChapterStatus()
151+
{
152+
lock (o)
153+
{
154+
// 找出下一个可用任务
155+
foreach (TaskDetail task in taskStatus)
156+
{
157+
if (task.IsEnabled)
158+
{
159+
task.ChapterStatus = ChapterService.GetChapterStatus(task);
160+
}
161+
}
162+
}
163+
}
149164
}
150165
}

OKEGui/OKEGui/Task/TaskStatus.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ public string InputFile
5151
}
5252
}
5353

54+
/// <summary>
55+
/// 章节信息(Yes/No)
56+
/// </summary>
57+
private string chapterStatus;
58+
public string ChapterStatus
59+
{
60+
get { return chapterStatus; }
61+
set
62+
{
63+
chapterStatus = value;
64+
OnPropertyChanged(new PropertyChangedEventArgs("ChapterStatus"));
65+
}
66+
}
67+
5468
/// <summary>
5569
/// 输出文件
5670
/// </summary>

0 commit comments

Comments
 (0)