only use hevc when recording the entire screen
This commit is contained in:
parent
4617e2c45a
commit
1f71584a77
14
src/main.cpp
14
src/main.cpp
@ -400,17 +400,15 @@ static AVStream *add_audio_stream(AVFormatContext *av_format_context, AVCodec **
|
|||||||
static AVStream *add_video_stream(AVFormatContext *av_format_context, AVCodec **codec,
|
static AVStream *add_video_stream(AVFormatContext *av_format_context, AVCodec **codec,
|
||||||
VideoQuality video_quality,
|
VideoQuality video_quality,
|
||||||
int texture_width, int texture_height,
|
int texture_width, int texture_height,
|
||||||
int fps) {
|
int fps, bool use_hevc) {
|
||||||
//*codec = avcodec_find_encoder(codec_id);
|
*codec = avcodec_find_encoder_by_name(use_hevc ? "hevc_nvenc" : "h264_nvenc");
|
||||||
bool using_hevc = true;
|
|
||||||
*codec = avcodec_find_encoder_by_name("hevc_nvenc");
|
|
||||||
if (!*codec) {
|
if (!*codec) {
|
||||||
*codec = avcodec_find_encoder_by_name("nvenc_hevc");
|
*codec = avcodec_find_encoder_by_name(use_hevc ? "nvenc_hevc" : "nvenc_h264");
|
||||||
}
|
}
|
||||||
if (!*codec) {
|
if (!*codec) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
"Error: Could not find h264_nvenc or nvenc_h264 encoder\n");
|
"Error: Could not find %s encoder\n", use_hevc ? "hevc" : "h264");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +440,7 @@ static AVStream *add_video_stream(AVFormatContext *av_format_context, AVCodec **
|
|||||||
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 = using_hevc ? 0 : 2;
|
codec_context->max_b_frames = use_hevc ? 0 : 2;
|
||||||
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) {
|
||||||
@ -882,7 +880,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
AVCodec *video_codec;
|
AVCodec *video_codec;
|
||||||
AVStream *video_stream =
|
AVStream *video_stream =
|
||||||
add_video_stream(av_format_context, &video_codec, quality, window_pixmap.texture_width, window_pixmap.texture_height, fps);
|
add_video_stream(av_format_context, &video_codec, quality, window_pixmap.texture_width, window_pixmap.texture_height, fps, strcmp(window_str, "screen") == 0);
|
||||||
if (!video_stream) {
|
if (!video_stream) {
|
||||||
fprintf(stderr, "Error: Failed to create video stream\n");
|
fprintf(stderr, "Error: Failed to create video stream\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user