Skip to content

Commit

Permalink
--vpp-select-everyが最終フレームの処理でエラー終了する場合があったのを修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Oct 7, 2023
1 parent 39f1168 commit 029af9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions NVEnc/NVEnc_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ NVIDIA グラフィックドライバ 536.23
- エンコードせずにy4m出力するオプションを追加。 (-c raw)
- 出力色空間を設定するオプションを追加。 (--output-csp)
- GPUの自動選択時にnvvfx使用の有無を考慮。
- --vpp-select-everyが最終フレームの処理でエラー終了する場合があったのを修正。

[NVEnc.auo]
- ログ出力に映像と音声の長さを表示するように。
Expand Down
20 changes: 5 additions & 15 deletions NVEncCore/NVEncFilterSelectEvery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,21 @@ RGY_ERR NVEncFilterSelectEvery::run_filter(const RGYFrameInfo *pInputFrame, RGYF
ppOutputFrames[0] = nullptr;
*pOutputFrameNum = 0;
if (pInputFrame->ptr == nullptr) {
if (m_frames % pSelectParam->selectevery.step != (pSelectParam->selectevery.step-1)
if (m_totalDuration > 0
&& m_frames % pSelectParam->selectevery.step != (pSelectParam->selectevery.step-1)
&& m_frames % pSelectParam->selectevery.step >= (pSelectParam->selectevery.step / 2)) {
auto pOutFrame = m_pFrameBuf[m_nFrameIdx].get();
if (m_frames % pSelectParam->selectevery.step < pSelectParam->selectevery.offset) {
const auto memcpyKind = getCudaMemcpyKind(pInputFrame->deivce_mem, pOutFrame->frame.deivce_mem);
if (memcpyKind != cudaMemcpyDeviceToDevice) {
AddMessage(RGY_LOG_ERROR, _T("only supported on device memory.\n"));
return RGY_ERR_INVALID_PARAM;
}
auto cudaerr = copyFrameAsync(&pOutFrame->frame, pInputFrame, stream);
if (cudaerr != cudaSuccess) {
AddMessage(RGY_LOG_ERROR, _T("failed to copy frame to buffer: %s.\n"), char_to_tstring(cudaGetErrorName(cudaerr)).c_str());
return RGY_ERR_CUDA;
}
pOutFrame->frame.inputFrameId = pInputFrame->inputFrameId;
}
ppOutputFrames[0] = &pOutFrame->frame;
ppOutputFrames[0]->duration = m_totalDuration * pSelectParam->selectevery.step / ((m_frames % pSelectParam->selectevery.step) + 1);
ppOutputFrames[0]->duration = m_totalDuration * pSelectParam->selectevery.step / (m_frames % pSelectParam->selectevery.step);
ppOutputFrames[0]->timestamp = m_outPts;
*pOutputFrameNum = 1;
if (m_totalDuration < 0 || m_outPts < 0) {
AddMessage(RGY_LOG_ERROR, _T("Invalid timestamp calculated for output: timestamp %lld, duration %lld.\n"),
m_outPts, m_totalDuration);
return RGY_ERR_INVALID_PARAM;
}
m_outPts = -1;
m_totalDuration = 0;
}
return sts;
}
Expand Down

0 comments on commit 029af9a

Please sign in to comment.