- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used MSDK 2013 R3 for Linux on Ubuntu 1204.
I wanted to change the bitrate in encoding, when I use the Reset function, I got the error code(-15)
int VideoEncoderIntel::ChangeVideoBitrate(uint16_t bitrate_kb) {
mfxStatus sts = MFX_ERR_NONE;
while (MFX_ERR_NONE <= sts && MFX_ERR_MORE_DATA != sts) {
sts = FlushEncoder();
if (MFX_ERR_NONE == sts) {
.... handle packet....
} else if (MFX_ERR_MORE_DATA == sts) {
mfxVideoParam oldParam;
memset(&oldParam, 0, sizeof(oldParam));
mfxStatus status = m_pmfxENC->GetVideoParam(&oldParam);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, status);
oldParam.mfx.TargetKbps = bitrate_kb;
sts = m_pmfxENC->Reset(&oldParam);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
break;
}
}
return sts;
}
mfxStatus VideoEncoderIntel::FlushEncoder() {
mfxStatus sts = MFX_ERR_NONE;
// while (MFX_ERR_NONE <= sts)
for (;;) {
sts = m_pmfxENC->EncodeFrameAsync(NULL, NULL, &m_mfxBS, &m_mfxEncSyncp);
if (MFX_ERR_NONE < sts && !m_mfxEncSyncp) // Repeat the call if warning and no output
{
if (MFX_WRN_DEVICE_BUSY == sts) {
u::Log::write(get_log_file(), "Busy!\n");
usleep(1000); // Wait if device is busy, then repeat the same call
}
}
else if (MFX_ERR_NONE < sts && m_mfxEncSyncp)
{
sts = MFX_ERR_NONE; // Ignore warnings if output is available
break;
}
else if (MFX_ERR_NOT_ENOUGH_BUFFER == sts)
{
// Allocate more bitstream buffer memory here if needed...
sts = AllocateSufficientBuffer(&m_mfxBS);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
else if (MFX_ERR_MORE_DATA == sts)
{
// printf("MORE DATA!\n");
break;
} else
{
break;
}
}
if(MFX_ERR_NONE == sts)
{
sts = m_mfxSession.SyncOperation(m_mfxEncSyncp, 60000); // Synchronize. Wait until encoded frame is ready
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
return sts;
}
Is there anything wrong?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I turn off NalHrdConformance in my program(NalHrdConformance = MFX_CODINGOPTION_OFF), and Reset() function return success, but the output stream seems contain the old bitrate in CBR mode, as described in this topic
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page