Skip to content

Commit

Permalink
Merge pull request #9 from wfwf1997/master
Browse files Browse the repository at this point in the history
Chapter module improvements
  • Loading branch information
LittlePox authored Feb 18, 2020
2 parents da2657e + 3d1f31c commit 41600b4
Show file tree
Hide file tree
Showing 16 changed files with 571 additions and 292 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "TChapter"]
path = TChapter
url = https://github.com/vcb-s/TChapter.git
26 changes: 19 additions & 7 deletions OKEGui/OKEGui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,42 @@ VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OKEGui", "OKEGui\OKEGui.csproj", "{BD980C51-9FCF-483E-BB88-B903952FDDDD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TChapter", "..\..\TChapter\TChapter\TChapter.csproj", "{D3EFF606-0562-45E4-8E0B-1DF967220A9B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TChapter", "..\TChapter\TChapter\TChapter.csproj", "{D3EFF606-0562-45E4-8E0B-1DF967220A9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x64.ActiveCfg = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x64.Build.0 = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x86.ActiveCfg = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Debug|x86.Build.0 = Debug|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|Any CPU.Build.0 = Release|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x64.ActiveCfg = Release|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x64.Build.0 = Release|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x86.ActiveCfg = Release|Any CPU
{BD980C51-9FCF-483E-BB88-B903952FDDDD}.Release|x86.Build.0 = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.ActiveCfg = Debug|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.Build.0 = Debug|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.ActiveCfg = Debug|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.ActiveCfg = Release|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.Build.0 = Release|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.ActiveCfg = Release|x64
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.ActiveCfg = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x64.Build.0 = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.ActiveCfg = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Debug|x86.Build.0 = Debug|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|Any CPU.Build.0 = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.ActiveCfg = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x64.Build.0 = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.ActiveCfg = Release|Any CPU
{D3EFF606-0562-45E4-8E0B-1DF967220A9B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion OKEGui/OKEGui/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class App : Application
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

static App()
App()
{
if (EnvironmentChecker.CheckEnviornment())
{
Expand Down
2 changes: 1 addition & 1 deletion OKEGui/OKEGui/Job/VideoJob/VideoJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class VideoJob : Job
public string EncoderPath;
public string EncodeParam;
public List<string> VspipeArgs = new List<string>();
public bool Vfr;
public double Fps;
public uint FpsNum;
public uint FpsDen;
public int NumaNode;
public ulong NumberOfFrames;
public string TimeCodeFile;

public VideoJob(string codec) : base(codec)
{
Expand Down
15 changes: 8 additions & 7 deletions OKEGui/OKEGui/JobProcessor/Audio/FFmpegVolumeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ class FFmpegVolumeChecker : CommandlineJobProcessor
public FFmpegVolumeChecker(string inputFile)
{
executable = Constants.ffmpegPath;
commandLine = "-i \"" + inputFile + "\" -af volumedetect -f null /dev/null";
commandLine = "-i \"" + inputFile + "\" -af astats=measure_perchannel=none -f null /dev/null";
}

public override void ProcessLine(string line, StreamType stream)
{
base.ProcessLine(line, stream);
if (line.Contains("mean_volume"))

if (line.Contains("RMS level dB"))
{
line = line.Replace(": 0.", ": -0.");
Regex rf = new Regex("mean_volume: (-[0-9]+.[0-9]+) dB");
Regex rf = new Regex(@"RMS level dB: (-?\d+.\d+)");
string[] result = rf.Split(line);
MeanVolume = double.Parse(result[1]);
return;
}
if (line.Contains("max_volume"))

if (line.Contains("Peak level dB"))
{
line = line.Replace(": 0.", ": -0.");
Regex rf = new Regex("max_volume: (-[0-9]+.[0-9]+) dB");
Regex rf = new Regex(@"Peak level dB: (-?\d+.\d+)");
string[] result = rf.Split(line);
MaxVolume = double.Parse(result[1]);
SetFinish();
Expand Down
76 changes: 0 additions & 76 deletions OKEGui/OKEGui/JobProcessor/Chapter/ChapterChecker.cs

This file was deleted.

2 changes: 1 addition & 1 deletion OKEGui/OKEGui/JobProcessor/Demuxer/TrackInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public bool IsDuplicate(in TrackInfo other)
switch (Type)
{
case TrackType.Audio:
return Math.Abs(MeanVolume - other.MeanVolume) < 0.15 && Math.Abs(MaxVolume - other.MaxVolume) < 0.15;
return Math.Abs(MeanVolume - other.MeanVolume) < 1e-4 && Math.Abs(MaxVolume - other.MaxVolume) < 1e-4;
default:
return FileSize == other.FileSize;
}
Expand Down
26 changes: 11 additions & 15 deletions OKEGui/OKEGui/JobProcessor/Video/CommandlineVideoEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,19 @@ protected void getInputProperties(VideoJob job)
fps_d = vsHelper.FpsDen;
NumberOfFrames = (ulong)vsHelper.TotalFreams;
job.NumberOfFrames = NumberOfFrames;
if (fps_n != job.FpsNum || fps_d != job.FpsDen)
if (fps_n == job.FpsNum && fps_d == job.FpsDen) return;
if (job.Vfr)
{
if (string.IsNullOrEmpty(job.TimeCodeFile))
{
OKETaskException ex = new OKETaskException(Constants.fpsMismatchSmr);
ex.progress = 0.0;
ex.Data["SRC_FPS"] = ((double)job.FpsNum / job.FpsDen).ToString("F3");
ex.Data["DST_FPS"] = ((double)fps_n / fps_d).ToString("F3");
throw ex;
}
else
{
job.FpsNum = (uint)fps_n;
job.FpsDen = (uint)fps_d;
job.Fps = (fps_n + 0.0) / fps_d;
}
job.FpsNum = (uint)fps_n;
job.FpsDen = (uint)fps_d;
job.Fps = (fps_n + 0.0) / fps_d;
return;
}
OKETaskException ex = new OKETaskException(Constants.fpsMismatchSmr);
ex.progress = 0.0;
ex.Data["SRC_FPS"] = ((double)job.FpsNum / job.FpsDen).ToString("F3");
ex.Data["DST_FPS"] = ((double)fps_n / fps_d).ToString("F3");
throw ex;
}

#endregion helper methods
Expand Down
5 changes: 3 additions & 2 deletions OKEGui/OKEGui/OKEGui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="JobProcessor\Audio\FFmpegVolumeChecker.cs" />
<Compile Include="JobProcessor\Chapter\ChapterChecker.cs" />
<Compile Include="JobProcessor\Demuxer\TrackInfo.cs" />
<Compile Include="JobProcessor\ExceptionParser.cs" />
<Compile Include="JobProcessor\RpChecker\RpChecker.cs" />
Expand Down Expand Up @@ -147,6 +146,8 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Task\VideoService.cs" />
<Compile Include="Utils\TChapterExtension.cs" />
<Compile Include="Utils\Timecode.cs" />
<Compile Include="Worker\ExecuteTaskService.cs" />
<Compile Include="Task\TaskStatus.cs" />
<Compile Include="Utils\Cleaner.cs" />
Expand Down Expand Up @@ -215,7 +216,7 @@
<Resource Include="Gui\App.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\TChapter\TChapter\TChapter.csproj">
<ProjectReference Include="..\..\TChapter\TChapter\TChapter.csproj">
<Project>{d3eff606-0562-45e4-8e0b-1df967220a9b}</Project>
<Name>TChapter</Name>
</ProjectReference>
Expand Down
Loading

0 comments on commit 41600b4

Please sign in to comment.