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.
3058 Discussions

Cropping input frames before encoding causes MFX_ERR_INCOMPATIBLE_VIDEO_PARAM

Emmanuel_T_
Beginner
532 Views

Hi all,

I have been trying to crop input frames before encoding them. The current pipeline I've build consists of decode -> VPP -> encode. According to the developpers guide, I understand that this is possible with such values:

                   VPP Input                       VPP output

              W,H           X,Y,W,H         W,H       X,Y,W,H

Cropping 720x480 16,16,688,448 720x480 16,16,688,448

In my case, I tried this set of values.

VPPParams.vpp.In.Width=1920
VPPParams.vpp.In.Height=1088
VPPParams.vpp.In.CropW=960
VPPParams.vpp.In.CropH=544
VPPParams.vpp.Out.Width=1920
VPPParams.vpp.Out.Height=1088
VPPParams.vpp.Out.CropW=960
VPPParams.vpp.Out.CropH=544

However, I get an error MFX_ERR_INCOMPATIBLE_VIDEO_PARAM -14.

I did try other combinations without sucess. Can anyone confirm that's the right way to perform cropping operations? If not, is there a better way to do it?

Thanks !

 

 

 

0 Kudos
7 Replies
Anthony_P_Intel
Employee
532 Views

Hi,

I assume you are seeing that error from the "encode" request.  What are your parameters to Encoding input?

The surface output of VPP will be vpp.Out.Width and vpp.Out.Height, so using your parameters, the VPP step is still making a 1080p surface (with video content in the crop region).  This should work if encode input is 1920x1088 and you really desire a 1080p stream, but...

I suspect that what you are trying to do (create 960x544 stream), should look more like

VPPParams.vpp.In.Width=1920
VPPParams.vpp.In.Height=1088
VPPParams.vpp.In.CropW=960
VPPParams.vpp.In.CropH=544
VPPParams.vpp.Out.Width=960
VPPParams.vpp.Out.Height=544
VPPParams.vpp.Out.CropW=960
VPPParams.vpp.Out.CropH=544

and

EncParams.vpp.In.Width=960
EncParams.vpp.In.Height=544

0 Kudos
Emmanuel_T_
Beginner
532 Views

Hi Tony,

Thanks for your reply !

Yes, your assumption is correct. I try to create a 960x544 stream representing 1/4 of a 1080p stream. The values you are suggesting make more sense to me as well although the documentation seems to say otherwise to my understanding (p.18 Region of Interest in API 1.7). Hence my confusion.

So I'm going to test with these values (VPP + Enc) and I'll get back to you.

In the meantime, I was also wondering what was the purpose of the crop sizes in the encoder initialisation. The documentation says H.264 cropped frame size. Would it be then possible to achieve the same result without implementing a VPP component (in case of H.264 encoding)?

Thanks !

 

Emmanuel

0 Kudos
Emmanuel_T_
Beginner
532 Views

Hi Tony,

I have implemented the value you suggested.

At the initialisation step I have :

mfxDecParams.mfx.FrameInfo.Width=1920
mfxDecParams.mfx.FrameInfo.Height=1088
VPPParams.vpp.In.Width=1920
VPPParams.vpp.In.Height=1088
VPPParams.vpp.In.CropW=960
VPPParams.vpp.In.CropH=544
VPPParams.vpp.Out.Width=960
VPPParams.vpp.Out.Height=544
VPPParams.vpp.Out.CropW=960
VPPParams.vpp.Out.CropH=544
mfxEncParams.mfx.FrameInfo.Width=960
mfxEncParams.mfx.FrameInfo.Height=544
mfxEncParams.mfx.FrameInfo.CropW=960
mfxEncParams.mfx.FrameInfo.CropH=544

Which seems indeed what I want to achieve. Now the pipeline runs whitout error.

But the output bistream I have is just the 960x544 downscaled version of the 1080p input stream. It does not perform any cropping operation.

I further printed out some information during the DSK operations. Here they are :

// Decoded frames

pSurfaces[nIndex]->Info.Width=1920
pSurfaces[nIndex]->Info.Height=1088
pSurfaces[nIndex]->Info.CropW=1920
pSurfaces[nIndex]->Info.CropH=1080

// VPP configuration
par_vpp.vpp.In.Width=1920
par_vpp.vpp.In.Height=1088
par_vpp.vpp.In.CropW=960
par_vpp.vpp.In.CropH=544
par_vpp.vpp.Out.Width=960
par_vpp.vpp.Out.Height=544
par_vpp.vpp.Out.CropW=960
par_vpp.vpp.Out.CropH=544

// Encoded frames
pSurfaces2[nIndex2]->Info.Width=960
pSurfaces2[nIndex2]->Info.Height=544
pSurfaces2[nIndex2]->Info.CropW=960
pSurfaces2[nIndex2]->Info.CropH=544

Do you see what is wrong in this pipeline? Do I need to implement something in the SDK operations to make the cropping happen?

By the way, I still have this question about the documentation. What is the purpose of the crop sizes in the encoder initialisation. The documentation says H.264 cropped frame size, does it also perform a cropping operation?

Thanks a lot !

 


 

 

0 Kudos
Emmanuel_T_
Beginner
532 Views

Hi all,

Has anyone ever tried to crop input streams? I am still struggling with it, no matter the crop parameters I use, at best I have a downscaled version...

Any help/pointers would be appreciated !

Thanks,

Emmanuel

0 Kudos
Renit_S_
Beginner
532 Views

I also get Downscaling problem (For Letterbox and crop to fit mode). so I used Thirdparty codec for appropriate downscale conversion. And giving that buffer for encoding

0 Kudos
Gilles_V_
Beginner
532 Views

Hi all,

I have the exact same issue! When I try to crop, it will just resize the video using the cropping values. I am using FFmpeg for my tests, with all the decoding/vpp/encoding chain remaining as MFX_IOPATTERN_OUT_VIDEO_MEMORY memory. When I use a dummy FFmpeg soft filter (yadiff for instance), it then uses MFX_IOPATTERN_OUT_SYSTEM_MEMORY and the cropping works as expected.

Any clue ?

Thanks,

Gilles

0 Kudos
Gilles_V_
Beginner
532 Views

Hi again,

I found my problem, I was setting cropping at Init instead of doing it at runtime... it works now.

0 Kudos
Reply