[FFmpeg-devel] [PATCH] nvenc: implement flush to help allow an encoder to be re-used

Josh Allmann joshua.allmann at gmail.com
Thu Jan 9 00:31:05 EET 2020


On Mon, 30 Dec 2019 at 16:40, Philip Langdale <philipl at overt.org> wrote:
>
> On Sat, 21 Dec 2019 14:54:38 -0800
> Philip Langdale <philipl at overt.org> wrote:
>
> > On Fri, 20 Dec 2019 16:07:18 -0800
> > Josh Allmann <joshua.allmann at gmail.com> wrote:
> >
> > > One concern I had was about the long-term stability of this
> > > behavior. Right now, it works, but perhaps only coincidentally?
> > > Being flushable and resumable like this isn't explicitly part of
> > > the "contract" for nvenc, as far as I can see. Could future changes
> > > inadvertently introduce state that isn't reset in between flushes,
> > > breaking the resumable behavior? If so, is there a way to safeguard
> > > against that?
> > >
> > > Josh
> >
> > So, the behaviour at the ffmpeg level is something you can view as
> > stable. If it was to break, I'd expect us to fix it. For nvenc itself,
> > that's harder to make any statements about. I wouldn't expect the
> > nvidia folks to change thing casually, but until they document a
> > specific flush behaviour, there's always going to be a risk -
> > ultimately we just have to react if they change something.
> >

Hi Phil,

Flushing and resumption is documented/supported in nvenc via
NV_ENC_FLAGS_EOS, but I wasn't sure if this was a feature that
ffmpeg's integration was intentionally designed for. But if you
confirm we can expect this behavior to be supported going forward,
then that's great news.

> > In an ideal world, you'd have a test running for this, but we're not
> > set up to exercise any hwaccels in our automated fate executions.
> >

We do have internal tests [1]  that should catch the issue if anything
changes, so that might be of some help as well, although we currently
only update ffmpeg on an as-needed basis.

[1] https://github.com/livepeer/lpms/blob/master/ffmpeg/nvidia_test.go

> > Did this form of the patch work for you?
> >
>
> Hi Josh,
>
> Did you get a chance to try it?
>
> --phil

Was delayed on testing this due to the holidays, my apologies.

Can confirm that this patch works very nicely in conjunction with
avcodec_flush_buffers . Thanks so much!

Josh


More information about the ffmpeg-devel mailing list