Improve quality, especially when using h264. Force disable h264 for now because quality is not as good
This commit is contained in:
parent
94af0aeec4
commit
066cfae84c
@ -12,9 +12,8 @@ NvFBC doesn't work with PRIME, so if you are using PRIME then you can't record t
|
|||||||
If you are using a variable refresh rate monitor, then choose to record "screen-direct". This will allow variable refresh rate to work when recording fullscreen applications. Note that some applications such as mpv will not work in fullscreen mode. A fix is being developed for this.
|
If you are using a variable refresh rate monitor, then choose to record "screen-direct". This will allow variable refresh rate to work when recording fullscreen applications. Note that some applications such as mpv will not work in fullscreen mode. A fix is being developed for this.
|
||||||
|
|
||||||
# Performance
|
# Performance
|
||||||
When recording a 4k game, fps drops from 30 to 7 when using OBS Studio, however when using this screen recorder
|
When recording a 4k game, fps drops from 30 to 7 when using OBS Studio, however when using this screen recorder the fps remains at 30.\
|
||||||
the fps remains at 30.
|
It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
If you are running an Arch Linux based distro, then you can find gpu screen recorder on aur under the name gpu-screen-recorder-git (`yay -S gpu-screen-recorder-git`).\
|
If you are running an Arch Linux based distro, then you can find gpu screen recorder on aur under the name gpu-screen-recorder-git (`yay -S gpu-screen-recorder-git`).\
|
||||||
If you are running an Ubuntu based distro then run `install_ubuntu.sh` as root: `sudo ./install_ubuntu.sh`.\
|
If you are running an Ubuntu based distro then run `install_ubuntu.sh` as root: `sudo ./install_ubuntu.sh`.\
|
||||||
|
38
src/main.cpp
38
src/main.cpp
@ -423,7 +423,7 @@ static AVCodecContext *create_video_codec_context(AVFormatContext *av_format_con
|
|||||||
codec_context->codec_id = codec->id;
|
codec_context->codec_id = codec->id;
|
||||||
codec_context->width = record_width & ~1;
|
codec_context->width = record_width & ~1;
|
||||||
codec_context->height = record_height & ~1;
|
codec_context->height = record_height & ~1;
|
||||||
codec_context->bit_rate = 7500000 + (codec_context->width * codec_context->height) / 2;
|
codec_context->bit_rate = 12500000 + (codec_context->width * codec_context->height) / 2;
|
||||||
// Timebase: This is the fundamental unit of time (in seconds) in terms
|
// Timebase: This is the fundamental unit of time (in seconds) in terms
|
||||||
// of which frame timestamps are represented. For fixed-fps content,
|
// of which frame timestamps are represented. For fixed-fps content,
|
||||||
// timebase should be 1/framerate and timestamp increments should be
|
// timebase should be 1/framerate and timestamp increments should be
|
||||||
@ -435,31 +435,46 @@ static AVCodecContext *create_video_codec_context(AVFormatContext *av_format_con
|
|||||||
codec_context->sample_aspect_ratio.num = 0;
|
codec_context->sample_aspect_ratio.num = 0;
|
||||||
codec_context->sample_aspect_ratio.den = 0;
|
codec_context->sample_aspect_ratio.den = 0;
|
||||||
codec_context->gop_size = fps * 2;
|
codec_context->gop_size = fps * 2;
|
||||||
codec_context->max_b_frames = use_hevc ? 0 : 2;
|
codec_context->max_b_frames = 0;
|
||||||
codec_context->pix_fmt = AV_PIX_FMT_CUDA;
|
codec_context->pix_fmt = AV_PIX_FMT_CUDA;
|
||||||
codec_context->color_range = AVCOL_RANGE_JPEG;
|
codec_context->color_range = AVCOL_RANGE_JPEG;
|
||||||
switch(video_quality) {
|
switch(video_quality) {
|
||||||
case VideoQuality::MEDIUM:
|
case VideoQuality::MEDIUM:
|
||||||
codec_context->bit_rate = 5000000 + (codec_context->width * codec_context->height) / 2;
|
codec_context->bit_rate = 10000000 + (codec_context->width * codec_context->height) / 2;
|
||||||
codec_context->qmin = 30;
|
if(use_hevc) {
|
||||||
codec_context->qmax = 51;
|
codec_context->qmin = 20;
|
||||||
|
codec_context->qmax = 35;
|
||||||
|
} else {
|
||||||
|
codec_context->qmin = 5;
|
||||||
|
codec_context->qmax = 20;
|
||||||
|
}
|
||||||
//av_opt_set(codec_context->priv_data, "preset", "slow", 0);
|
//av_opt_set(codec_context->priv_data, "preset", "slow", 0);
|
||||||
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
||||||
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
||||||
//av_opt_set(codec_context->priv_data, "preset", "p4", 0);
|
//av_opt_set(codec_context->priv_data, "preset", "p4", 0);
|
||||||
break;
|
break;
|
||||||
case VideoQuality::HIGH:
|
case VideoQuality::HIGH:
|
||||||
codec_context->qmin = 20;
|
if(use_hevc) {
|
||||||
codec_context->qmax = 40;
|
codec_context->qmin = 17;
|
||||||
|
codec_context->qmax = 30;
|
||||||
|
} else {
|
||||||
|
codec_context->qmin = 5;
|
||||||
|
codec_context->qmax = 15;
|
||||||
|
}
|
||||||
//av_opt_set(codec_context->priv_data, "preset", "slow", 0);
|
//av_opt_set(codec_context->priv_data, "preset", "slow", 0);
|
||||||
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
||||||
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
||||||
//av_opt_set(codec_context->priv_data, "preset", "p5", 0);
|
//av_opt_set(codec_context->priv_data, "preset", "p5", 0);
|
||||||
break;
|
break;
|
||||||
case VideoQuality::ULTRA:
|
case VideoQuality::ULTRA:
|
||||||
codec_context->bit_rate = 10000000 + (codec_context->width * codec_context->height) / 2;
|
codec_context->bit_rate = 15000000 + (codec_context->width * codec_context->height) / 2;
|
||||||
codec_context->qmin = 16;
|
if(use_hevc) {
|
||||||
codec_context->qmax = 30;
|
codec_context->qmin = 16;
|
||||||
|
codec_context->qmax = 25;
|
||||||
|
} else {
|
||||||
|
codec_context->qmin = 3;
|
||||||
|
codec_context->qmax = 13;
|
||||||
|
}
|
||||||
//av_opt_set(codec_context->priv_data, "preset", "veryslow", 0);
|
//av_opt_set(codec_context->priv_data, "preset", "veryslow", 0);
|
||||||
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
//av_opt_set(codec_context->priv_data, "profile", "high", 0);
|
||||||
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
//codec_context->profile = FF_PROFILE_H264_HIGH;
|
||||||
@ -1095,7 +1110,8 @@ int main(int argc, char **argv) {
|
|||||||
av_format_context->flags |= AVFMT_FLAG_GENPTS;
|
av_format_context->flags |= AVFMT_FLAG_GENPTS;
|
||||||
const AVOutputFormat *output_format = av_format_context->oformat;
|
const AVOutputFormat *output_format = av_format_context->oformat;
|
||||||
|
|
||||||
bool use_hevc = strcmp(window_str, "screen") == 0 || strcmp(window_str, "screen-direct") == 0;
|
//bool use_hevc = strcmp(window_str, "screen") == 0 || strcmp(window_str, "screen-direct") == 0;
|
||||||
|
bool use_hevc = true;
|
||||||
if(use_hevc && strcmp(container_format, "flv") == 0) {
|
if(use_hevc && strcmp(container_format, "flv") == 0) {
|
||||||
use_hevc = false;
|
use_hevc = false;
|
||||||
fprintf(stderr, "Warning: hevc is not compatible with flv, falling back to h264 instead.\n");
|
fprintf(stderr, "Warning: hevc is not compatible with flv, falling back to h264 instead.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user