aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 05f062d..f5ffa85 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -531,15 +531,15 @@ static void receive_frames(AVCodecContext *av_codec_context, int stream_index, A
frame_data_queue.pop_front();
frames_erased = true;
}
+ av_packet_unref(&av_packet);
} else {
av_packet_rescale_ts(&av_packet, av_codec_context->time_base, stream->time_base);
av_packet.stream_index = stream->index;
- int ret = av_write_frame(av_format_context, &av_packet);
+ int ret = av_interleaved_write_frame(av_format_context, &av_packet);
if(ret < 0) {
fprintf(stderr, "Error: Failed to write frame index %d to muxer, reason: %s (%d)\n", av_packet.stream_index, av_error_to_string(ret), ret);
}
}
- av_packet_unref(&av_packet);
} else if (res == AVERROR(EAGAIN)) { // we have no packet
// fprintf(stderr, "No packet!\n");
av_packet_unref(&av_packet);
@@ -823,15 +823,15 @@ static void open_video(AVCodecContext *codec_context,
codec_context->hw_frames_ctx = frame_context;
bool supports_p4 = false;
- bool supports_p7 = false;
+ bool supports_p6 = false;
const AVOption *opt = nullptr;
while((opt = av_opt_next(codec_context->priv_data, opt))) {
if(opt->type == AV_OPT_TYPE_CONST) {
if(strcmp(opt->name, "p4") == 0)
supports_p4 = true;
- else if(strcmp(opt->name, "p7") == 0)
- supports_p7 = true;
+ else if(strcmp(opt->name, "p6") == 0)
+ supports_p6 = true;
}
}
@@ -868,7 +868,7 @@ static void open_video(AVCodecContext *codec_context,
}
}
- if(!supports_p4 && !supports_p7) {
+ if(!supports_p4 && !supports_p6) {
fprintf(stderr, "Info: your ffmpeg version is outdated. It's recommended that you use the flatpak version of gpu-screen-recorder version instead, which you can find at https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder\n");
}
@@ -883,12 +883,10 @@ static void open_video(AVCodecContext *codec_context,
// older gpus p5-p7 slow the gpu down to a crawl...
// "hq" is now just an alias for p7 in ffmpeg :(
// TODO: Temporary disable because of stuttering?
- /*
if(very_old_gpu)
av_dict_set(&options, "preset", supports_p4 ? "p4" : "medium", 0);
else
- av_dict_set(&options, "preset", supports_p7 ? "p7" : "slow", 0);
- */
+ av_dict_set(&options, "preset", supports_p6 ? "p6" : "slow", 0);
av_dict_set(&options, "tune", "hq", 0);
av_dict_set(&options, "rc", "constqp", 0);
@@ -1127,7 +1125,7 @@ static void save_replay_async(AVCodecContext *video_codec_context, int video_str
av_packet.stream_index = stream->index;
av_packet_rescale_ts(&av_packet, codec_context->time_base, stream->time_base);
- int ret = av_write_frame(av_format_context, &av_packet);
+ int ret = av_interleaved_write_frame(av_format_context, &av_packet);
if(ret < 0)
fprintf(stderr, "Error: Failed to write frame index %d to muxer, reason: %s (%d)\n", stream->index, av_error_to_string(ret), ret);
}
@@ -1207,8 +1205,6 @@ int main(int argc, char **argv) {
VideoCodec video_codec;
const char *codec_to_use = args["-k"].value();
- fprintf(stderr, "Info: forcing codec to h264 to investigate stuttering with some configs\n");
- codec_to_use = "h264";
if(!codec_to_use)
codec_to_use = "auto";
@@ -1368,12 +1364,8 @@ int main(int argc, char **argv) {
const char *capture_target = window_str;
bool direct_capture = strcmp(window_str, "screen-direct") == 0;
- if(direct_capture) {
+ if(direct_capture)
capture_target = "screen";
- // TODO: Temporary disable direct capture because push model causes stuttering when it's direct capturing. This might be a nvfbc bug. This does not happen when using a compositor.
- direct_capture = false;
- fprintf(stderr, "Warning: screen-direct has temporary been disabled as it causes stuttering. This is likely a NvFBC bug. Falling back to \"screen\".\n");
- }
if(!nv_fbc_library.create(capture_target, fps, &window_width, &window_height, region_x, region_y, region_width, region_height, direct_capture))
return 1;
@@ -1400,7 +1392,7 @@ int main(int argc, char **argv) {
if(replay_buffer_size_secs != -1) {
struct stat buf;
if(stat(filename, &buf) == -1 || !S_ISDIR(buf.st_mode)) {
- fprintf(stderr, "%s does not exist or is not a directory\n", filename);
+ fprintf(stderr, "Error: directory \"%s\" does not exist or is not a directory\n", filename);
usage();
}
}