aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2026-05-27 06:01:48 +0200
committerdec05eba <dec05eba@protonmail.com>2026-05-27 06:01:48 +0200
commit60f0459f840f568159a320f58d56063ba02e52c4 (patch)
tree748b0d32b9364f8ff7e63de700b608d6c5cac74d /src/main.cpp
parent33aba9a2c96c0cf4f3da512b1e1af076d220ea4a (diff)
Add check for libavformat version before using hybrid_fragmented, to workaround old ffmpeg bugs
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f0fbfc0..147db4f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1039,19 +1039,23 @@ static bool add_hdr_metadata_to_video_stream(gsr_capture *cap, AVStream *video_s
}
static void set_format_context_options(AVFormatContext *av_format_context) {
- bool hybrid_fragmented_available = false;
- av_opt_set(av_format_context->priv_data, "use_editlist", "1", 0);
- const AVOption *opt = av_opt_find(av_format_context->priv_data, "movflags", NULL, 0, 0);
- if (opt && opt->unit) {
- const AVOption *flag = av_opt_find(av_format_context->priv_data, "hybrid_fragmented", opt->unit, 0, 0);
- if (flag) {
- hybrid_fragmented_available = true;
- av_opt_set(av_format_context->priv_data, "movflags", "+hybrid_fragmented", 0);
+ if(LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(62, 6, 101)) {
+ bool hybrid_fragmented_available = false;
+ av_opt_set(av_format_context->priv_data, "use_editlist", "1", 0);
+ const AVOption *opt = av_opt_find(av_format_context->priv_data, "movflags", NULL, 0, 0);
+ if (opt && opt->unit) {
+ const AVOption *flag = av_opt_find(av_format_context->priv_data, "hybrid_fragmented", opt->unit, 0, 0);
+ if (flag) {
+ hybrid_fragmented_available = true;
+ av_opt_set(av_format_context->priv_data, "movflags", "+hybrid_fragmented", 0);
+ }
}
- }
- if(!hybrid_fragmented_available)
- fprintf(stderr, "gsr warning: hybrid_fragmented movflags is not available in your FFmpeg version. If you experience stutter in the mp4 file then update your FFmpeg or record to a mkv file\n");
+ if(!hybrid_fragmented_available)
+ fprintf(stderr, "gsr warning: hybrid_fragmented movflags is not available in your FFmpeg version. If you experience stutter in the mp4 file then update your FFmpeg to at least version 8 or record to a mkv file\n");
+ } else {
+ fprintf(stderr, "gsr warning: your FFmpeg version is known to be buggy (it doesn't have working hybrid_fragmented movflags). If you experience stutter in the mp4 file then update your FFmpeg to at least version 8 or record to a mkv file\n");
+ }
}
struct RecordingStartAudio {