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.

Two or more Encoders at the same time?

Fernando_B_
Beginner
2,148 Views

hi all,

I'm using Intel Media SDK and I want to know if it is possible to initializate two or more MfxVideoEncoders to be used at the same time... Currently, I can create one correctly but when the second is going to be created I get an error on the Init call returning a MFX_ERR_DEVICE_FAILED and I would like to know if this error is being or could be caused due to I have a MfxVideoEncoder already created.

Thanks in advance!

Fernando B.

0 Kudos
22 Replies
Fernando_B_
Beginner
1,982 Views

 

I add the System Analyzer info...

Intel Media SDK System Analyzer (32 bit)


The following versions of Media SDK API are supported by platform/driver:

        Version Target  Supported       Dec     Enc
        1.0     HW      Yes             X       X
        1.0     SW      Yes             X       X
        1.1     HW      Yes             X       X
        1.1     SW      Yes             X       X
        1.3     HW      Yes             X       X
        1.3     SW      Yes             X       X
        1.4     HW      Yes             X       X
        1.4     SW      Yes             X       X
        1.5     HW      Yes             X       X
        1.5     SW      Yes             X       X
        1.6     HW      Yes             X       X
        1.6     SW      Yes             X       X
        1.7     HW      Yes             X       X
        1.7     SW      Yes             X       X
        1.8     HW      No
        1.8     SW      Yes             X       X

Graphics Devices:
        Name                                         Version             State
        Intel(R) HD Graphics Family                  10.18.10.3379       Active

System info:
        CPU:    Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
        OS:     Microsoft Windows 8.1
        Arch:   64 bits

Installed Media SDK packages (be patient...processing takes some time):
        Intel« INDE Media SDK for Windows 6.0.0.308

Installed Media SDK DirectShow filters:

Installed Intel Media Foundation Transforms:
  Intel« Hardware M-JPEG Decoder MFT : {00C69F81-0524-48C0-A353-4DD9D54F9A6E}
  Intel« Quick Sync Video H.264 Encoder MFT : {4BE8D3C0-0515-4A37-AD55-E4BAE19AF471}

Analysis complete... [press ENTER]

Thanks,

Fernando B.

0 Kudos
Shaojuan_Z_Intel
Employee
1,982 Views

Hi Fernando,

Media SDK allows multiple encoding. You may take a look at sample_multi_transcode in our media samples (http://software.intel.com/en-us/intel-inde-support/code-samples) to understand how multiple transcodes are implemented there. Let us know if you have any further question. Thanks!

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi Shaojuan,

Thank you very much for your reply, I've look into that example but I cannot isolate the problem I have.

I'm constructing a Encoder/Decoder for H264, for several video streams. The problem I have is using the encoder in hardware mode when I want to create another encoder (for a different video stream). My encoder performs this:

mfxStatus status = _mfxENC->Init(&_mfxEncParams);

For the first video stream the encoder is initialized correctly, but when I want to create another one, the init method returns MFX_ERR_DEVICE_FAILED.

If I force the encoder to use software mode there is no problem initializing the second encoder.

do you know if I need to perform some type of modification to allow instantiate more than one MFXVideoENCODE ?

Thank you for your help.

Fernando.

 

0 Kudos
Shaojuan_Z_Intel
Employee
1,982 Views

Hi Fernando,

MediaSDK doesn't need special modification to allow multiple encodes. If possible, could you send us your code to understand why SW mode works but HW modes doesn't? Thanks!

0 Kudos
Shaojuan_Z_Intel
Employee
1,982 Views

Actually, before changing  your code, could you update to the latest graphics driver? Do you still see the same problem after updating? Thanks!

0 Kudos
OTorg
New Contributor III
1,982 Views

Actually, you can't normally utilize several MediaSDK encoder instances because of chance to get nonrecoverable exception at encoder core.

No matter, it's solely your application, or your + some third-party imsdk application.

See https://software.intel.com/en-us/forums/topic/475624?page=1#comment-1779278 topic.

Nothing has changed with the release of IMSDK 1.15 (INDE 2015 Update 2).

0 Kudos
Sravanthi_K_Intel
1,982 Views

Hi Fernando,

Please update the drivers as Shaojuan recommended and try the sample_multi_transcode. Media SDK can initialize multiple encoders at the same time, this is a supported configuration.

What the dj_alek is referring to is a different issue as compared to yours. So, please go ahead and update the drivers and see if that helps. Your system analyzer output at the top is showing the the HW implementation is not supported on 1.8 version on your system - updating the driver will fix this for you.

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi dj_alek,

Thanks for your response.

So, It is not possible use more than one encoder at the same time? As I commented before, I can use more than one in Software... do you know the reason about hardware mode?

 

0 Kudos
OTorg
New Contributor III
1,982 Views

Hardware had the same bug within previous imsdk versions, I didn't test 1.15-hw yet.

But as rightly said SRAVANTHI K., your current problem is different. Correct it, try to work, and only then bother Intel that your program isn't working again (from time to time).

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi SRAVANTHI,

I have just update the driver and now the analyzer shows that 1.8 version is supported. But the problem continues...

Intel Media SDK System Analyzer (32 bit)

The following versions of Media SDK API are supported by platform/driver:

        Version Target  Supported       Dec     Enc
        1.0     HW      Yes             X       X
        1.0     SW      Yes             X       X
        1.1     HW      Yes             X       X
        1.1     SW      Yes             X       X
        1.3     HW      Yes             X       X
        1.3     SW      Yes             X       X
        1.4     HW      Yes             X       X
        1.4     SW      Yes             X       X
        1.5     HW      Yes             X       X
        1.5     SW      Yes             X       X
        1.6     HW      Yes             X       X
        1.6     SW      Yes             X       X
        1.7     HW      Yes             X       X
        1.7     SW      Yes             X       X
        1.8     HW      Yes             X       X
        1.8     SW      Yes             X       X

Graphics Devices:
        Name                                         Version             State
        Intel(R) HD Graphics Family                  10.18.14.4170       Active

System info:
        CPU:    Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
        OS:     Microsoft Windows 8.1
        Arch:   64 bits

 

I have compiled the multi transcode: I have run it using this...

sample_multi_transcode -i::h264 c:\development\test.h264  -o::jpeg out.jpeg -hw

Is this using two ENCODERS?

Multi Transcoding Sample Version 5.0.491.98875

Pipeline surfaces number: 13
MFX HARDWARE Session 0 API ver 1.15 parameters:
Input  video: AVC
Output video: JPEG
MFX dll: C:\Program Files\Intel\Media SDK\libmfxhw32.dll

Session 0 was NOT joined with other sessions

Transcoding started

Return on error: error code -16,        src\pipeline_transcode.cpp      998


Transcoding finished

Common transcoding time is  0.02 sec
MFX session 0 transcoding FAILED:
Processing time: 0.02 sec
Number of processed frames: 0

The test FAILED

Return on error: error code 1,  src\sample_multi_transcode.cpp  501

sample_multi_transcode -i::h264 c:\development\test.h264  -o::mpeg2 out.mpeg2 -hw

This execution works.

My program still giving -17 error when the second encoder want to be initialized.

Thanks!

 

0 Kudos
Shaojuan_Z_Intel
Employee
1,982 Views

For jpeg transcode, you need to specify "-q" (quality parameter) in the command. "sample_multi_transcode -i::h264 c:\development\test.h264  -o::jpeg out.jpeg -hw" is not using two encoders. To learn more about executing multiple transcode sessions, please refer to "readme-multi-transcode" file included in the samples, which explains how to use a par file to execute multiple transcodes. Thanks!  

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi Shaojuan,

I tested multi transcode using a par file and it seems to be working, but I cannot get working my implementation creating a second encoder it still returning error -17...

Do you have any clue about what could be happening?

Thanks!

0 Kudos
diamantis__nikos
1,982 Views

Hello.

I'm trying to understand, how all of you expect a Haswell processor to encode JPEG in HW.

Haswell supports H.264 and MPEG2 HW encoding and SW encoding for JPEG.

 

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi Nikos,

No, we don't want to encode jpeg in HW. The issue is that using Intel Media SDK to encode/decode H264 I have a problem that when I create more than one encoder, I get the error MFX_ERR_DEVICE_FAILED. But Using the Multi transcoder example that it is supposed that use several encoders there is no problem.

So, we are trying to identify where could be the issue on creating more than one encoder in HW mode,due to in SW mode there is no problem.

Thanks!

0 Kudos
diamantis__nikos
1,982 Views

Hi.

The failing code you have published, doesn't have any H.264 encoding. It has only H.264 streams as source.

Your code has two encodings both in HW mode. One is MPEG2 encoding which succeeds and the other one is JPEG encoding which fails in HW.

You haven't published any code with H.264 as output. Only as input.

0 Kudos
Nina_K_Intel
Employee
1,982 Views

Hi Fernando,

As a guess: are you trying to create the second encoder with the same mfxSession? If so, it is not supported: one mfxSession can host only one component of each type (one decode, vpp or encode). So you need to create a new mfxSession first, then create the second encoder in this session.

Regards,

Nina

0 Kudos
Andrew_B_2
Beginner
1,982 Views

Hi Fernando,

Are you creating encoders in different threads?  Does anyone know if the API is thread safe?

Andy

0 Kudos
Fernando_B_
Beginner
1,982 Views

Hi Nina,

Yes, I checked that, but a new session is being created for each new instance of the encoder. The new session is created, then the encoder is created using the session and finally when the encoder is going to be initialized passing the params the second time it returns device failed error.

This is the way the encoder is being created...

mfxIMPL impl = MFX_IMPL_AUTO_ANY; // MFX_IMPL_SOFTWARE;
mfxVersion ver = { 0, 1 };

mfxStatus status = Initialize(impl, ver, &_mfxSession, &_mfxAllocator, true);
MSDK_CHECK_RESULT(status, MFX_ERR_NONE, status);

// Create Media SDK encoder
_mfxENC = new MFXVideoENCODE(_mfxSession);

and the session is defined --> MFXVideoSession _mfxSession; This is a class attribute.

and each enconder is being created.. MyEncoder enc = new MyEncoder(); So, each MyEncoder instance has its own Session. As I commented before, the first encoder creation works, and next ones fails, with error MFX_ERR_DEVICE_FAILED.

As I read in the documentation I understand that each session can manage an enconder, decoder and VPP. Currently, I'm creating together with the Encoder a VPP using the same session. This do not generate problems due to the first time it works.

Is there a way to correctly release resources?

Currently, I have added this...

if(_mfxENC != nullptr)
     _mfxENC->Close();
if(_mfxVPP != nullptr)
    _mfxVPP->Close();

_mfxSession.Close();

Also the Session is being initialized as follows....

mfxStatus Initialize(mfxIMPL impl, mfxVersion ver, MFXVideoSession* pSession, mfxFrameAllocator* pmfxAllocator, bool bCreateSharedHandles)
{
    mfxStatus sts = MFX_ERR_NONE;

#ifdef DX11_D3D
    impl |= MFX_IMPL_VIA_D3D11;
#endif

    // Initialize Intel Media SDK Session
    sts = pSession->Init(impl, &ver);
    MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);

#if defined(DX9_D3D) || defined(DX11_D3D)
    // If mfxFrameAllocator is provided it means we need to setup DirectX device and memory allocator
    if (pmfxAllocator) {
        // Create DirectX device context
        mfxHDL deviceHandle;
        sts = CreateHWDevice(*pSession, &deviceHandle, NULL, bCreateSharedHandles);
        MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);

        // Provide device manager to Media SDK
        sts = pSession->SetHandle(DEVICE_MGR_TYPE, deviceHandle);
        MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);

        pmfxAllocator->pthis  = *pSession; // We use Media SDK session ID as the allocation identifier
        pmfxAllocator->Alloc  = simple_alloc;
        pmfxAllocator->Free   = simple_free;
        pmfxAllocator->Lock   = simple_lock;
        pmfxAllocator->Unlock = simple_unlock;
        pmfxAllocator->GetHDL = simple_gethdl;

        // Since we are using video memory we must provide Media SDK with an external allocator
        sts = pSession->SetFrameAllocator(pmfxAllocator);
        MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
    }
#endif

    return sts;
}

 

 

Thanks!

0 Kudos
Nina_K_Intel
Employee
1,982 Views

To Fernando: thanks for confirming, wrong guess then :) I see you're using tutorials, could you please send us your modified code?

To Andy: the SDK APIs are thread safe.

0 Kudos
Shaojuan_Z_Intel
Employee
1,863 Views

Response transferred to private message.

0 Kudos
Reply