Message ID | 1574125994-7782-1-git-send-email-joshua.allmann@gmail.com |
---|---|
State | New |
Headers | show |
On 2019-11-18 17:13, Josh Allmann wrote: > This patch is meant to be an entry point for discussion around an > issue we are having with flushing the nvenc encoder while doing > segmented transcoding. Hopefully there will be a less kludgey > workaround than this. Hi Josh, I happened to see your email recently, and took a quick look into this. It seems that encoders are allowed to implement .flush() and then avcodec_flush_buffers() can be called on them like on a decoder. So I've posted a patch that does this (with the same impl that you had). If that works for you, then that's all it takes - no need for a new API call because there's already one you can use. Let us know, --phil
On Fri, 20 Dec 2019 at 15:36, Philip Langdale <philipl@overt.org> wrote: > > On 2019-11-18 17:13, Josh Allmann wrote: > > This patch is meant to be an entry point for discussion around an > > issue we are having with flushing the nvenc encoder while doing > > segmented transcoding. Hopefully there will be a less kludgey > > workaround than this. > > Hi Josh, > > I happened to see your email recently, and took a quick look into > this. It seems that encoders are allowed to implement .flush() and > then avcodec_flush_buffers() can be called on them like on a > decoder. So I've posted a patch that does this (with the same impl > that you had). If that works for you, then that's all it takes - > no need for a new API call because there's already one you can use. That would be perfect - thought .flush() was decode-only for some reason. Thank you! Josh
On Fri, 20 Dec 2019 at 19:03, Josh Allmann <joshua.allmann@gmail.com> wrote: > > On Fri, 20 Dec 2019 at 15:36, Philip Langdale <philipl@overt.org> wrote: > > > > On 2019-11-18 17:13, Josh Allmann wrote: > > > This patch is meant to be an entry point for discussion around an > > > issue we are having with flushing the nvenc encoder while doing > > > segmented transcoding. Hopefully there will be a less kludgey > > > workaround than this. > > > > Hi Josh, > > > > I happened to see your email recently, and took a quick look into > > this. It seems that encoders are allowed to implement .flush() and > > then avcodec_flush_buffers() can be called on them like on a > > decoder. So I've posted a patch that does this (with the same impl > > that you had). If that works for you, then that's all it takes - > > no need for a new API call because there's already one you can use. > > That would be perfect - thought .flush() was decode-only for some > reason. Thank you! > > Josh Related: For CLI usage, does this affect the behavior of the global output option -flush_packets 1 When the NVENC encoder is in use, in any way?
On Fri, 20 Dec 2019 19:12:00 -0500 Dennis Mungai <dmngaie@gmail.com> wrote: > On Fri, 20 Dec 2019 at 19:03, Josh Allmann <joshua.allmann@gmail.com> > > For CLI usage, does this affect the behavior of the global output > option > > -flush_packets 1 > > When the NVENC encoder is in use, in any way? It's unrelated. This is a muxer level (avio specific, in fact) option. It doesn't affect decoders or encoders. --phil
On Sat, 21 Dec 2019 at 07:12, Philip Langdale <philipl@overt.org> wrote: > > On Fri, 20 Dec 2019 19:12:00 -0500 > Dennis Mungai <dmngaie@gmail.com> wrote: > > > On Fri, 20 Dec 2019 at 19:03, Josh Allmann <joshua.allmann@gmail.com> > > > > For CLI usage, does this affect the behavior of the global output > > option > > > > -flush_packets 1 > > > > When the NVENC encoder is in use, in any way? > > It's unrelated. This is a muxer level (avio specific, in fact) option. > It doesn't affect decoders or encoders. > > --phil Thanks for the clarification.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index bcb931f0dd..763a557d82 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -6232,6 +6232,8 @@ const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); */ AVCPBProperties *av_cpb_properties_alloc(size_t *size); +int av_nvenc_flush(AVCodecContext *avctx); + /** * @} */ diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 111048d043..36134fa6a9 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2071,6 +2071,11 @@ static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame) } } +int attribute_align_arg av_nvenc_flush(AVCodecContext *avctx) +{ + return ff_nvenc_send_frame(avctx, NULL); +} + int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) { NVENCSTATUS nv_status;