【问题标题】:How to pass GPU Device ID to NVENC如何将 GPU 设备 ID 传递给 NVENC
【发布时间】:2013-08-17 08:49:38
【问题描述】:

我们使用的库与 NVIDIA 提供的示例大致相似。但是,这些示例是为单 GPU 场景设计的。

在我们的服务器上,我们有 8 个 Kepler K10 GPU,我们希望将参数作为设备 ID 作为输入传递,然后将其传递给库中的 NVENC API。有什么办法吗?

这里是初始化函数:

static av_cold int NVENC_init(AVCodecContext *avctx)
{

        NVENCContext *x4 = avctx->priv_data;

        x4->p_nv264IntefaceCtxt = (nv264InterfaceCtxt *)av_malloc(sizeof(nv264InterfaceCtxt));

        x4->p_nv264IntefaceCtxt->width       = avctx->width;
        x4->p_nv264IntefaceCtxt->height      = avctx->height;
        if (avctx->bit_rate) {
                x4->p_nv264IntefaceCtxt->avgBitRate  = avctx->bit_rate;
        }else
        {
                x4->p_nv264IntefaceCtxt->avgBitRate = 128000;
        }
        x4->p_nv264IntefaceCtxt->peakBitRate = 1.1*(x4->p_nv264IntefaceCtxt->avgBitRate);
        if (avctx->gop_size >= 0)
        {
                x4->p_nv264IntefaceCtxt->gopLength = avctx->gop_size;
        }
        else
        {
                x4->p_nv264IntefaceCtxt->gopLength = 30;
        }

        x4->p_nv264IntefaceCtxt->frameRateNum = x4->frameRateNum ;
        x4->p_nv264IntefaceCtxt->frameRateDen = x4->frameRateDen;
        x4->p_nv264IntefaceCtxt->rc_mode = x4->rc_mode;
        x4->p_nv264IntefaceCtxt->idr_period = x4->p_nv264IntefaceCtxt->gopLength;
        x4->p_nv264IntefaceCtxt->insertSEIMessage = x4->insertSEIMessage;
        x4->p_nv264IntefaceCtxt->cabacenable      = x4->cabacenable;
        x4->p_nv264IntefaceCtxt->profile          = x4->profile;
        x4->p_nv264IntefaceCtxt->gpu_number       = x4->gpu_number;

        x4->opStreamBufAllocSize = (avctx->width) * (avctx->height);
        x4->p_opStream = (unsigned char *)malloc(x4->opStreamBufAllocSize*sizeof(unsigned char));
        if(NULL == x4->p_opStream)
        {
                return -1;
        }

        if(0 != nv264Enc_Init(x4->p_nv264IntefaceCtxt))
        {
                return -1;
        }

        // copy the extradate to appropriate structure
        if ((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) && (x4->p_nv264IntefaceCtxt->spsSize > 0)) {
                uint8_t *p;

                avctx->extradata = p = av_malloc(x4->p_nv264IntefaceCtxt->spsSize);
         memcpy(p,x4->p_nv264IntefaceCtxt->spsbuffer,x4->p_nv264IntefaceCtxt->spsSize);
                avctx->extradata_size = x4->p_nv264IntefaceCtxt->spsSize;
        }
        return 0;
}

【问题讨论】:

  • 我建议你用 CUDA 以外的东西来标记它。
  • @RobertCrovella 我们需要一个标签“nvenc”,我认为它不存在。

标签: encoding gpu nvidia


【解决方案1】:

检查 nv264Enc_Init(x4->p_nv264IntefaceCtxt)) 函数。

你的答案就在这个函数中。 :)

【讨论】:

    猜你喜欢
    • 2012-11-26
    • 2021-03-14
    • 2014-06-28
    • 2015-08-13
    • 2011-11-08
    • 1970-01-01
    • 2016-03-24
    • 2020-09-29
    • 2019-04-08
    相关资源
    最近更新 更多