Skip to content

Commit

Permalink
--output-resを使用した場合に、アスペクト比の設定がおかしくなることがあるのを修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Nov 17, 2022
1 parent 5ed759e commit 07589ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Amatsukaze/EncoderOptionParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct EncoderOptionInfo {
ENUM_ENCODER_DEINT deint;
bool afsTimecode;
int selectEvery;
int resizeWidth;
int resizeHeight;
};

static std::vector<std::wstring> SplitOptions(const tstring& str)
Expand Down Expand Up @@ -66,6 +68,8 @@ EncoderOptionInfo ParseEncoderOption(ENUM_ENCODER encoder, const tstring& str)
int argc = (int)argv.size();

info.format = VS_H264;
info.resizeWidth = 0;
info.resizeHeight = 0;

for (int i = 0; i < argc; ++i) {
auto& arg = argv[i];
Expand Down Expand Up @@ -155,6 +159,17 @@ EncoderOptionInfo ParseEncoderOption(ENUM_ENCODER encoder, const tstring& str)
} else {
info.format = VS_UNKNOWN;
}
} else if (arg == L"--output-res") {
int w = 0, h = 0;
if ( wscanf_s(next.c_str(), L"%dx%d", &w, &h) == 2
|| wscanf_s(next.c_str(), L"%d:%d", &w, &h) == 2
|| wscanf_s(next.c_str(), L"%d/%d", &w, &h) == 2) {
if (w <= 0 || h <= 0) {
THROW(ArgumentException,"--output-resは自然数で指定してください");
}
info.resizeWidth = w;
info.resizeHeight = h;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions Amatsukaze/TranscodeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,15 @@ static void transcodeMain(AMTContext& ctx, const ConfigWrapper& setting)
AMTFilterVideoEncoder encoder(ctx, std::max(4, setting.getNumEncodeBufferFrames()));
encoder.encode(filterClip, outfmt,
timeCodes, encoderArgs, env);

//エンコーダでのリサイズを反映
if (eoInfo.resizeWidth != 0 && eoInfo.resizeHeight != 0) {
fileOut.vfmt.width = eoInfo.resizeWidth;
fileOut.vfmt.height = eoInfo.resizeHeight;
// エンコーダ側でリサイズを行う場合は、SAR比を1:1にする
fileOut.vfmt.sarWidth = 1;
fileOut.vfmt.sarHeight = 1;
}
}
catch (const AvisynthError& avserror) {
THROWF(AviSynthException, "%s", avserror.msg);
Expand Down

0 comments on commit 07589ed

Please sign in to comment.