Skip to content

Commit fe7e494

Browse files
committed
support qaac tvbr
AudioTracks add Quality, and it cannot appear at the same time as Bitrate.
1 parent 6f2a3d2 commit fe7e494

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

OKEGui/OKEGui/JobProcessor/Audio/QAACEncoder.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.RegularExpressions;
55
using System.Threading;
66
using OKEGui.Utils;
7+
using System.Text;
78

89
namespace OKEGui.JobProcessor
910
{
@@ -19,7 +20,19 @@ protected AudioJob AJob
1920
public QAACEncoder(AudioJob ajob) : base(ajob)
2021
{
2122
executable = Constants.QAACPath;
22-
commandLine = $"-i -v {AJob.Info.Bitrate} -q 2 --no-delay -o \"{AJob.Output}\" \"{AJob.Input}\"";
23+
24+
var sb = new StringBuilder("-i ");
25+
if (AJob.Info.Quality != null)
26+
{
27+
sb.Append($"-V {AJob.Info.Quality} ");
28+
}
29+
else
30+
{
31+
sb.Append($"-v {AJob.Info.Bitrate} ");
32+
}
33+
sb.Append($"-q 2 --no-delay -o \"{AJob.Output}\" \"{AJob.Input}\"");
34+
35+
commandLine = sb.ToString();
2336
}
2437

2538
public QAACEncoder(string commandLine) : base(null)

OKEGui/OKEGui/Model/Info/AudioInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class AudioInfo : Info
66
{
77
public string OutputCodec;
88
public int Bitrate = Constants.QAACBitrate;
9+
public int? Quality;
910
public bool Lossy = false;
1011
public int Length;
1112

OKEGui/OKEGui/Task/AddTaskService.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,21 @@ public static TaskProfile ProcessJsonProfile(TaskProfile json, DirectoryInfo pro
186186
MessageBox.Show("音轨未设置 OutputCodec,请检查大小写", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
187187
return null;
188188
}
189+
190+
if (ai.Quality != null)
191+
{
192+
if (ai.Bitrate != Constants.QAACBitrate)
193+
{
194+
MessageBox.Show("音轨不能同时指定 Bitrate 和 Quality,请只保留其中一个", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
195+
return null;
196+
}
197+
198+
if (ai.Quality < Constants.QAACQualityMin || ai.Quality > Constants.QAACQualityMax)
199+
{
200+
MessageBox.Show($"音轨 Quality 的值必须介于 {Constants.QAACQualityMin}-${Constants.QAACQualityMax} 之间(闭区间),请检查", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
201+
return null;
202+
}
203+
}
189204
}
190205
// 主音轨
191206
json.AudioFormat = json.AudioTracks[0].OutputCodec;

OKEGui/OKEGui/Utils/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public static class Constants
88
//QAAC encoder.
99
public const string QAACPath = ".\\tools\\qaac\\qaac64.exe";
1010
public const int QAACBitrate = 192;
11+
public const int QAACQualityMin = 0;
12+
public const int QAACQualityMax = 127;
1113

1214
//ffmpeg
1315
public const string ffmpegPath = ".\\tools\\ffmpeg\\ffmpeg.exe";

0 commit comments

Comments
 (0)