h264_qsv did't take pix_fmt AV_PIX_FMT_BGRA

h264_qsv did't take pix_fmt AV_PIX_FMT_BGRA

Hello,

I have a hardware i9-9900k with widows 10 sdk.

I have installed Media SDK 2019R1.

ffmpeg latest 4.2 sdk.

My problem is when I set pix_fmt = nv12, avcodec_open2 returns the 0 value. But if I set pix_fmt AV_PIX_FMT_BGRA it returns -22.

Please help me why it didn't support AV_PIX_FMT_BGRA.

In sample code of Intel encode it is support bgra format.

    AVBufferRef *encode_device = NULL;

   AVCodecContext * Codec_Context_GPU;
    int ret = 0;
    const AVCodec *codec;
    avcodec_register_all();
    AVHWDeviceType Device_Type = AV_HWDEVICE_TYPE_QSV;     

    ret = av_hwdevice_ctx_create(&encode_device, Device_Type , NULL, NULL, 0);   

    codec = avcodec_find_encoder_by_name("h264_qsv");   

    Codec_Context_GPU = avcodec_alloc_context3(codec);
   
    Codec_Context_GPU->bit_rate = 2000000;                                          
    Codec_Context_GPU->width = 1920;
    Codec_Context_GPU->height = 1080;    

    Codec_Context_GPU->framerate.num = 25;
    Codec_Context_GPU->framerate.den = 1;   
    Codec_Context_GPU->time_base.num = Codec_Context_GPU->framerate.den;
    Codec_Context_GPU->time_base.den = Codec_Context_GPU->framerate.num; 
    Codec_Context_GPU->hw_device_ctx = av_buffer_ref(encode_device);       
    Codec_Context_GPU->pix_fmt = AV_PIX_FMT_NV12;//AV_PIX_FMT_BGRA;//AV_PIX_FMT_NV12;

    ret = avcodec_open2(Codec_Context_GPU, codec, NULL);
    if (ret < 0)
    {
        LogException(L"Could not open codec: %s\n");
    }

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.