From 35e218e05bb49903c4cc87f439d78bab96b6ad4e Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Mon, 27 Apr 2020 01:22:05 +0200 Subject: [PATCH] obs-ffmpeg: Add localization for NVENC error messages --- plugins/obs-ffmpeg/data/locale/en-US.ini | 8 ++++++++ plugins/obs-ffmpeg/jim-nvenc-helpers.c | 14 +++---------- plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c | 25 ++++++++++-------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/plugins/obs-ffmpeg/data/locale/en-US.ini b/plugins/obs-ffmpeg/data/locale/en-US.ini index ffd5034cc..d140a1093 100644 --- a/plugins/obs-ffmpeg/data/locale/en-US.ini +++ b/plugins/obs-ffmpeg/data/locale/en-US.ini @@ -58,3 +58,11 @@ ReplayBuffer.Save="Save Replay" HelperProcessFailed="Unable to start the recording helper process. Check that OBS files have not been blocked or removed by any 3rd party antivirus / security software." UnableToWritePath="Unable to write to %1. Make sure you're using a recording path which your user account is allowed to write to and that there is sufficient disk space." WarnWindowsDefender="If Windows 10 Ransomware Protection is enabled it can also cause this error. Try turning off controlled folder access in Windows Security / Virus & threat protection settings." + +NVENC.Error="Failed to open NVENC codec: %1" +NVENC.GenericError="Check your video drivers are up to date. Try closing other recording software which might be using NVENC such as NVIDIA Shadowplay or Windows 10 Game DVR." +NVENC.BadGPUIndex="You have selected GPU %1 in your output encoder settings. Set this back to 0 and try again." +NVENC.OutdatedDriver="Your current video card driver does not support this NVENC version, please update your drivers." +NVENC.UnsupportedDevice="NVENC Error: Unsupported device. Check your video card supports NVENC and that the drivers are up to date." +NVENC.TooManySessions="NVENC Error: Too many concurrent sessions. Try closing other recording software which might be using NVENC such as NVIDIA Shadowplay or Windows 10 Game DVR." +NVENC.CheckDrivers="Please check your video drivers are up to date." diff --git a/plugins/obs-ffmpeg/jim-nvenc-helpers.c b/plugins/obs-ffmpeg/jim-nvenc-helpers.c index 872ab2d06..bf6b58e44 100644 --- a/plugins/obs-ffmpeg/jim-nvenc-helpers.c +++ b/plugins/obs-ffmpeg/jim-nvenc-helpers.c @@ -21,18 +21,12 @@ bool nv_failed(obs_encoder_t *encoder, NVENCSTATUS err, const char *func, case NV_ENC_ERR_OUT_OF_MEMORY: obs_encoder_set_last_error( - encoder, - "NVENC Error: Too many concurrent sessions. " - "Try closing other recording software which might " - "be using NVENC such as Windows 10 Game DVR."); + encoder, obs_module_text("NVENC.TooManySessions")); break; case NV_ENC_ERR_UNSUPPORTED_DEVICE: obs_encoder_set_last_error( - encoder, - "NVENC Error: Unsupported device. Check your " - "video card supports NVENC and that the drivers are " - "up to date."); + encoder, obs_module_text("NVENC.UnsupportedDevice")); break; default: @@ -140,9 +134,7 @@ static inline bool init_nvenc_internal(obs_encoder_t *encoder) NVENCAPI_MINOR_VERSION; if (cur_ver > ver) { obs_encoder_set_last_error( - encoder, - "Your current video card driver does not support " - "this NVENC version, please update your drivers."); + encoder, obs_module_text("NVENC.OutdatedDriver")); error("Current driver version does not support this NVENC " "version, please upgrade your driver"); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c index 31c734b18..d731f426f 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c @@ -96,23 +96,18 @@ static bool nvenc_init_codec(struct nvenc_encoder *enc) if (!obs_encoder_get_last_error(enc->encoder)) { struct dstr error_message = {0}; - // special case for common NVENC error + dstr_copy(&error_message, + obs_module_text("NVENC.Error")); + dstr_replace(&error_message, "%1", av_err2str(ret)); + dstr_cat(&error_message, "\r\n\r\n"); + if (ret == AVERROR_EXTERNAL) { - dstr_printf( - &error_message, - "Failed to open NVENC codec: %s\r\n\r\n" - "Check your video drivers are up to " - "date. Disable other software that may " - "be using NVENC such as NVIDIA " - "ShadowPlay or Windows 10 Game " - "DVR.", - av_err2str(ret)); + // special case for common NVENC error + dstr_cat(&error_message, + obs_module_text("NVENC.GenericError")); } else { - dstr_printf( - &error_message, - "Failed to open NVENC codec: %s\r\n\r\n" - "Please check your video drivers are up to date.", - av_err2str(ret)); + dstr_cat(&error_message, + obs_module_text("NVENC.CheckDrivers")); } obs_encoder_set_last_error(enc->encoder,