Skip to content

Commit 41600b4

Browse files
authored
Merge pull request #9 from wfwf1997/master
Chapter module improvements
2 parents da2657e + 3d1f31c commit 41600b4

File tree

16 files changed

+571
-292
lines changed

16 files changed

+571
-292
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "TChapter"]
2+
path = TChapter
3+
url = https://github.com/vcb-s/TChapter.git

OKEGui/OKEGui.sln

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,42 @@ VisualStudioVersion = 16.0.29411.108
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OKEGui", "OKEGui\OKEGui.csproj", "{BD980C51-9FCF-483E-BB88-B903952FDDDD}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TChapter", "..\..\TChapter\TChapter\TChapter.csproj", "{D3EFF606-0562-45E4-8E0B-1DF967220A9B}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TChapter", "..\TChapter\TChapter\TChapter.csproj", "{D3EFF606-0562-45E4-8E0B-1DF967220A9B}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
1213
Debug|x64 = Debug|x64
1314
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
1416
Release|x64 = Release|x64
1517
Release|x86 = Release|x86
1618
EndGlobalSection
1719
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
1822
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x64.ActiveCfg = Debug|Any CPU
1923
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x64.Build.0 = Debug|Any CPU
2024
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x86.ActiveCfg = Debug|Any CPU
2125
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x86.Build.0 = Debug|Any CPU
26+
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|Any CPU.Build.0 = Release|Any CPU
2228
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x64.ActiveCfg = Release|Any CPU
2329
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x64.Build.0 = Release|Any CPU
2430
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x86.ActiveCfg = Release|Any CPU
2531
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x86.Build.0 = Release|Any CPU
26-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.ActiveCfg = Debug|x64
27-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.Build.0 = Debug|x64
28-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.ActiveCfg = Debug|x64
29-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.ActiveCfg = Release|x64
30-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.Build.0 = Release|x64
31-
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.ActiveCfg = Release|x64
32+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.ActiveCfg = Debug|Any CPU
35+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.Build.0 = Debug|Any CPU
36+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.ActiveCfg = Debug|Any CPU
37+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.Build.0 = Debug|Any CPU
38+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.ActiveCfg = Release|Any CPU
41+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.Build.0 = Release|Any CPU
42+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.ActiveCfg = Release|Any CPU
43+
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.Build.0 = Release|Any CPU
3244
EndGlobalSection
3345
GlobalSection(SolutionProperties) = preSolution
3446
HideSolutionNode = FALSE

OKEGui/OKEGui/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class App : Application
1212
{
1313
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
1414

15-
static App()
15+
App()
1616
{
1717
if (EnvironmentChecker.CheckEnviornment())
1818
{

OKEGui/OKEGui/Job/VideoJob/VideoJob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ public class VideoJob : Job
77
public string EncoderPath;
88
public string EncodeParam;
99
public List<string> VspipeArgs = new List<string>();
10+
public bool Vfr;
1011
public double Fps;
1112
public uint FpsNum;
1213
public uint FpsDen;
1314
public int NumaNode;
1415
public ulong NumberOfFrames;
15-
public string TimeCodeFile;
1616

1717
public VideoJob(string codec) : base(codec)
1818
{

OKEGui/OKEGui/JobProcessor/Audio/FFmpegVolumeChecker.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ class FFmpegVolumeChecker : CommandlineJobProcessor
1616
public FFmpegVolumeChecker(string inputFile)
1717
{
1818
executable = Constants.ffmpegPath;
19-
commandLine = "-i \"" + inputFile + "\" -af volumedetect -f null /dev/null";
19+
commandLine = "-i \"" + inputFile + "\" -af astats=measure_perchannel=none -f null /dev/null";
2020
}
2121

2222
public override void ProcessLine(string line, StreamType stream)
2323
{
2424
base.ProcessLine(line, stream);
25-
if (line.Contains("mean_volume"))
25+
26+
if (line.Contains("RMS level dB"))
2627
{
27-
line = line.Replace(": 0.", ": -0.");
28-
Regex rf = new Regex("mean_volume: (-[0-9]+.[0-9]+) dB");
28+
Regex rf = new Regex(@"RMS level dB: (-?\d+.\d+)");
2929
string[] result = rf.Split(line);
3030
MeanVolume = double.Parse(result[1]);
31+
return;
3132
}
32-
if (line.Contains("max_volume"))
33+
34+
if (line.Contains("Peak level dB"))
3335
{
34-
line = line.Replace(": 0.", ": -0.");
35-
Regex rf = new Regex("max_volume: (-[0-9]+.[0-9]+) dB");
36+
Regex rf = new Regex(@"Peak level dB: (-?\d+.\d+)");
3637
string[] result = rf.Split(line);
3738
MaxVolume = double.Parse(result[1]);
3839
SetFinish();

OKEGui/OKEGui/JobProcessor/Chapter/ChapterChecker.cs

Lines changed: 0 additions & 76 deletions
This file was deleted.

OKEGui/OKEGui/JobProcessor/Demuxer/TrackInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public bool IsDuplicate(in TrackInfo other)
8787
switch (Type)
8888
{
8989
case TrackType.Audio:
90-
return Math.Abs(MeanVolume - other.MeanVolume) < 0.15 && Math.Abs(MaxVolume - other.MaxVolume) < 0.15;
90+
return Math.Abs(MeanVolume - other.MeanVolume) < 1e-4 && Math.Abs(MaxVolume - other.MaxVolume) < 1e-4;
9191
default:
9292
return FileSize == other.FileSize;
9393
}

OKEGui/OKEGui/JobProcessor/Video/CommandlineVideoEncoder.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,19 @@ protected void getInputProperties(VideoJob job)
4343
fps_d = vsHelper.FpsDen;
4444
NumberOfFrames = (ulong)vsHelper.TotalFreams;
4545
job.NumberOfFrames = NumberOfFrames;
46-
if (fps_n != job.FpsNum || fps_d != job.FpsDen)
46+
if (fps_n == job.FpsNum && fps_d == job.FpsDen) return;
47+
if (job.Vfr)
4748
{
48-
if (string.IsNullOrEmpty(job.TimeCodeFile))
49-
{
50-
OKETaskException ex = new OKETaskException(Constants.fpsMismatchSmr);
51-
ex.progress = 0.0;
52-
ex.Data["SRC_FPS"] = ((double)job.FpsNum / job.FpsDen).ToString("F3");
53-
ex.Data["DST_FPS"] = ((double)fps_n / fps_d).ToString("F3");
54-
throw ex;
55-
}
56-
else
57-
{
58-
job.FpsNum = (uint)fps_n;
59-
job.FpsDen = (uint)fps_d;
60-
job.Fps = (fps_n + 0.0) / fps_d;
61-
}
49+
job.FpsNum = (uint)fps_n;
50+
job.FpsDen = (uint)fps_d;
51+
job.Fps = (fps_n + 0.0) / fps_d;
52+
return;
6253
}
54+
OKETaskException ex = new OKETaskException(Constants.fpsMismatchSmr);
55+
ex.progress = 0.0;
56+
ex.Data["SRC_FPS"] = ((double)job.FpsNum / job.FpsDen).ToString("F3");
57+
ex.Data["DST_FPS"] = ((double)fps_n / fps_d).ToString("F3");
58+
throw ex;
6359
}
6460

6561
#endregion helper methods

OKEGui/OKEGui/OKEGui.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
<SubType>Designer</SubType>
101101
</ApplicationDefinition>
102102
<Compile Include="JobProcessor\Audio\FFmpegVolumeChecker.cs" />
103-
<Compile Include="JobProcessor\Chapter\ChapterChecker.cs" />
104103
<Compile Include="JobProcessor\Demuxer\TrackInfo.cs" />
105104
<Compile Include="JobProcessor\ExceptionParser.cs" />
106105
<Compile Include="JobProcessor\RpChecker\RpChecker.cs" />
@@ -147,6 +146,8 @@
147146
<SubType>Code</SubType>
148147
</Compile>
149148
<Compile Include="Task\VideoService.cs" />
149+
<Compile Include="Utils\TChapterExtension.cs" />
150+
<Compile Include="Utils\Timecode.cs" />
150151
<Compile Include="Worker\ExecuteTaskService.cs" />
151152
<Compile Include="Task\TaskStatus.cs" />
152153
<Compile Include="Utils\Cleaner.cs" />
@@ -215,7 +216,7 @@
215216
<Resource Include="Gui\App.ico" />
216217
</ItemGroup>
217218
<ItemGroup>
218-
<ProjectReference Include="..\..\..\TChapter\TChapter\TChapter.csproj">
219+
<ProjectReference Include="..\..\TChapter\TChapter\TChapter.csproj">
219220
<Project>{d3eff606-0562-45e4-8e0b-1df967220a9b}</Project>
220221
<Name>TChapter</Name>
221222
</ProjectReference>

0 commit comments

Comments
 (0)