diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index 9a9258ce7b..05ac4eb2de 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -1023,3 +1023,37 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
 
     return 0;
 }
+
+int ff_vulkan_encode_create_session_params (AVCodecContext *avctx, FFVulkanEncodeContext *ctx,
+                                            void *codec_params_pnext)
+{
+    VkResult ret;
+    FFVulkanFunctions *vk = &ctx->s.vkfn;
+    FFVulkanContext *s = &ctx->s;
+
+    VkVideoEncodeQualityLevelInfoKHR q_info;
+    VkVideoSessionParametersCreateInfoKHR session_params_create;
+
+    q_info = (VkVideoEncodeQualityLevelInfoKHR) {
+        .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR,
+        .pNext = codec_params_pnext,
+        .qualityLevel = ctx->opts.quality,
+    };
+    session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
+        .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
+        .pNext = &q_info,
+        .videoSession = ctx->common.session,
+        .videoSessionParametersTemplate = VK_NULL_HANDLE,
+    };
+
+    /* Create session parameters */
+    ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create,
+                                              s->hwctx->alloc, &ctx->session_params);
+    if (ret != VK_SUCCESS) {
+        av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n",
+               ff_vk_ret2str(ret));
+        return AVERROR_EXTERNAL;
+    }
+
+    return 0;
+}
diff --git a/libavcodec/vulkan_encode.h b/libavcodec/vulkan_encode.h
index fd3499dd10..a7a02d5fd0 100644
--- a/libavcodec/vulkan_encode.h
+++ b/libavcodec/vulkan_encode.h
@@ -245,6 +245,12 @@ int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt);
  */
 void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx);
 
+/**
+ * Create session parameters.
+ */
+int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx,
+                                           void *codec_params_pnext);
+
 /**
  * Paperwork.
  */
diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c
index af229afe52..72bed94e78 100644
--- a/libavcodec/vulkan_encode_h264.c
+++ b/libavcodec/vulkan_encode_h264.c
@@ -1005,7 +1005,6 @@ static av_cold int base_unit_to_vk(AVCodecContext *avctx,
 static int create_session_params(AVCodecContext *avctx)
 {
     int err;
-    VkResult ret;
     VulkanEncodeH264Context *enc = avctx->priv_data;
     FFVulkanEncodeContext *ctx = &enc->common;
     FFVulkanContext *s = &ctx->s;
@@ -1015,7 +1014,6 @@ static int create_session_params(AVCodecContext *avctx)
 
     VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info;
     VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params;
-    VkVideoSessionParametersCreateInfoKHR session_params_create;
 
     /* Convert it to Vulkan */
     err = base_unit_to_vk(avctx, &vk_units);
@@ -1044,23 +1042,8 @@ static int create_session_params(AVCodecContext *avctx)
         .maxStdPPSCount = 1,
         .pParametersAddInfo = &h264_params_info,
     };
-    session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
-        .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
-        .pNext = &h264_params,
-        .videoSession = ctx->common.session,
-        .videoSessionParametersTemplate = NULL,
-    };
 
-    /* Create session parameters */
-    ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create,
-                                              s->hwctx->alloc, &ctx->session_params);
-    if (ret != VK_SUCCESS) {
-        av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n",
-               ff_vk_ret2str(ret));
-        return AVERROR_EXTERNAL;
-    }
-
-    return 0;
+    return ff_vulkan_encode_create_session_params (avctx, ctx, &h264_params);
 }
 
 static int parse_feedback_units(AVCodecContext *avctx,
diff --git a/libavcodec/vulkan_encode_h265.c b/libavcodec/vulkan_encode_h265.c
index 3cb7a3b7df..6cfa3b0d7b 100644
--- a/libavcodec/vulkan_encode_h265.c
+++ b/libavcodec/vulkan_encode_h265.c
@@ -1165,7 +1165,6 @@ static int create_session_params(AVCodecContext *avctx)
 
     VkVideoEncodeH265SessionParametersAddInfoKHR h265_params_info;
     VkVideoEncodeH265SessionParametersCreateInfoKHR h265_params;
-    VkVideoSessionParametersCreateInfoKHR session_params_create;
 
     /* Convert it to Vulkan */
     err = base_unit_to_vk(avctx, &vk_units);
@@ -1197,23 +1196,8 @@ static int create_session_params(AVCodecContext *avctx)
         .maxStdVPSCount = 1,
         .pParametersAddInfo = &h265_params_info,
     };
-    session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
-        .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
-        .pNext = &h265_params,
-        .videoSession = ctx->common.session,
-        .videoSessionParametersTemplate = NULL,
-    };
 
-    /* Create session parameters */
-    ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create,
-                                              s->hwctx->alloc, &ctx->session_params);
-    if (ret != VK_SUCCESS) {
-        av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n",
-               ff_vk_ret2str(ret));
-        return AVERROR_EXTERNAL;
-    }
-
-    return 0;
+    return ff_vulkan_encode_create_session_params (avctx, ctx, &h265_params);
 }
 
 static int parse_feedback_units(AVCodecContext *avctx,
