我正在编写应用程序使用在PC上使用多个图形处理器,我试图获得一个图形处理器索引列表,可以解码流在h264中,以分配所有新的视频源平等地在所有可用的图形处理器之间。
我已经找到了如何在命令提示符中执行此操作,但我需要在c++中编写属于它的行
ffmpeg -vsync 0 -i input.mp4 -c:v h264_nvenc -gpu list -f null –
我需要它动态地将它传递给av_hwdevice_ctx_create(AVBufferRef**,char *int)
有人知道怎么做吗?
发布于 2020-06-04 18:36:27
据我所知,您不需要显式地将设备传递给
av_hwdevice_ctx_create (
AVBufferRef ** device_ctx,
enum AVHWDeviceType type,
const char * device,
AVDictionary * opts,
int flags
)
device_ctx
可以是空的,因为它是在这里创建的。你只需要知道你想要的类型。例如AV_HWDEVICE_TYPE_CUDA
。其余参数可以为空或0。至少在hw_decode example中是这样做的
static AVBufferRef *hw_device_ctx = NULL;
//...
static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type)
{
int err = 0;
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
NULL, NULL, 0)) < 0) {
fprintf(stderr, "Failed to create specified HW device.\n");
return err;
}
ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
return err;
}
(注意:我自己还没有用过这个函数。我只是根据示例中的实现方式来回答问题。)
https://stackoverflow.com/questions/62151289
复制相似问题