[FFmpeg-devel] [PATCH 5/8] lavc/nvenc: Add hardware config metadata

Dennis Mungai dmngaie at gmail.com
Mon Apr 13 19:48:14 EEST 2020


On Mon, 13 Apr 2020 at 18:34, Mark Thompson <sw at jkqxz.net> wrote:

> NOT TESTED.
> ---
> Needs someone with suitable hardware to try it.
>
> With this and the relevant ffmpeg patches, existing stuff should continue
> to work and you should also be able to choose between multiple devices for
> a standalone encoder with things like:
>
> ffmpeg -init_hw_device cuda:2 ... -c:v nvenc ...
> ffmpeg -init_hw_device d3d11:2 ... -c:v nvenc ...
>
>
>  libavcodec/nvenc.c      | 11 +++++++++++
>  libavcodec/nvenc.h      |  1 +
>  libavcodec/nvenc_h264.c |  1 +
>  libavcodec/nvenc_hevc.c |  1 +
>  4 files changed, 14 insertions(+)
>
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index 9a96bf2bba..b0cd8874ee 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -30,6 +30,7 @@
>  #include "libavutil/avassert.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/pixdesc.h"
> +#include "hwconfig.h"
>  #include "internal.h"
>
>  #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x)
> @@ -55,6 +56,16 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
>      AV_PIX_FMT_NONE
>  };
>
> +const AVCodecHWConfigInternal *ff_nvenc_hw_configs[] = {
> +    HW_CONFIG_ENCODER_FRAMES(CUDA,  CUDA),
> +    HW_CONFIG_ENCODER_DEVICE(NONE,  CUDA),
> +#if CONFIG_D3D11VA
> +    HW_CONFIG_ENCODER_FRAMES(D3D11, D3D11),
> +    HW_CONFIG_ENCODER_DEVICE(NONE,  D3D11),
> +#endif
> +    NULL,
> +};
> +
>  #define IS_10BIT(pix_fmt)  (pix_fmt == AV_PIX_FMT_P010    || \
>                              pix_fmt == AV_PIX_FMT_P016    || \
>                              pix_fmt == AV_PIX_FMT_YUV444P16)
> diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
> index c44c81e675..c80332d914 100644
> --- a/libavcodec/nvenc.h
> +++ b/libavcodec/nvenc.h
> @@ -217,5 +217,6 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx,
> AVPacket *pkt,
>  void ff_nvenc_encode_flush(AVCodecContext *avctx);
>
>  extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
> +extern const AVCodecHWConfigInternal *ff_nvenc_hw_configs[];
>
>  #endif /* AVCODEC_NVENC_H */
> diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
> index 479155fe15..6d82422308 100644
> --- a/libavcodec/nvenc_h264.c
> +++ b/libavcodec/nvenc_h264.c
> @@ -248,4 +248,5 @@ AVCodec ff_h264_nvenc_encoder = {
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .pix_fmts       = ff_nvenc_pix_fmts,
>      .wrapper_name   = "nvenc",
> +    .hw_configs     = ff_nvenc_hw_configs,
>  };
> diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
> index 7c9b3848f1..58d5265977 100644
> --- a/libavcodec/nvenc_hevc.c
> +++ b/libavcodec/nvenc_hevc.c
> @@ -206,4 +206,5 @@ AVCodec ff_hevc_nvenc_encoder = {
>      .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .wrapper_name   = "nvenc",
> +    .hw_configs     = ff_nvenc_hw_configs,
>  };
> --
> 2.25.1
>
>
>
What type of hardware is considered "suitable"? Systems with multiple
NVENC-capable GPUs?
Also, provide a sample command line extending on the examples above that
you'd like tested and I'll report back with results.

Regards,

Dennis.


More information about the ffmpeg-devel mailing list