Skip to content

Commit 3cee727

Browse files
committed
Add progress for lsmas indexing
Signed-off-by: akarin <[email protected]>
1 parent 62cf858 commit 3cee727

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

OKEGui/OKEGui/Job/VideoJob/VideoInfoJob.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ namespace OKEGui
55
public class VideoInfoJob : Job
66
{
77
public List<string> Args = new List<string>();
8-
public VideoInfoJob(string input, List<string> args) : base()
8+
public VideoJob vJob;
9+
public VideoInfoJob(VideoJob job) : base()
910
{
10-
Input = input;
11-
Args.AddRange(args);
11+
vJob = job;
12+
Input = job.Input;
13+
Args.AddRange(job.VspipeArgs);
1214
}
1315

1416
public override JobType GetJobType()

OKEGui/OKEGui/JobProcessor/Video/CommandlineVideoEncoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected void getInputProperties(VideoJob job)
3838
{
3939
//VapourSynthHelper vsHelper = new VapourSynthHelper();
4040
//vsHelper.LoadScriptFile(job.Input);
41-
VSPipeInfo vsHelper = new VSPipeInfo(job.Input, job.VspipeArgs);
41+
VSPipeInfo vsHelper = new VSPipeInfo(job);
4242
fps_n = vsHelper.FpsNum;
4343
fps_d = vsHelper.FpsDen;
4444
NumberOfFrames = (ulong)vsHelper.TotalFreams;

OKEGui/OKEGui/JobProcessor/Video/VSPipeProcessor.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ public class VSPipeProcessor : CommandlineJobProcessor
1717
private bool videoInfoOk;
1818
private string lastStderrLine;
1919
private ManualResetEvent retrieved = new ManualResetEvent(false);
20+
private VideoJob job;
2021

2122
public VSPipeProcessor(VideoInfoJob j) : base()
2223
{
2324
// 获取VSPipe路径
2425
executable = Initializer.Config.vspipePath;
2526
videoInfo = new VSVideoInfo();
2627
videoInfoOk = false;
28+
job = j.vJob;
2729

2830
StringBuilder sb = new StringBuilder();
2931

@@ -50,6 +52,7 @@ public override void ProcessLine(string line, StreamType stream)
5052
Regex rFormatName = new Regex("Format Name: ([a-zA-Z0-9]+)");
5153
Regex rColorFamily = new Regex("Color Family: ([a-zA-Z]+)");
5254
Regex rBits = new Regex("Bits: ([0-9]+)");
55+
Regex rlwiProgress = new Regex("Creating lwi index file ([0-9]+)%");
5356

5457
if (line.Contains("Python exception: "))
5558
{
@@ -143,7 +146,14 @@ public override void ProcessLine(string line, StreamType stream)
143146
else if (line.Contains("SubSampling"))
144147
{
145148
//目前还没有要处理subsampling的
146-
}
149+
}
150+
else if (rlwiProgress.IsMatch(line))
151+
{
152+
var s = rlwiProgress.Split(line);
153+
int p;
154+
int.TryParse(s[1], out p);
155+
job.Progress = p;
156+
}
147157
}
148158

149159
public override void waitForFinish()

OKEGui/OKEGui/Utils/VapourSynthHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ public class VSPipeInfo
215215
private int height;
216216
private VSVideoInfo videoInfo;
217217

218-
public VSPipeInfo(string vsScriptPath, List<string> args)
218+
public VSPipeInfo(VideoJob vjob)
219219
{
220-
VideoInfoJob j = new VideoInfoJob(vsScriptPath, args);
220+
VideoInfoJob j = new VideoInfoJob(vjob);
221221

222222
VSPipeProcessor processor = new VSPipeProcessor(j);
223223
processor.start();

0 commit comments

Comments
 (0)