Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

h264_qsv did't take pix_fmt AV_PIX_FMT_BGRA

Sheth__Dhrumil
Beginner
1,633 Views

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");
    }

0 Kudos
1 Solution
Mark_L_Intel1
Moderator
1,633 Views

Hi Dhrumil,

In case of MSDK sample code, it supports BGRA because it configures the color conversion function of VPP at the output of debug. The decoder as an independent module can only output NV12.

Hope this helps.

Mark

View solution in original post

0 Kudos
4 Replies
Mark_L_Intel1
Moderator
1,634 Views

Hi Dhrumil,

In case of MSDK sample code, it supports BGRA because it configures the color conversion function of VPP at the output of debug. The decoder as an independent module can only output NV12.

Hope this helps.

Mark

0 Kudos
Sheth__Dhrumil
Beginner
1,633 Views

Thanks Liu Mark for reply. 

Can I take BGRA Raw frame into ffmpeg encoder using vpp?

If yes, Could you provide sample code for that.

Thanks

0 Kudos
Mark_L_Intel1
Moderator
1,633 Views

Hi Dhrumil,

I don't use ffmpeg a lot and this forum is for Media SDK only, but I found following command, I hope useful:

> ffmpeg -init_hw_device qsv=qsv:MFX_IMPL_hw_any -hwaccel qsv -filter_hw_device qsv -vcodec h264_qsv -i input-file -acodec aac -ac 2 -b:a 48k -vcodec h264_qsv -b:v 2000k -vf "hwupload=extra_hw_frames=10,scale_qsv=960:720" -g 25 -r 25.0 -f flv > output-file

I got this from following post:

https://lists.ffmpeg.org/pipermail/ffmpeg-user/2018-June/040279.html

Let me know if this helps.

Mark

0 Kudos
Sheth__Dhrumil
Beginner
1,633 Views

Thanks for reply Liu,

This is a ffmpeg command line (File based) for intel qvc. We need stream based ffmpeg code lines just like mention above.

Once again thanks for  try to find out ffmpeg lines.

0 Kudos
Reply