diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 2ed12beb0c..f838ee5bd5 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1020,6 +1020,7 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
     const AVPixFmtDescriptor *desc;
     VAConfigAttrib rt_format_attr;
     const VAAPIEncodeRTFormat *rt_format;
+    const char *profile_string, *entrypoint_string;
     int i, j, n, depth, err;
 
 
@@ -1081,6 +1082,12 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
             avctx->profile != FF_PROFILE_UNKNOWN)
             continue;
 
+#if VA_CHECK_VERSION(1, 0, 0)
+        profile_string = vaProfileStr(profile->va_profile);
+#else
+        profile_string = "[no profile names]";
+#endif
+
         for (j = 0; j < n; j++) {
             if (va_profiles[j] == profile->va_profile)
                 break;
@@ -1102,13 +1109,8 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
 
     avctx->profile  = profile->av_profile;
     ctx->va_profile = profile->va_profile;
-#if VA_CHECK_VERSION(1, 0, 0)
     av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
-           vaProfileStr(ctx->va_profile), ctx->va_profile);
-#else
-    av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %d.\n",
-           ctx->va_profile);
-#endif
+           profile_string, ctx->va_profile);
 
     n = vaMaxNumEntrypoints(ctx->hwctx->display);
     va_entrypoints = av_malloc_array(n, sizeof(VAEntrypoint));
@@ -1120,8 +1122,8 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
                                    va_entrypoints, &n);
     if (vas != VA_STATUS_SUCCESS) {
         av_log(avctx, AV_LOG_ERROR, "Failed to query entrypoints for "
-               "profile %u: %d (%s).\n", ctx->va_profile,
-               vas, vaErrorStr(vas));
+               "profile %s (%d): %d (%s).\n", profile_string,
+               ctx->va_profile, vas, vaErrorStr(vas));
         err = AVERROR_EXTERNAL;
         goto fail;
     }
@@ -1136,19 +1138,19 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
     }
     if (i >= n) {
         av_log(avctx, AV_LOG_ERROR, "No usable encoding entrypoint found "
-               "for profile %d.\n", ctx->va_profile);
+               "for profile %s (%d).\n", profile_string, ctx->va_profile);
         err = AVERROR(ENOSYS);
         goto fail;
     }
 
     ctx->va_entrypoint = va_entrypoints[i];
 #if VA_CHECK_VERSION(1, 0, 0)
-    av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI entrypoint %s (%d).\n",
-           vaEntrypointStr(ctx->va_entrypoint), ctx->va_entrypoint);
+    entrypoint_string = vaEntrypointStr(ctx->va_entrypoint);
 #else
-    av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI entrypoint %d.\n",
-           ctx->va_entrypoint);
+    entrypoint_string = "[no entrypoint names]";
 #endif
+    av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI entrypoint %s (%d).\n",
+           entrypoint_string, ctx->va_entrypoint);
 
     for (i = 0; i < FF_ARRAY_ELEMS(vaapi_encode_rt_formats); i++) {
         rt_format = &vaapi_encode_rt_formats[i];
@@ -1160,8 +1162,9 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
     }
     if (i >= FF_ARRAY_ELEMS(vaapi_encode_rt_formats)) {
         av_log(avctx, AV_LOG_ERROR, "No usable render target format "
-               "found for profile %d entrypoint %d.\n",
-               ctx->va_profile, ctx->va_entrypoint);
+               "found for profile %s (%d) entrypoint %s (%d).\n",
+               profile_string, ctx->va_profile,
+               entrypoint_string, ctx->va_entrypoint);
         err = AVERROR(ENOSYS);
         goto fail;
     }
@@ -1183,8 +1186,9 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
                "is valid.\n", rt_format->name);
     } else if (!(rt_format_attr.value & rt_format->value)) {
         av_log(avctx, AV_LOG_ERROR, "Surface RT format %s not supported "
-               "by driver for encoding profile %d entrypoint %d.\n",
-               rt_format->name, ctx->va_profile, ctx->va_entrypoint);
+               "by driver for encoding profile %s (%d) entrypoint %s (%d).\n",
+               rt_format->name, profile_string, ctx->va_profile,
+               entrypoint_string, ctx->va_entrypoint);
         err = AVERROR(ENOSYS);
         goto fail;
     } else {
