> From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > Anton Khirnov > Sent: Wednesday, June 10, 2020 16:31 > To: FFmpeg development discussions and patches <ffmpeg- > de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg: flush and recreate > encoder instance if resolution changes > > Quoting Linjie Fu (2020-06-09 10:48:46) > > Signed-off-by: Linjie Fu <linjie...@intel.com> > > --- > > Should be squashed with: > > https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1434 > > > > fftools/ffmpeg.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > > index 5859781..8cdd532 100644 > > --- a/fftools/ffmpeg.c > > +++ b/fftools/ffmpeg.c > > @@ -130,6 +130,7 @@ static void do_video_stats(OutputStream *ost, int > frame_size); > > static BenchmarkTimeStamps get_benchmark_time_stamps(void); > > static int64_t getmaxrss(void); > > static int ifilter_has_all_input_formats(FilterGraph *fg); > > +static void flush_encoders(void); > > > > static int run_as_daemon = 0; > > static int nb_frames_dup = 0; > > @@ -1058,11 +1059,21 @@ static void do_video_out(OutputFile *of, > > > > if (next_picture && (enc->width != next_picture->width || > > enc->height != next_picture->height)) { > > + flush_encoders(); > > + avcodec_flush_buffers(enc); > > if (!(enc->codec->capabilities & > AV_CODEC_CAP_VARIABLE_DIMENSIONS)) { > > av_log(NULL, AV_LOG_ERROR, "Variable dimension encoding " > > "is not supported by %s.\n", enc->codec->name); > > goto error; > > } > > + > > + enc->width = next_picture->width; > > + enc->height = next_picture->height; > > + > > + if (enc->codec->close(enc) < 0) > > + goto error; > > + if (enc->codec->init(enc) < 0) > > + goto error; > > Absolutely not. > Those are private fields, they must not be accessed by libavcodec > callers. > > What I meant was freeing the encoder and creating a completely new > encoder instance.
Got it and updated, please help to comment, thx. https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1470 - Linjie _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".