Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion OKEGui/OKEGui/JobProcessor/Audio/QAACEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using OKEGui.Utils;
using System.Text;

namespace OKEGui.JobProcessor
{
Expand All @@ -19,7 +20,19 @@ protected AudioJob AJob
public QAACEncoder(AudioJob ajob) : base(ajob)
{
executable = Constants.QAACPath;
commandLine = $"-i -v {AJob.Info.Bitrate} -q 2 --no-delay -o \"{AJob.Output}\" \"{AJob.Input}\"";

var sb = new StringBuilder("-i ");
if (AJob.Info.Quality != null)
{
sb.Append($"-V {AJob.Info.Quality} ");
}
else
{
sb.Append($"-v {AJob.Info.Bitrate} ");
}
sb.Append($"-q 2 --no-delay -o \"{AJob.Output}\" \"{AJob.Input}\"");

commandLine = sb.ToString();
}

public QAACEncoder(string commandLine) : base(null)
Expand Down
1 change: 1 addition & 0 deletions OKEGui/OKEGui/Model/Info/AudioInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class AudioInfo : Info
{
public string OutputCodec;
public int Bitrate = Constants.QAACBitrate;
public int? Quality;
public bool Lossy = false;
public int Length;

Expand Down
15 changes: 15 additions & 0 deletions OKEGui/OKEGui/Task/AddTaskService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ public static TaskProfile ProcessJsonProfile(TaskProfile json, DirectoryInfo pro
MessageBox.Show("音轨未设置 OutputCodec,请检查大小写", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
return null;
}

if (ai.Quality != null)
{
if (ai.Bitrate != Constants.QAACBitrate)
{
MessageBox.Show("音轨不能同时指定 Bitrate 和 Quality,请只保留其中一个", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
return null;
}

if (ai.Quality < Constants.QAACQualityMin || ai.Quality > Constants.QAACQualityMax)
{
MessageBox.Show($"音轨 Quality 的值必须介于 {Constants.QAACQualityMin}-${Constants.QAACQualityMax} 之间(闭区间),请检查", "音轨编码错误", MessageBoxButton.OK, MessageBoxImage.Error);
return null;
}
}
}
// 主音轨
json.AudioFormat = json.AudioTracks[0].OutputCodec;
Expand Down
2 changes: 2 additions & 0 deletions OKEGui/OKEGui/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public static class Constants
//QAAC encoder.
public const string QAACPath = ".\\tools\\qaac\\qaac64.exe";
public const int QAACBitrate = 192;
public const int QAACQualityMin = 0;
public const int QAACQualityMax = 127;

//ffmpeg
public const string ffmpegPath = ".\\tools\\ffmpeg\\ffmpeg.exe";
Expand Down