diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 13be7c4872..29679432c6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -328,6 +328,8 @@ typedef struct OutputFilterOptions { enum AVColorRange color_range; enum VideoSyncMethod vsync_method; + AVRational frame_rate; + AVRational max_frame_rate; int sample_rate; AVChannelLayout ch_layout; @@ -605,9 +607,6 @@ typedef struct OutputStream { AVCodecContext *enc_ctx; /* video only */ - AVRational frame_rate; - AVRational max_frame_rate; - int force_fps; #if FFMPEG_OPT_TOP int top_field_first; #endif diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 63462300f9..4c08386b8d 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -854,8 +854,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, return AVERROR(ENOMEM); ofp->fps.vsync_method = opts->vsync_method; - ofp->fps.framerate = ost->frame_rate; - ofp->fps.framerate_max = ost->max_frame_rate; + ofp->fps.framerate = opts->frame_rate; + ofp->fps.framerate_max = opts->max_frame_rate; ofp->fps.framerate_supported = opts->frame_rates; // reduce frame rate for mpeg4 to be within the spec limits diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 5df718faf0..f41f2c18fa 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -85,6 +85,10 @@ typedef struct MuxStream { int ts_drop; #endif + AVRational frame_rate; + AVRational max_frame_rate; + int force_fps; + const char *apad; } MuxStream; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index bf2c0b8f67..1435d8339d 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -605,13 +605,13 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, st = ost->st; opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate); - if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { + if (frame_rate && av_parse_video_rate(&ms->frame_rate, frame_rate) < 0) { av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); return AVERROR(EINVAL); } opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate); - if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) { + if (max_frame_rate && av_parse_video_rate(&ms->max_frame_rate, max_frame_rate) < 0) { av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate); return AVERROR(EINVAL); } @@ -775,7 +775,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, } } - opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps); + opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ms->force_fps); #if FFMPEG_OPT_TOP ost->top_field_first = -1; @@ -796,7 +796,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, return ret; } - if ((ost->frame_rate.num || ost->max_frame_rate.num) && + if ((ms->frame_rate.num || ms->max_frame_rate.num) && !(*vsync_method == VSYNC_AUTO || *vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR)) { av_log(ost, AV_LOG_FATAL, "One of -r/-fpsmax was specified " @@ -805,7 +805,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, } if (*vsync_method == VSYNC_AUTO) { - if (ost->frame_rate.num || ost->max_frame_rate.num) { + if (ms->frame_rate.num || ms->max_frame_rate.num) { *vsync_method = VSYNC_CFR; } else if (!strcmp(oc->oformat->name, "avi")) { *vsync_method = VSYNC_VFR; @@ -937,6 +937,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, .color_space = enc_ctx->colorspace, .color_range = enc_ctx->color_range, .vsync_method = vsync_method, + .frame_rate = ms->frame_rate, + .max_frame_rate = ms->max_frame_rate, .sample_rate = enc_ctx->sample_rate, .ch_layout = enc_ctx->ch_layout, .sws_opts = o->g->sws_dict, @@ -963,7 +965,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, if (ret < 0) return ret; } - if (!ost->force_fps) { + if (!ms->force_fps) { ret = avcodec_get_supported_config(enc_ctx, NULL, AV_CODEC_CONFIG_FRAME_RATE, 0, (const void **) &opts.frame_rates, NULL); @@ -1035,7 +1037,7 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **e AVCodecContext *codec_ctx = NULL; - AVRational fr = ost->frame_rate; + AVRational fr = ms->frame_rate; int ret = 0;