1
우리는 NVIDIA가 제공 한 샘플과 비슷한 라이브러리를 사용하고 있습니다. 그러나 예제는 단일 GPU 시나리오 용으로 설계되었습니다.GPU 장치 ID를 NVENC에 전달하는 방법
우리 서버에는 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'라는 태그가 필요합니다. 존재하지 않는 것 같아요. –