From ef3767d750e82539198554277c493a8675360f44 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 3 Jul 2020 02:35:35 +0200 Subject: Improve video quality --- src/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 102e938..3a0635c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -377,7 +377,7 @@ static AVStream *add_video_stream(AVFormatContext *av_format_context, AVCodec ** fprintf(stderr, "codec id: %d\n", (*codec)->id); codec_context->width = window_pixmap.texture_width & ~1; codec_context->height = window_pixmap.texture_height & ~1; - codec_context->bit_rate = 3000000 + (codec_context->width * codec_context->height) / 2; //5000000 * ((double)fps / 30.0) + (codec_context->width * codec_context->height) / 2; + codec_context->bit_rate = 3500000 + (codec_context->width * codec_context->height) / 2; //5000000 * ((double)fps / 30.0) + (codec_context->width * codec_context->height) / 2; // Timebase: This is the fundamental unit of time (in seconds) in terms // of which frame timestamps are represented. For fixed-fps content, // timebase should be 1/framerate and timestamp increments should be @@ -388,8 +388,7 @@ static AVStream *add_video_stream(AVFormatContext *av_format_context, AVCodec ** // codec_context->framerate.den = 1; codec_context->sample_aspect_ratio.num = 1; codec_context->sample_aspect_ratio.den = 1; - codec_context->gop_size = - 32; // Emit one intra frame every 32 frames at most + codec_context->gop_size = fps * 2; codec_context->max_b_frames = 2; codec_context->pix_fmt = AV_PIX_FMT_CUDA; if (codec_context->codec_id == AV_CODEC_ID_MPEG1VIDEO) @@ -753,7 +752,7 @@ int main(int argc, char **argv) { // res = cuGraphicsUnmapResources(1, &cuda_graphics_resource, 0); double start_time = glfwGetTime(); - double frame_timer_start = start_time - target_fps - 0.001; + double frame_timer_start = start_time; double window_resize_timer = start_time; bool window_resized = false; int fps_counter = 0; -- cgit v1.2.3