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

Reset EncoderParam failed(return MFX_ERR_INVALID_VIDEO_PARAM)

Jetsen_W_
Beginner
385 Views

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?

0 Kudos
1 Reply
Jetsen_W_
Beginner
385 Views

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

http://software.intel.com/en-us/forums/topic/505598

0 Kudos
Reply