mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
Fix first frame is black
This commit is contained in:
@@ -570,6 +570,9 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c
|
|||||||
if(!capture_is_combined_plane)
|
if(!capture_is_combined_plane)
|
||||||
capture_pos = (vec2i){drm_fd->x, drm_fd->y};
|
capture_pos = (vec2i){drm_fd->x, drm_fd->y};
|
||||||
|
|
||||||
|
self->params.egl->glFlush();
|
||||||
|
self->params.egl->glFinish();
|
||||||
|
|
||||||
/* Fast opengl free path */
|
/* Fast opengl free path */
|
||||||
if(self->monitor_rotation == GSR_MONITOR_ROT_0 && video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) {
|
if(self->monitor_rotation == GSR_MONITOR_ROT_0 && video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) {
|
||||||
int fds[4];
|
int fds[4];
|
||||||
|
|||||||
@@ -336,6 +336,9 @@ static int gsr_capture_portal_capture(gsr_capture *cap, AVFrame *frame, gsr_colo
|
|||||||
|
|
||||||
const vec2i target_pos = { max_int(0, frame->width / 2 - self->capture_size.x / 2), max_int(0, frame->height / 2 - self->capture_size.y / 2) };
|
const vec2i target_pos = { max_int(0, frame->width / 2 - self->capture_size.x / 2), max_int(0, frame->height / 2 - self->capture_size.y / 2) };
|
||||||
|
|
||||||
|
self->params.egl->glFlush();
|
||||||
|
self->params.egl->glFinish();
|
||||||
|
|
||||||
// TODO: Handle region crop
|
// TODO: Handle region crop
|
||||||
|
|
||||||
/* Fast opengl free path */
|
/* Fast opengl free path */
|
||||||
|
|||||||
@@ -258,6 +258,9 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, AVFrame *frame, gsr_
|
|||||||
|
|
||||||
const vec2i target_pos = { max_int(0, frame->width / 2 - self->texture_size.x / 2), max_int(0, frame->height / 2 - self->texture_size.y / 2) };
|
const vec2i target_pos = { max_int(0, frame->width / 2 - self->texture_size.x / 2), max_int(0, frame->height / 2 - self->texture_size.y / 2) };
|
||||||
|
|
||||||
|
self->params.egl->glFlush();
|
||||||
|
self->params.egl->glFinish();
|
||||||
|
|
||||||
/* Fast opengl free path */
|
/* Fast opengl free path */
|
||||||
if(video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) {
|
if(video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) {
|
||||||
vaapi_copy_egl_image_to_video_surface(self->params.egl, self->window_texture.image, (vec2i){0, 0}, self->texture_size, target_pos, self->texture_size, self->video_codec_context, frame);
|
vaapi_copy_egl_image_to_video_surface(self->params.egl, self->window_texture.image, (vec2i){0, 0}, self->texture_size, target_pos, self->texture_size, self->video_codec_context, frame);
|
||||||
|
|||||||
@@ -3158,7 +3158,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double fps_start_time = clock_get_monotonic_seconds();
|
double fps_start_time = clock_get_monotonic_seconds();
|
||||||
double frame_timer_start = fps_start_time - target_fps; // We want to capture the first frame immediately
|
double frame_timer_start = fps_start_time;
|
||||||
int fps_counter = 0;
|
int fps_counter = 0;
|
||||||
int damage_fps_counter = 0;
|
int damage_fps_counter = 0;
|
||||||
|
|
||||||
@@ -3446,11 +3446,11 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double frame_time_overflow = frame_timer_elapsed - target_fps;
|
double frame_time_overflow = frame_timer_elapsed - target_fps;
|
||||||
if (frame_time_overflow >= 0.0 && damaged) {
|
if ((frame_time_overflow >= 0.0 || video_pts_counter == 0) && damaged) {
|
||||||
gsr_damage_clear(&damage);
|
gsr_damage_clear(&damage);
|
||||||
if(capture->clear_damage)
|
if(capture->clear_damage)
|
||||||
capture->clear_damage(capture);
|
capture->clear_damage(capture);
|
||||||
frame_time_overflow = std::min(frame_time_overflow, target_fps);
|
frame_time_overflow = std::min(std::max(0.0, frame_time_overflow), target_fps);
|
||||||
frame_timer_start = time_now - frame_time_overflow;
|
frame_timer_start = time_now - frame_time_overflow;
|
||||||
|
|
||||||
const double this_video_frame_time = clock_get_monotonic_seconds() - paused_time_offset;
|
const double this_video_frame_time = clock_get_monotonic_seconds() - paused_time_offset;
|
||||||
|
|||||||
Reference in New Issue
Block a user