Skip to content

Commit 2e46826

Browse files
committed
1.Used ffmpeg to detect empty audios and duplicated audios.
2.Cleanup and refactoring.
1 parent fef32a4 commit 2e46826

File tree

14 files changed

+273
-133
lines changed

14 files changed

+273
-133
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.RegularExpressions;
6+
using System.Threading.Tasks;
7+
using OKEGui.Utils;
8+
9+
namespace OKEGui
10+
{
11+
class FFmpegVolumeChecker : CommandlineJobProcessor
12+
{
13+
public double MeanVolume { get; private set; }
14+
public double MaxVolume { get; private set; }
15+
16+
public FFmpegVolumeChecker(string inputFile)
17+
{
18+
executable = Constants.ffmpegPath;
19+
commandLine = "-i \"" + inputFile + "\" -af volumedetect -f null /dev/null";
20+
}
21+
22+
public override void ProcessLine(string line, StreamType stream)
23+
{
24+
if (line.Contains("mean_volume"))
25+
{
26+
Regex rf = new Regex("mean_volume: (-[0-9]+.[0-9]+) dB");
27+
string[] result = rf.Split(line);
28+
MeanVolume = double.Parse(result[1]);
29+
}
30+
if (line.Contains("max_volume"))
31+
{
32+
Regex rf = new Regex("max_volume: (-[0-9]+.[0-9]+) dB");
33+
string[] result = rf.Split(line);
34+
MaxVolume = double.Parse(result[1]);
35+
SetFinish();
36+
}
37+
}
38+
}
39+
}

OKEGui/OKEGui/JobProcessor/Audio/FLACDecoder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,5 @@ public override void ProcessLine(string line, StreamType stream)
4343
SetFinish();
4444
}
4545
}
46-
47-
public override void setup(Job job, StatusUpdate su)
48-
{
49-
}
50-
5146
}
5247
}

OKEGui/OKEGui/JobProcessor/Audio/QAACEncoder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,5 @@ public override void ProcessLine(string line, StreamType stream)
4141
throw new OKETaskException(Constants.qaacErrorSmr);
4242
}
4343
}
44-
45-
public override void setup(Job job, StatusUpdate su)
46-
{
47-
}
48-
4944
}
5045
}

OKEGui/OKEGui/JobProcessor/CommandlineJobProcessor.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ protected void proc_Exited(object sender, EventArgs e)
113113

114114
#region IVideoEncoder overridden Members
115115

116-
public abstract void setup(Job job, StatusUpdate su);
117-
118116
// TODO: 默认优先级
119117
public void start()
120118
{
@@ -285,7 +283,7 @@ protected void readStdOut()
285283
try {
286284
sr = proc.StandardOutput;
287285
} catch (Exception e) {
288-
// log.LogValue("Exception getting IO reader for stdout", e, ImageType.Error);
286+
Debugger.Log(0, "", "Exception getting IO reader for stdout" + e.ToString());
289287
stdoutDone.Set();
290288
return;
291289
}
@@ -298,7 +296,7 @@ protected void readStdErr()
298296
try {
299297
sr = proc.StandardError;
300298
} catch (Exception e) {
301-
// log.LogValue("Exception getting IO reader for stderr", e, ImageType.Error);
299+
Debugger.Log(0, "", "Exception getting IO reader for stderr" + e.ToString());
302300
stderrDone.Set();
303301
return;
304302
}

OKEGui/OKEGui/JobProcessor/CommandlineVideoEncoder.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,12 @@ protected void compileFinalStats()
7676
}
7777
catch (Exception e)
7878
{
79-
// log.LogValue("Exception in compileFinalStats", e, ImageType.Warning);
79+
Debugger.Log(0, "", "Exception compiling final stats" + e.ToString());
8080
}
8181
}
8282

8383
#endregion helper methods
8484

85-
public override void setup(Job job, StatusUpdate su)
86-
{
87-
}
88-
8985
protected bool setFrameNumber(string frameString, bool isUpdateSpeed = false)
9086
{
9187
int currentFrame;

0 commit comments

Comments
 (0)