Make sure the first frame is pts 0

This commit is contained in:
dec05eba
2026-04-21 18:12:41 +02:00
parent 9a6b345bac
commit 1e1da80d74
3 changed files with 22 additions and 4 deletions

View File

@@ -898,6 +898,7 @@ static AVStream* create_stream(AVFormatContext *av_format_context, AVCodecContex
stream->id = av_format_context->nb_streams - 1;
stream->time_base = codec_context->time_base;
stream->avg_frame_rate = codec_context->framerate;
//stream->r_frame_rate = codec_context->framerate;
return stream;
}
@@ -1084,6 +1085,9 @@ static RecordingStartResult start_recording_create_streams(const char *filename,
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);
AVStream *video_stream = create_stream(av_format_context, video_codec_context);
avcodec_parameters_from_context(video_stream->codecpar, video_codec_context);
@@ -3785,6 +3789,9 @@ 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);
const AVOutputFormat *output_format = av_format_context->oformat;
std::string file_extension = output_format->extensions ? output_format->extensions : "";