closed caption issue

closed caption issue

Abdellatif Khindouf's picture

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.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Gregory Shimansky (Intel)'s picture

Hello Abdellatif Do you encode into H.264 or MPEG2?

Abdellatif Khindouf's picture

Hi,

I'm using the H.264 encoder.

Petter Larsson (Intel)'s picture

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:

#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);

Regards, Petter

Abdellatif Khindouf's picture

Hi Petter,

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

Regards,
Abdellatif

Login to leave a comment.