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.

RepeatPPS in qsv HEVC encoding

drquake_a_
Beginner
1,506 Views

hi, i'm using ffmpeg with qsv acceleration in hevc live encoding, on xeon e3-1585 v5. The problem I found is, mfxExtCodingOption2::RepeatPPS cannot be enabled on mfx initialization (saw that in ffmpeg debug log). It is ok for file encoding as the extra data is stored in file container header. But it brings problem to live stream encoding as the output stream cannot be decoded correctly by vlc player or other decoders. Is there solution for this or am I doing something wrong? Any help.

P.S. qsv accelerated h.264 encoding doesn't have such issue. RepeatPPS is enabled without problem.

0 Kudos
1 Solution
Stanley_W_
Beginner
1,506 Views

from mediasdk-man.pdf

when use H.264, you should set IdrInterval = 0;

when use HEVC, you should set IdrInterval = 1;

IdrInterval For H.264, IdrInterval specifies IDR-frame interval in terms of
I-frames; if
IdrInterval=0, then every I-frame is an IDR-frame.
If
IdrInterval=1, then every other I-frame is an IDR-frame, etc.
For HEVC, if
IdrInterval=0, then only first I-frame is an IDR
frame
. If
IdrInterval=1, then every I-frame is an IDR-frame. If
IdrInterval=2, then every other I-frame is an IDR-frame, etc.
For MPEG2,
IdrInterval defines sequence header interval in
terms of I-frames. If
IdrInterval=N, SDK inserts the sequence
header before every
Nth I-frame. If IdrInterval=0 (default),
SDK inserts the sequence header once at the beginning of the
stream.


 

View solution in original post

0 Kudos
9 Replies
drquake_a_
Beginner
1,506 Views

any body heeeeeeelp

0 Kudos
Mark_L_Intel1
Moderator
1,506 Views

Hi drquake,

Sorry for the late response, we are working on other projects and I didn't have a chance to check the forum questions.

I don't know too much detail about the FFmpeg integration and I doubt H.264 case is just the RepeatPPS was enabled by default. You might refer to the following code for help, this is the same code to dump the debug log mentioned in your post:

http://www.ffmpeg.org/doxygen/3.0/qsvenc_8c_source.html

This is the interface to integrate the ffmpeg parameters with MSDK. If you look at line 670, the function ff_qsv_enc_init(), it calls init_video_param() at line 710, I think you can modify it to add the RepeatPPS option.

Let me know if this helps.

Mark

0 Kudos
drquake_a_
Beginner
1,506 Views

Liu, Yan wrote:

Hi drquake,

Sorry for the late response, we are working on other projects and I didn't have a chance to check the forum questions.

I don't know too much detail about the FFmpeg integration and I doubt H.264 case is just the RepeatPPS was enabled by default. You might refer to the following code for help, this is the same code to dump the debug log mentioned in your post:

http://www.ffmpeg.org/doxygen/3.0/qsvenc_8c_source.html

This is the interface to integrate the ffmpeg parameters with MSDK. If you look at line 670, the function ff_qsv_enc_init(), it calls init_video_param() at line 710, I think you can modify it to add the RepeatPPS option.

Let me know if this helps.

Mark

Thank you very much for your kind support.

I have done some code trying to set RepeatPPS. But it doesn't work. Here is part of my code fix:

if (avctx->codec_id == AV_CODEC_ID_HEVC) {
    q->extco2.Header.BufferId     = MFX_EXTBUFF_CODING_OPTION2;
    q->extco2.Header.BufferSz     = sizeof(q->extco2);
    q->extco2.RepeatPPS = MFX_CODINGOPTION_ON;
    av_log(avctx, AV_LOG_INFO, "set RepeatPPS to ON\n");
}

And here is the ffmpeg output:

[hevc_qsv @ 059ce620] Using the constant bitrate (CBR) ratecontrol method
[hevc_qsv @ 059ce620] set RepeatPPS to ON
[hevc_qsv @ 059ce620] profile: simple; level: 30
[hevc_qsv @ 059ce620] GopPicSize: 248; GopRefDist: 9; GopOptFlag: closed ; IdrInterval: 0
[hevc_qsv @ 059ce620] TargetUsage: 4; RateControlMethod: CBR
[hevc_qsv @ 059ce620] InitialDelayInKB: 600; TargetKbps: 800; MaxKbps: 800
[hevc_qsv @ 059ce620] NumSlice: 1; NumRefFrame: 5
[hevc_qsv @ 059ce620] RateDistortionOpt: unknown
[hevc_qsv @ 059ce620] RecoveryPointSEI: unknown IntRefType: 0; IntRefCycleSize: 0; IntRefQPDelta: 0
[hevc_qsv @ 059ce620] MaxFrameSize: 0; MaxSliceSize: 0;
[hevc_qsv @ 059ce620] BitrateLimit: unknown; MBBRC: ON; ExtBRC: unknown
[hevc_qsv @ 059ce620] Trellis: auto
[hevc_qsv @ 059ce620] RepeatPPS: OFF; NumMbPerSlice: 0; LookAheadDS: unknown
[hevc_qsv @ 059ce620] AdaptiveI: unknown; AdaptiveB: unknown; BRefType: pyramid
[hevc_qsv @ 059ce620] MinQPI: 0; MaxQPI: 0; MinQPP: 0; MaxQPP: 0; MinQPB: 0; MaxQPB: 0
[hevc_qsv @ 059ce620] Main profile bitstream
[hevc_qsv @ 059ce620] Decoding VUI

You can see clearly that although my code set RepeatPPS to MFX_CODINGOPTION_ON, the final param retrieved from qsv api after init_video_param() shows RepeatPPS is OFF anyway. That causes the problem I described above.

Is it a qsv bug or is my code wrong?

0 Kudos
Ramashankar
New Contributor III
1,506 Views

Hi drquake,

if (avctx->codec_id == AV_CODEC_ID_HEVC) {
    q->extco2.Header.BufferId     = MFX_EXTBUFF_CODING_OPTION2;
    q->extco2.Header.BufferSz     = sizeof(q->extco2);
    q->extco2.RepeatPPS = MFX_CODINGOPTION_ON;
    av_log(avctx, AV_LOG_INFO, "set RepeatPPS to ON\n");
}

Though it seems obvious but still wanted to confirm: In above code, after setting the RepeatPPS to ON, are you pushing this setting structure in extended param list also? 

m_EncExtParams.push_back((mfxExtBuffer *)&q->extco2);

If not, then it could be the reason why it was still not enabled.

 

0 Kudos
drquake_a_
Beginner
1,507 Views

Ramashankar wrote:

Hi drquake,

if (avctx->codec_id == AV_CODEC_ID_HEVC) {
    q->extco2.Header.BufferId     = MFX_EXTBUFF_CODING_OPTION2;
    q->extco2.Header.BufferSz     = sizeof(q->extco2);
    q->extco2.RepeatPPS = MFX_CODINGOPTION_ON;
    av_log(avctx, AV_LOG_INFO, "set RepeatPPS to ON\n");
}

Though it seems obvious but still wanted to confirm: In above code, after setting the RepeatPPS to ON, are you pushing this setting structure in extended param list also? 

m_EncExtParams.push_back((mfxExtBuffer *)&q->extco2);

If not, then it could be the reason why it was still not enabled.

 

Thanks for your anwer.

No I don't use push_back() to validate extended param. Because ffmpeg code is in c not in c++.

The question is, if I choose h.264 encoding, my code can set RepeatPPS to either On or OFF with no problem. But if I choose hevc encoding, RepeatPPS can only be OFF whatever I code. So I'm guessing it's a limit of qsv or something.

0 Kudos
drquake_a_
Beginner
1,507 Views

Any updates?

Are there intel qsv supports/experts in this forum?

0 Kudos
Stanley_W_
Beginner
1,507 Views

from mediasdk-man.pdf

when use H.264, you should set IdrInterval = 0;

when use HEVC, you should set IdrInterval = 1;

IdrInterval For H.264, IdrInterval specifies IDR-frame interval in terms of
I-frames; if
IdrInterval=0, then every I-frame is an IDR-frame.
If
IdrInterval=1, then every other I-frame is an IDR-frame, etc.
For HEVC, if
IdrInterval=0, then only first I-frame is an IDR
frame
. If
IdrInterval=1, then every I-frame is an IDR-frame. If
IdrInterval=2, then every other I-frame is an IDR-frame, etc.
For MPEG2,
IdrInterval defines sequence header interval in
terms of I-frames. If
IdrInterval=N, SDK inserts the sequence
header before every
Nth I-frame. If IdrInterval=0 (default),
SDK inserts the sequence header once at the beginning of the
stream.


 

0 Kudos
Stanley_W_
Beginner
1,507 Views

information from mediasdk-man.pdf

        For HEVC, 
        if IdrInterval=0, then only first I-frame is an IDRframe. 
        If IdrInterval=1, then every I-frame is an IDR-frame. 
        If IdrInterval=2, then every other I-frame is an IDR-frame, etc

        For H.264, IdrInterval specifies IDR-frame interval in terms of I-frames; 
        if IdrInterval=0, then every I-frame is an IDR-frame.
        If IdrInterval=1, then every other I-frame is an IDR-frame, etc.

 

 

0 Kudos
drquake_a_
Beginner
1,507 Views

Stanley W. wrote:

from mediasdk-man.pdf

when use H.264, you should set IdrInterval = 0;

when use HEVC, you should set IdrInterval = 1;

IdrInterval
For H.264, IdrInterval specifies IDR-frame interval in terms of
I-frames; if IdrInterval=0, then every I-frame is an IDR-frame.
If IdrInterval=1, then every other I-frame is an IDR-frame, etc.
For HEVC, if IdrInterval=0, then only first I-frame is an IDR
frame
. If IdrInterval=1, then every I-frame is an IDR-frame. If
IdrInterval=2, then every other I-frame is an IDR-frame, etc.
For MPEG2, IdrInterval defines sequence header interval in
terms of I-frames. If IdrInterval=N, SDK inserts the sequence
header before every Nth I-frame. If IdrInterval=0 (default),
SDK inserts the sequence header once at the beginning of the
stream.

 

You are super! Works like a charm

Still curious why RepeatPPS doesn't work for hevc though...

0 Kudos
Reply