diff --git a/NVEncC_Options.en.md b/NVEncC_Options.en.md index 0a90649a..d14158eb 100644 --- a/NVEncC_Options.en.md +++ b/NVEncC_Options.en.md @@ -218,8 +218,9 @@ - [--log \](#--log-string) - [--log-level \[\=\]\\[,\=\\]...](#--log-level-param1valueparam2value) - [--log-opt \=\\[,\=\\]...](#--log-opt-param1valueparam2value) - - [--log-framelist](#--log-framelist) - - [--log-packets](#--log-packets) + - [--log-framelist \[\\]](#--log-framelist-string) + - [--log-packets \[\\]](#--log-packets-string) + - [--log-mux-ts \[\\]](#--log-mux-ts-string) - [--thread-affinity \[\=\]{\\[#\\[:\\]...\] or 0x\}](#--thread-affinity-string1string2intint-or-0xhex) - [--thread-priority \[\=\]\\[#\\[:\\]...\]](#--thread-priority-string1string2intint) - [--thread-throttling \[\=\]\\[#\\[:\\]...\]](#--thread-throttling-string1string2intint) @@ -2608,12 +2609,15 @@ additional options for log output. - addtime (default=off) Add time of to each line of the log. -### --log-framelist +### --log-framelist [<string>] FOR DEBUG ONLY! Output debug log for avsw/avhw reader. -### --log-packets +### --log-packets [<string>] FOR DEBUG ONLY! Output debug log for packets read in avsw/avhw reader. +### --log-mux-ts [<string>] +FOR DEBUG ONLY! Output debug log for packets written. + ### --thread-affinity [<string1>=]{<string2>[#<int>[:<int>]...] or 0x<hex>} Set thread affinity to the process or threads of the application. diff --git a/NVEncC_Options.ja.md b/NVEncC_Options.ja.md index f90b2087..f28dd1fc 100644 --- a/NVEncC_Options.ja.md +++ b/NVEncC_Options.ja.md @@ -214,8 +214,9 @@ - [--log \](#--log-string) - [--log-level \[\=\]\\[,\=\\]...](#--log-level-param1valueparam2value) - [--log-opt \=\\[,\=\\]...](#--log-opt-param1valueparam2value) - - [--log-framelist](#--log-framelist) - - [--log-packets](#--log-packets) + - [--log-framelist \[\\]](#--log-framelist-string) + - [--log-packets \[\\]](#--log-packets-string) + - [--log-mux-ts \[\\]](#--log-mux-ts-string) - [--thread-affinity \[\=\]{\\[#\\[:\\]...\] or 0x\}](#--thread-affinity-string1string2intint-or-0xhex) - [--thread-priority \[\=\]\\[#\\[:\\]...\]](#--thread-priority-string1string2intint) - [--thread-throttling \[\=\]\\[#\\[:\\]...\]](#--thread-throttling-string1string2intint) @@ -2675,12 +2676,14 @@ file以外のプロトコルを使用する場合には、この出力バッフ - addtime (デフォルト=off) ログの各行に時刻を表示するように。 -### --log-framelist +### --log-framelist [<string>] avsw/avhw読み込み時のデバッグ情報出力。 -### --log-packets +### --log-packets [<string>] avsw/avhw読み込み時のデバッグ情報出力。 +### --log-mux-ts [<string>] +デバッグ情報出力。 ### --thread-affinity [<string1>=]{<string2>[#<int>[:<int>]...] or 0x<hex>} NVEncCのプロセスやスレッドのスレッドアフィニティを設定する。具体的な指定方法は例を確認してください。 diff --git a/NVEncCore/rgy_cmd.cpp b/NVEncCore/rgy_cmd.cpp index 2d2c3623..27b2b2e9 100644 --- a/NVEncCore/rgy_cmd.cpp +++ b/NVEncCore/rgy_cmd.cpp @@ -5097,7 +5097,7 @@ int parse_one_ctrl_option(const TCHAR *option_name, const TCHAR *strInput[], int if (param_arg == _T("framelist")) { bool b = false; if (!cmd_string_to_bool(&b, param_val)) { - ctrl->logAddTime = b; + ctrl->logFramePosList.enable = b; } else { print_cmd_error_invalid_value(tstring(option_name) + _T(" ") + param_arg + _T("="), param_val); return 1; @@ -5107,7 +5107,17 @@ int parse_one_ctrl_option(const TCHAR *option_name, const TCHAR *strInput[], int if (param_arg == _T("packets")) { bool b = false; if (!cmd_string_to_bool(&b, param_val)) { - ctrl->logAddTime = b; + ctrl->logPacketsList.enable = b; + } else { + print_cmd_error_invalid_value(tstring(option_name) + _T(" ") + param_arg + _T("="), param_val); + return 1; + } + continue; + } + if (param_arg == _T("mux-ts")) { + bool b = false; + if (!cmd_string_to_bool(&b, param_val)) { + ctrl->logMuxVidTs.enable = b; } else { print_cmd_error_invalid_value(tstring(option_name) + _T(" ") + param_arg + _T("="), param_val); return 1; @@ -5121,10 +5131,13 @@ int parse_one_ctrl_option(const TCHAR *option_name, const TCHAR *strInput[], int ctrl->logAddTime = true; continue; } else if (param == _T("framelist")) { - ctrl->logFramePosList = true; + ctrl->logFramePosList.enable = true; continue; } else if (param == _T("packets")) { - ctrl->logPacketsList = true; + ctrl->logPacketsList.enable = true; + continue; + } else if (param == _T("mux-ts")) { + ctrl->logMuxVidTs.enable = true; continue; } else { print_cmd_error_unknown_opt_param(option_name, param, paramList); @@ -5142,16 +5155,30 @@ int parse_one_ctrl_option(const TCHAR *option_name, const TCHAR *strInput[], int return parse_log_level_param(option_name, strInput[i], ctrl->loglevel); } if (IS_OPTION("log-framelist")) { - ctrl->logFramePosList = true; + ctrl->logFramePosList.enable = true; + if (i + 1 >= nArgNum || strInput[i + 1][0] == _T('-')) { + return 0; + } + i++; + ctrl->logFramePosList.filename = strInput[i]; return 0; } if (IS_OPTION("log-packets")) { - ctrl->logPacketsList = true; + ctrl->logPacketsList.enable = true; + if (i + 1 >= nArgNum || strInput[i + 1][0] == _T('-')) { + return 0; + } + i++; + ctrl->logPacketsList.filename = strInput[i]; return 0; } if (IS_OPTION("log-mux-ts")) { + ctrl->logMuxVidTs.enable = true; + if (i + 1 >= nArgNum || strInput[i + 1][0] == _T('-')) { + return 0; + } i++; - ctrl->logMuxVidTsFile = _tcsdup(strInput[i]); + ctrl->logMuxVidTs.filename = strInput[i]; return 0; } if (IS_OPTION("max-procfps")) { @@ -6629,9 +6656,24 @@ tstring gen_cmd(const RGYParamControl *param, const RGYParamControl *defaultPrm, cmd << _T(" --log-opt ") << tmp.str().substr(1); } } - OPT_BOOL(_T("--log-framelist"), _T(""), logFramePosList); - OPT_BOOL(_T("--log-packets"), _T(""), logPacketsList); - OPT_CHAR_PATH(_T("--log-mux-ts"), logMuxVidTsFile); + if (param->logFramePosList.enable) { + cmd << _T(" --log-framelist"); + if (param->logFramePosList.filename.length() > 0) { + cmd << _T(" \"") << param->logFramePosList.filename << _T("\""); + } + } + if (param->logPacketsList.enable) { + cmd << _T(" --log-packets"); + if (param->logPacketsList.filename.length() > 0) { + cmd << _T(" \"") << param->logPacketsList.filename << _T("\""); + } + } + if (param->logMuxVidTs.enable) { + cmd << _T(" --log-mux-ts"); + if (param->logMuxVidTs.filename.length() > 0) { + cmd << _T(" \"") << param->logMuxVidTs.filename << _T("\""); + } + } OPT_BOOL(_T("--skip-hwenc-check"), _T(""), skipHWEncodeCheck); OPT_BOOL(_T("--skip-hwdec-check"), _T(""), skipHWDecodeCheck); OPT_STR_PATH(_T("--avsdll"), avsdll); @@ -7433,8 +7475,9 @@ tstring gen_cmd_help_ctrl() { _T(" additional options for log output.\n") _T(" params\n") _T(" addtime add time to log lines.\n") - _T(" --log-framelist output debug info for avsw/avhw reader.\n") - _T(" --log-packets output debug info for avsw/avhw reader.\n")); + _T(" --log-framelist [] output debug info for avsw/avhw reader.\n") + _T(" --log-packets [] output debug info for avsw/avhw reader.\n") + _T(" --log-mux-ts [] output debug info for avsw/avhw reader.\n")); str += strsprintf(_T("\n") _T(" --option-file read commanline options written in file.\n")); diff --git a/NVEncCore/rgy_input.cpp b/NVEncCore/rgy_input.cpp index ce754e32..dea80d63 100644 --- a/NVEncCore/rgy_input.cpp +++ b/NVEncCore/rgy_input.cpp @@ -397,7 +397,8 @@ static RGY_ERR initOtherReaders( inputInfoAVAudioReader.AVSyncMode = RGY_AVSYNC_ASSUME_CFR; inputInfoAVAudioReader.seekSec = common->seekSec; inputInfoAVAudioReader.seekToSec = common->seekToSec; - inputInfoAVAudioReader.logFramePosList = (ctrl->logFramePosList) ? src.filename + _T(".framelist.csv") : _T(""); + inputInfoAVAudioReader.logFramePosList = ctrl->logFramePosList.getFilename(src.filename, _T(".framelist.csv")); + inputInfoAVAudioReader.logPackets = ctrl->logPacketsList.getFilename(src.filename, _T(".packets.csv")); inputInfoAVAudioReader.threadInput = 0; inputInfoAVAudioReader.threadParamInput = ctrl->threadParams.get(RGYThreadType::INPUT); inputInfoAVAudioReader.timestampPassThrough = common->timestampPassThrough; @@ -616,8 +617,8 @@ RGY_ERR initReaders( inputInfoAVCuvid.AVSyncMode = RGY_AVSYNC_ASSUME_CFR; inputInfoAVCuvid.seekSec = common->seekSec; inputInfoAVCuvid.seekToSec = common->seekToSec; - inputInfoAVCuvid.logFramePosList = (ctrl->logFramePosList) ? common->outputFilename + _T(".framelist.csv") : _T(""); - inputInfoAVCuvid.logPackets = (ctrl->logPacketsList) ? common->outputFilename + _T(".packets.csv") : _T(""); + inputInfoAVCuvid.logFramePosList = ctrl->logFramePosList.getFilename(common->inputFilename, _T(".framelist.csv")); + inputInfoAVCuvid.logPackets = ctrl->logPacketsList.getFilename(common->inputFilename, _T(".packets.csv")); inputInfoAVCuvid.threadInput = ctrl->threadInput; inputInfoAVCuvid.threadParamInput = ctrl->threadParams.get(RGYThreadType::INPUT); inputInfoAVCuvid.queueInfo = (perfMonitor) ? perfMonitor->GetQueueInfoPtr() : nullptr; diff --git a/NVEncCore/rgy_input_avcodec.cpp b/NVEncCore/rgy_input_avcodec.cpp index 4092a9ad..53a86355 100644 --- a/NVEncCore/rgy_input_avcodec.cpp +++ b/NVEncCore/rgy_input_avcodec.cpp @@ -1470,6 +1470,7 @@ RGY_ERR RGYInputAvcodec::Init(const TCHAR *strFileName, VideoInfo *inputInfo, co } if (input_prm->logPackets.length() > 0) { m_fpPacketList.reset(_tfopen(input_prm->logPackets.c_str(), _T("w"))); + fprintf(m_fpPacketList.get(), " stream id, codec, pts, dts, duration, flags, pos\n"); } // input-probesizeやinput-analyzeが小さすぎて動画情報を得られなかったときのためのretryループ (デフォルトでは無効) @@ -2479,9 +2480,11 @@ std::tuple>> RGYInputAvcod continue; } if (m_fpPacketList) { - fprintf(m_fpPacketList.get(), "stream %2d, %12s, pts, %s\n", + fprintf(m_fpPacketList.get(), "stream %2d, %12s, %s, %s,%5lld,%2d, %12lld\n", pkt->stream_index, avcodec_get_name(m_Demux.format.formatCtx->streams[pkt->stream_index]->codecpar->codec_id), - pkt->pts == AV_NOPTS_VALUE ? "Unknown" : strsprintf("%lld", pkt->pts).c_str()); + pkt->pts == AV_NOPTS_VALUE ? " Unknown" : strsprintf("%12lld", pkt->pts).c_str(), + pkt->dts == AV_NOPTS_VALUE ? " Unknown" : strsprintf("%12lld", pkt->dts).c_str(), + pkt->duration, pkt->flags, pkt->pos); } if (pkt->stream_index == m_Demux.video.index) { if (pkt->flags & AV_PKT_FLAG_CORRUPT) { diff --git a/NVEncCore/rgy_input_avcodec.h b/NVEncCore/rgy_input_avcodec.h index bf62c4a1..4d81a9e9 100644 --- a/NVEncCore/rgy_input_avcodec.h +++ b/NVEncCore/rgy_input_avcodec.h @@ -196,17 +196,19 @@ class FramePosList { if (filename == nullptr) { return 1; } - FILE *fp = NULL; - if (0 != _tfopen_s(&fp, filename, _T("wb"))) { + FILE *fp = nullptr; + if (0 != _tfopen_s(&fp, filename, _T("wb")) || fp == nullptr) { return 1; } - fprintf(fp, "pts,dts,duration,duration2,poc,flags,pic_struct,repeat_pict,pict_type\r\n"); + fprintf(fp, " poc, T,flags,repeat, pts, dts,duration,duration2,pic_struct\r\n"); for (int i = 0; i < nList; i++) { - fprintf(fp, "%lld,%lld,%d,%d,%d,%d,%d,%d,%d\r\n", + fprintf(fp, "%8d,%2s,%2d,%2d,%12lld, %12lld, %6d, %6d, %s\r\n", + m_list[i].data.poc, + (m_list[i].data.pict_type == 1) ? "I" : ((m_list[i].data.pict_type == 2) ? "P" : ((m_list[i].data.pict_type == 3) ? "B" : "X")), + (int)m_list[i].data.flags, m_list[i].data.repeat_pict, (lls)m_list[i].data.pts, (lls)m_list[i].data.dts, m_list[i].data.duration, m_list[i].data.duration2, - m_list[i].data.poc, - (int)m_list[i].data.flags, (int)m_list[i].data.pic_struct, (int)m_list[i].data.repeat_pict, (int)m_list[i].data.pict_type); + tchar_to_string(picstrcut_to_str((RGY_PICSTRUCT)m_list[i].data.pic_struct)).c_str()); } fclose(fp); return 0; diff --git a/NVEncCore/rgy_output.cpp b/NVEncCore/rgy_output.cpp index e23419a3..5269e9a2 100644 --- a/NVEncCore/rgy_output.cpp +++ b/NVEncCore/rgy_output.cpp @@ -1046,7 +1046,7 @@ RGY_ERR initWriters( writerPrm.audioResampler = common->audioResampler; writerPrm.audioIgnoreDecodeError = common->audioIgnoreDecodeError; writerPrm.queueInfo = (pPerfMonitor) ? pPerfMonitor->GetQueueInfoPtr() : nullptr; - writerPrm.muxVidTsLogFile = (ctrl->logMuxVidTsFile) ? ctrl->logMuxVidTsFile : _T(""); + writerPrm.muxVidTsLogFile = ctrl->logMuxVidTs.getFilename(common->outputFilename, _T(".muxts.log")); writerPrm.bitstreamTimebase = av_make_q(outputTimebase); writerPrm.chapterNoTrim = common->chapterNoTrim; writerPrm.attachments = common->attachmentSource; diff --git a/NVEncCore/rgy_prm.cpp b/NVEncCore/rgy_prm.cpp index a7190d7d..c7e48c56 100644 --- a/NVEncCore/rgy_prm.cpp +++ b/NVEncCore/rgy_prm.cpp @@ -1473,6 +1473,23 @@ bool GPUAutoSelectMul::operator!=(const GPUAutoSelectMul &x) const { return !(*this == x); } +RGYDebugLogFile::RGYDebugLogFile() : enable(false), filename() {} + +bool RGYDebugLogFile::operator==(const RGYDebugLogFile &x) const { + return enable == x.enable + && filename == x.filename; +} +bool RGYDebugLogFile::operator!=(const RGYDebugLogFile &x) const { + return !(*this == x); +} +tstring RGYDebugLogFile::getFilename(const tstring& outputFilename, const tstring& defaultAppendix) const { + if (!enable) return tstring(); + if (filename.length() > 0) { + return filename; + } + return outputFilename + defaultAppendix; +} + RGYParamInput::RGYParamInput() : resizeResMode(RGYResizeResMode::Normal) { @@ -1552,9 +1569,9 @@ RGYParamControl::RGYParamControl() : logfile(), //ログ出力先 loglevel(RGY_LOG_INFO), //ログ出力レベル logAddTime(false), - logFramePosList(false), //framePosList出力 - logPacketsList(false), - logMuxVidTsFile(nullptr), + logFramePosList(), //framePosList出力 + logPacketsList(), + logMuxVidTs(), threadOutput(RGY_OUTPUT_THREAD_AUTO), threadAudio(RGY_AUDIO_THREAD_AUTO), threadInput(RGY_INPUT_THREAD_AUTO), diff --git a/NVEncCore/rgy_prm.h b/NVEncCore/rgy_prm.h index a28850db..2993f137 100644 --- a/NVEncCore/rgy_prm.h +++ b/NVEncCore/rgy_prm.h @@ -1455,6 +1455,16 @@ struct GPUAutoSelectMul { bool operator!=(const GPUAutoSelectMul &x) const; }; +struct RGYDebugLogFile { + bool enable; + tstring filename; + + RGYDebugLogFile(); + bool operator==(const RGYDebugLogFile &x) const; + bool operator!=(const RGYDebugLogFile &x) const; + tstring getFilename(const tstring& outputFilename, const tstring& defaultAppendix) const; +}; + struct RGYParamInput { RGYResizeResMode resizeResMode; @@ -1537,9 +1547,9 @@ struct RGYParamControl { tstring logfile; //ログ出力先 RGYParamLogLevel loglevel; //ログ出力レベル bool logAddTime; - bool logFramePosList; //framePosList出力 - bool logPacketsList; - TCHAR *logMuxVidTsFile; + RGYDebugLogFile logFramePosList; //framePosList出力 + RGYDebugLogFile logPacketsList; + RGYDebugLogFile logMuxVidTs; int threadOutput; int threadAudio; int threadInput;