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.

closed caption issue

Abdellatif_Khindouf1
760 Views
Hi,

We're trying to add closed caption data using the media SDK by attaching "mfxPayload" buffer to each frame, after calling "MFXVideoENCODE_EncodeFrameAsync" then "MFXVideoCORE_SyncOperation" method return a "MFX_ERR_UNKNOWN" error.

So could you please tell us how to send the closed caption data using the mfx encoder.


Regards.
0 Kudos
4 Replies
Gregory_S_Intel
Employee
760 Views
Hello Abdellatif
Do you encode into H.264 or MPEG2?
0 Kudos
Abdellatif_Khindouf1
760 Views
Hi,

I'm using the H.264 encoder.
0 Kudos
Petter_L_Intel
Employee
760 Views
Hi Abdellatif,

sorry for the late response. I'm assuming you are trying to insert the SEI messageuser_data_registered_itu_t_t35 into the stream to carry the closed captioning information?

If so, then using mfxPayload is the correct approach. Please see below for an example on how to insert custom SEI messages:

[cpp]#define SEI_USER_DATA_REGISTERED_ITU_T_T35  4
typedef struct
{
	unsigned char countryCode;
	unsigned char countryCodeExtension;
	unsigned char payloadBytes[2];  // In this example only two bytes of data
} userdata_reg_t35;

mfxEncodeCtrl m_encodeCtrl;
mfxPayload m_mySEIPayload;
mfxU8 m_seiData[100];
mfxPayload* m_payloads[5];
userdata_reg_t35 m_userSEIData;


// Insert SEI_USER_DATA_REGISTERED_ITU_T_T35 into payload
m_userSEIData.countryCode           = 10;
m_userSEIData.countryCodeExtension  = 11;
m_userSEIData.payloadBytes[0]       = 1;
m_userSEIData.payloadBytes[1]       = 2;

MSDK_ZERO_MEMORY(m_mySEIPayload);
m_mySEIPayload.Type    = SEI_USER_DATA_REGISTERED_ITU_T_T35;
m_mySEIPayload.BufSize = sizeof(userdata_reg_t35) + 2;  // 2 bytes for header
m_mySEIPayload.NumBit  = 4*8 + 2*8;  // data + header
m_mySEIPayload.Data    = m_seiData;
	
// SEI header
m_seiData[0] = (mfxU8)m_mySEIPayload.Type;
m_seiData[1] = (mfxU8)((m_mySEIPayload.NumBit - 16) >> 3); // size of following SEI message in bytes
// SEI message
memcpy(m_seiData+2, &m_userSEIData, sizeof(userdata_reg_t35));

m_payloads[0] = &m_mySEIPayload;

// Encode control structure initialization
MSDK_ZERO_MEMORY(m_encodeCtrl);
m_encodeCtrl.Payload = (mfxPayload**)&m_payloads[0];
m_encodeCtrl.NumPayload = 1;

// Use encode control structure while calling encode
sts = m_pmfxENC->EncodeFrameAsync(&m_pEncodeCtrl, &m_pEncSurfaces[nEncSurfIdx], &pCurrentTask->mfxBS, &pCurrentTask->EncSyncP);[/cpp]


Regards,
Petter
0 Kudos
Abdellatif_Khindouf1
760 Views
Hi Petter,

Thank you for your code example, it was very helpful. I'm now able to add closed caption data.

Regards,
Abdellatif
0 Kudos
Reply