diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-03-13 01:38:26 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-03-13 01:38:26 +0100 |
commit | af5468410376f6b8cb3a0c6e3fb46636e03299f8 (patch) | |
tree | d43bc60461ae593831f3e717bb74266315441c55 /src/encoder | |
parent | 92492db788e97db028176c942e9aed047f8f152a (diff) |
Fix screenshot with region not working correctly for some sizes and possibly crashing
Diffstat (limited to 'src/encoder')
-rw-r--r-- | src/encoder/video/nvenc.c | 3 | ||||
-rw-r--r-- | src/encoder/video/vaapi.c | 7 | ||||
-rw-r--r-- | src/encoder/video/vulkan.c | 12 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/encoder/video/nvenc.c b/src/encoder/video/nvenc.c index 943a4e8..c78e94a 100644 --- a/src/encoder/video/nvenc.c +++ b/src/encoder/video/nvenc.c @@ -138,6 +138,9 @@ static bool gsr_video_encoder_nvenc_start(gsr_video_encoder *encoder, AVCodecCon return false; } + video_codec_context->width = FFALIGN(video_codec_context->width, 2); + video_codec_context->height = FFALIGN(video_codec_context->height, 2); + if(video_codec_context->width < 128) video_codec_context->width = 128; diff --git a/src/encoder/video/vaapi.c b/src/encoder/video/vaapi.c index 3931571..8bb2f08 100644 --- a/src/encoder/video/vaapi.c +++ b/src/encoder/video/vaapi.c @@ -167,6 +167,13 @@ static bool gsr_video_encoder_vaapi_start(gsr_video_encoder *encoder, AVCodecCon } else { video_codec_context->height = FFALIGN(video_codec_context->height, 16); } + } else { + video_codec_context->width = FFALIGN(video_codec_context->width, 2); + video_codec_context->height = FFALIGN(video_codec_context->height, 2); + } + + if(FFALIGN(video_codec_context->width, 2) != FFALIGN(frame->width, 2) || FFALIGN(video_codec_context->height, 2) != FFALIGN(frame->height, 2)) { + fprintf(stderr, "gsr warning: gsr_video_encoder_vaapi_start: black bars have been added to the video because of a bug in AMD drivers/hardware. Record with h264 codec instead (-k h264) to get around this issue\n"); } if(video_codec_context->width < 128) diff --git a/src/encoder/video/vulkan.c b/src/encoder/video/vulkan.c index 0b6c380..d202ddd 100644 --- a/src/encoder/video/vulkan.c +++ b/src/encoder/video/vulkan.c @@ -165,6 +165,18 @@ static void gsr_video_encoder_vulkan_stop(gsr_video_encoder_vulkan *self, AVCode static bool gsr_video_encoder_vulkan_start(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame) { gsr_video_encoder_vulkan *self = encoder->priv; + video_codec_context->width = FFALIGN(video_codec_context->width, 2); + video_codec_context->height = FFALIGN(video_codec_context->height, 2); + + if(video_codec_context->width < 128) + video_codec_context->width = 128; + + if(video_codec_context->height < 128) + video_codec_context->height = 128; + + frame->width = video_codec_context->width; + frame->height = video_codec_context->height; + if(!gsr_video_encoder_vulkan_setup_context(self, video_codec_context)) { gsr_video_encoder_vulkan_stop(self, video_codec_context); return false; |