diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-03-13 00:18:28 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-03-13 00:18:28 +0100 |
commit | 92492db788e97db028176c942e9aed047f8f152a (patch) | |
tree | 71071397c0237a803c2d926e656dca6d4143409b /src/encoder | |
parent | f23308444a94b96cf943fedc669bf2b7bc505a16 (diff) |
Add region capture with -w region -region WxH+X+Y
Diffstat (limited to 'src/encoder')
-rw-r--r-- | src/encoder/video/nvenc.c | 9 | ||||
-rw-r--r-- | src/encoder/video/vaapi.c | 28 |
2 files changed, 14 insertions, 23 deletions
diff --git a/src/encoder/video/nvenc.c b/src/encoder/video/nvenc.c index e83d0e8..943a4e8 100644 --- a/src/encoder/video/nvenc.c +++ b/src/encoder/video/nvenc.c @@ -138,6 +138,15 @@ static bool gsr_video_encoder_nvenc_start(gsr_video_encoder *encoder, AVCodecCon return false; } + 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_nvenc_setup_context(self, video_codec_context)) { gsr_video_encoder_nvenc_stop(self, video_codec_context); return false; diff --git a/src/encoder/video/vaapi.c b/src/encoder/video/vaapi.c index d558785..3931571 100644 --- a/src/encoder/video/vaapi.c +++ b/src/encoder/video/vaapi.c @@ -169,29 +169,11 @@ static bool gsr_video_encoder_vaapi_start(gsr_video_encoder *encoder, AVCodecCon } } - const int crop_top = (video_codec_context->height - frame->height) / 2; - const int crop_left = (video_codec_context->width - frame->width) / 2; - if(crop_top != 0 || crop_left != 0) { - 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 0 - #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 10, 100) - const int crop_bottom = crop_top; - const int crop_right = crop_left; - fprintf(stderr, "gsr info: cropping metadata has been added to the file to try and workaround this issue. Video players that support this will remove the black bars when the video is playing\n"); - const int frame_cropping_data_size = 4 * sizeof(uint32_t); - uint8_t *frame_cropping = av_malloc(frame_cropping_data_size); - if(frame_cropping) { - AV_WL32(frame_cropping + 0, crop_top); - AV_WL32(frame_cropping + 4, crop_bottom); - AV_WL32(frame_cropping + 8, crop_left); - AV_WL32(frame_cropping + 12, crop_right); - const bool sidedata_added = av_packet_side_data_add(&video_stream->codecpar->coded_side_data, &video_stream->codecpar->nb_coded_side_data, AV_PKT_DATA_FRAME_CROPPING, frame_cropping, frame_cropping_data_size, 0) != NULL; - if(!sidedata_added) - av_free(frame_cropping); - } - #endif -#endif - } + 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; |