Skip to content

Commit

Permalink
音声フォーマット無視オプション追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nekopanda committed Sep 8, 2019
1 parent eebf180 commit 874e640
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Amatsukaze/AmatsukazeCLI.hpp
Expand Up @@ -67,6 +67,7 @@ static void printHelp(const tchar* bin) {
" --ignore-no-drcsmap マッピングにないDRCS外字があっても処理を続行する\n"
" --ignore-no-logo ロゴが見つからなくても処理を続行する\n"
" --ignore-nicojk-error ニコニコ実況取得でエラーが発生しても処理を続行する\n"
" --ignore-audio-format 音声フォーマットの切り替わりでファイルを分けない\n"
" --no-delogo ロゴ消しをしない(デフォルトはロゴがある場合は消します)\n"
" --loose-logo-detection ロゴ検出判定しきい値を低くします\n"
" --max-fade-length <数値> ロゴの最大フェードフレーム数[16]\n"
Expand Down Expand Up @@ -348,6 +349,9 @@ static std::unique_ptr<ConfigWrapper> parseArgs(AMTContext& ctx, int argc, const
else if (key == _T("--ignore-nicojk-error")) {
conf.ignoreNicoJKError = true;
}
else if (key == _T("--ignore-audio-format")) {
conf.ignoreAudioFormat = true;
}
else if (key == _T("--loose-logo-detection")) {
conf.looseLogoDetection = true;
}
Expand Down
4 changes: 2 additions & 2 deletions Amatsukaze/AmatsukazeTestImpl.hpp
Expand Up @@ -284,7 +284,7 @@ static int ProcessTest(AMTContext& ctx, const ConfigWrapper& setting)
static int FileStreamInfo(AMTContext& ctx, const ConfigWrapper& setting)
{
StreamReformInfo reformInfo = StreamReformInfo::deserialize(ctx, setting.getStreamInfoPath());
reformInfo.prepare(false);
reformInfo.prepare(false, false);
auto audioDiffInfo = reformInfo.genAudio({ CMTYPE_BOTH });
audioDiffInfo.printAudioPtsDiff(ctx);
reformInfo.printOutputMapping([&](EncodeFileKey key) {
Expand Down Expand Up @@ -535,7 +535,7 @@ static int CaptionASS(AMTContext& ctx, const ConfigWrapper& setting)
try {
StreamReformInfo reformInfo = StreamReformInfo::deserialize(ctx, setting.getStreamInfoPath());

reformInfo.prepare(false);
reformInfo.prepare(false, false);
auto audioDiffInfo = reformInfo.genAudio({ CMTYPE_BOTH });
audioDiffInfo.printAudioPtsDiff(ctx);

Expand Down
7 changes: 6 additions & 1 deletion Amatsukaze/Muxer.hpp
Expand Up @@ -82,7 +82,9 @@ class AMTMuxder : public AMTObject {
for (int asrc = 0, adst = 0; asrc < (int)fileIn.audioFrames.size(); ++asrc) {
const std::vector<int>& frameList = fileIn.audioFrames[asrc];
if (frameList.size() > 0) {
if (fmt.audioFormat[asrc].channels == AUDIO_2LANG) {
bool ignoreAudioFormat = setting_.isIgnoreAudioFormat();
bool isDualMono = (fmt.audioFormat[asrc].channels == AUDIO_2LANG);
if (!ignoreAudioFormat && isDualMono) {
// デュアルモノは2つのAACに分離
ctx.infoF("音声%d-%dはデュアルモノなので2つのAACファイルに分離します", fileIn.outKey.format, asrc);
SpDualMonoSplitter splitter(ctx);
Expand All @@ -97,6 +99,9 @@ class AMTMuxder : public AMTObject {
audioFiles.push_back(filepath1);
}
else {
if (isDualMono) {
ctx.infoF("音声%d-%dはデュアルモノですが、音声フォーマット無視指定があるので分離しません", fileIn.outKey.format, asrc);
}
tstring filepath = setting_.getIntAudioFilePath(key, adst++);
File file(filepath, _T("wb"));
for (int frameIndex : frameList) {
Expand Down
7 changes: 5 additions & 2 deletions Amatsukaze/StreamReform.hpp
Expand Up @@ -234,7 +234,8 @@ class StreamReformInfo : public AMTObject {

// 1. コンストラクト直後に呼ぶ
// splitSub: メイン以外のフォーマットを結合しない
void prepare(bool splitSub) {
void prepare(bool splitSub, bool ignoreAudioFormat) {
ignoreAudioFormat_ = ignoreAudioFormat;
reformMain(splitSub);
genWaveAudioStream();
}
Expand Down Expand Up @@ -488,6 +489,7 @@ class StreamReformInfo : public AMTObject {
std::vector<TimeInfo> timeList_;

std::array<std::vector<NicoJKLine>, NICOJK_MAX> nicoJKList_;
bool ignoreAudioFormat_;

// 計算データ
bool isVFR_;
Expand Down Expand Up @@ -1082,6 +1084,7 @@ class StreamReformInfo : public AMTObject {
bool isEquealFormat(const OutVideoFormat& a, const OutVideoFormat& b) {
if (a.videoFormat != b.videoFormat) return false;
if (a.audioFormat.size() != b.audioFormat.size()) return false;
if (ignoreAudioFormat_) return true;
for (int i = 0; i < (int)a.audioFormat.size(); ++i) {
if (a.audioFormat[i] != b.audioFormat[i]) {
return false;
Expand Down Expand Up @@ -1341,7 +1344,7 @@ class StreamReformInfo : public AMTObject {
++nskipped;
continue;
}
if (format != nullptr && frame.format != *format) {
if (!ignoreAudioFormat_ && format != nullptr && frame.format != *format) {
// フォーマットが違うのでスキップ
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion Amatsukaze/TranscodeManager.hpp
Expand Up @@ -514,7 +514,7 @@ static void transcodeMain(AMTContext& ctx, const ConfigWrapper& setting)
}
}

reformInfo.prepare(setting.isSplitSub());
reformInfo.prepare(setting.isSplitSub(), setting.isIgnoreAudioFormat());

time_t startTime = reformInfo.getFirstFrameTime();

Expand Down
5 changes: 5 additions & 0 deletions Amatsukaze/TranscodeSetting.hpp
Expand Up @@ -507,6 +507,7 @@ struct Config {
tstring nicoConvChSidPath;
ENUM_FORMAT format;
bool splitSub;
bool ignoreAudioFormat;
bool twoPass;
bool autoBitrate;
bool chapter;
Expand Down Expand Up @@ -654,6 +655,10 @@ class ConfigWrapper : public AMTObject
return conf.splitSub;
}

bool isIgnoreAudioFormat() const {
return conf.ignoreAudioFormat;
}

bool isTwoPass() const {
return conf.twoPass;
}
Expand Down
12 changes: 12 additions & 0 deletions AmatsukazeGUI/Models/DisplayData.cs
Expand Up @@ -1514,6 +1514,18 @@ public string ChapterExeOptions
}
#endregion

#region IgnoreAudioFormat変更通知プロパティ
public bool IgnoreAudioFormat {
get { return Data.IgnoreAudioFormat; }
set {
if (Data.IgnoreAudioFormat == value)
return;
Data.IgnoreAudioFormat = value;
RaisePropertyChanged();
}
}
#endregion

#region NoDelogo変更通知プロパティ
public bool NoDelogo {
get { return Data.NoDelogo; }
Expand Down
4 changes: 4 additions & 0 deletions AmatsukazeServer/Server/EncodeServer.cs
Expand Up @@ -1401,6 +1401,10 @@ private string GetEncoderName(EncoderType encoderType)
{
sb.Append(" --ignore-no-drcsmap");
}
if(profile.IgnoreAudioFormat)
{
sb.Append(" --ignore-audio-format");
}
if (profile.NoDelogo)
{
sb.Append(" --no-delogo");
Expand Down
2 changes: 2 additions & 0 deletions AmatsukazeServer/Server/EncodeServerData.cs
Expand Up @@ -242,6 +242,8 @@ public class ProfileSetting : IExtensibleDataObject
[DataMember]
public bool IgnoreNoDrcsMap { get; set; }
[DataMember]
public bool IgnoreAudioFormat { get; set; }
[DataMember]
public bool LooseLogoDetection { get; set; }
[DataMember]
public bool IgnoreNoLogo { get; set; }
Expand Down

0 comments on commit 874e640

Please sign in to comment.