Skip to content

Commit

Permalink
1.Used ffmpeg to detect empty audios and duplicated audios.
Browse files Browse the repository at this point in the history
2.Cleanup and refactoring.
  • Loading branch information
LittlePox committed Aug 11, 2019
1 parent fef32a4 commit 2e46826
Show file tree
Hide file tree
Showing 14 changed files with 273 additions and 133 deletions.
39 changes: 39 additions & 0 deletions OKEGui/OKEGui/JobProcessor/Audio/FFmpegVolumeChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using OKEGui.Utils;

namespace OKEGui
{
class FFmpegVolumeChecker : CommandlineJobProcessor
{
public double MeanVolume { get; private set; }
public double MaxVolume { get; private set; }

public FFmpegVolumeChecker(string inputFile)
{
executable = Constants.ffmpegPath;
commandLine = "-i \"" + inputFile + "\" -af volumedetect -f null /dev/null";
}

public override void ProcessLine(string line, StreamType stream)
{
if (line.Contains("mean_volume"))
{
Regex rf = new Regex("mean_volume: (-[0-9]+.[0-9]+) dB");
string[] result = rf.Split(line);
MeanVolume = double.Parse(result[1]);
}
if (line.Contains("max_volume"))
{
Regex rf = new Regex("max_volume: (-[0-9]+.[0-9]+) dB");
string[] result = rf.Split(line);
MaxVolume = double.Parse(result[1]);
SetFinish();
}
}
}
}
5 changes: 0 additions & 5 deletions OKEGui/OKEGui/JobProcessor/Audio/FLACDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,5 @@ public override void ProcessLine(string line, StreamType stream)
SetFinish();
}
}

public override void setup(Job job, StatusUpdate su)
{
}

}
}
5 changes: 0 additions & 5 deletions OKEGui/OKEGui/JobProcessor/Audio/QAACEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,5 @@ public override void ProcessLine(string line, StreamType stream)
throw new OKETaskException(Constants.qaacErrorSmr);
}
}

public override void setup(Job job, StatusUpdate su)
{
}

}
}
6 changes: 2 additions & 4 deletions OKEGui/OKEGui/JobProcessor/CommandlineJobProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ protected void proc_Exited(object sender, EventArgs e)

#region IVideoEncoder overridden Members

public abstract void setup(Job job, StatusUpdate su);

// TODO: 默认优先级
public void start()
{
Expand Down Expand Up @@ -285,7 +283,7 @@ protected void readStdOut()
try {
sr = proc.StandardOutput;
} catch (Exception e) {
// log.LogValue("Exception getting IO reader for stdout", e, ImageType.Error);
Debugger.Log(0, "", "Exception getting IO reader for stdout" + e.ToString());
stdoutDone.Set();
return;
}
Expand All @@ -298,7 +296,7 @@ protected void readStdErr()
try {
sr = proc.StandardError;
} catch (Exception e) {
// log.LogValue("Exception getting IO reader for stderr", e, ImageType.Error);
Debugger.Log(0, "", "Exception getting IO reader for stderr" + e.ToString());
stderrDone.Set();
return;
}
Expand Down
6 changes: 1 addition & 5 deletions OKEGui/OKEGui/JobProcessor/CommandlineVideoEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,12 @@ protected void compileFinalStats()
}
catch (Exception e)
{
// log.LogValue("Exception in compileFinalStats", e, ImageType.Warning);
Debugger.Log(0, "", "Exception compiling final stats" + e.ToString());
}
}

#endregion helper methods

public override void setup(Job job, StatusUpdate su)
{
}

protected bool setFrameNumber(string frameString, bool isUpdateSpeed = false)
{
int currentFrame;
Expand Down
Loading

0 comments on commit 2e46826

Please sign in to comment.