diff options
| author | dec05eba <dec05eba@protonmail.com> | 2026-04-23 10:03:01 +0200 |
|---|---|---|
| committer | dec05eba <dec05eba@protonmail.com> | 2026-04-23 10:03:01 +0200 |
| commit | 4ae78f6b6a980150147278df0229a40ab9fedc20 (patch) | |
| tree | ada98caa6c258957dfe7bd85e4b4fcca75661d7f /src | |
| parent | feac27c3d1a65ba0f368f7de736d7f2a9aac1b93 (diff) | |
Switch to hybrid fragmented mp4
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3b443c6..f6c9b19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1036,6 +1036,16 @@ static bool add_hdr_metadata_to_video_stream(gsr_capture *cap, AVStream *video_s return true; } +static void set_format_context_options(AVFormatContext *av_format_context) { + 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) + av_opt_set(av_format_context->priv_data, "movflags", "+hybrid_fragmented", 0); + } +} + struct RecordingStartAudio { const AudioTrack *audio_track; AVStream *stream; @@ -1084,9 +1094,7 @@ struct VideoSource { static RecordingStartResult start_recording_create_streams(const char *filename, const args_parser &arg_parser, AVCodecContext *video_codec_context, const std::vector<AudioTrack> &audio_tracks, bool hdr, std::vector<VideoSource> &video_sources) { AVFormatContext *av_format_context; avformat_alloc_output_context2(&av_format_context, nullptr, arg_parser.container_format, filename); - - av_opt_set(av_format_context->priv_data, "use_editlist", "1", 0); - av_opt_set(av_format_context->priv_data, "movflags", "+frag_keyframe+empty_moov+delay_moov", 0); + set_format_context_options(av_format_context); AVStream *video_stream = create_stream(av_format_context, video_codec_context); avcodec_parameters_from_context(video_stream->codecpar, video_codec_context); @@ -3789,8 +3797,7 @@ int main(int argc, char **argv) { _exit(1); } - av_opt_set(av_format_context->priv_data, "use_editlist", "1", 0); - av_opt_set(av_format_context->priv_data, "movflags", "+frag_keyframe+empty_moov+delay_moov", 0); + set_format_context_options(av_format_context); const AVOutputFormat *output_format = av_format_context->oformat; |
