2

I am using nvenc to encode a series of frames to a h.264 video on the GPU. My example is quite synthetic where I simply repeat the same frame. The encoding works fine and I was looking at figuring out what is going on:

One thing I notice is that the beginning frame is an IDR frame (NV_ENC_PIC_TYPE_IDR) and the rest of the frames are all forward predicted frames (NV_ENC_PIC_TYPE_P). I thought this is perhaps because every frame is the same. So, I generated frames where each frame is completely random. In that case, it is the same as well.

So, my question is whether there is something in the configuration which makes all the frames P-frames and there are no B or I frames. Under what conditions would these frames be generated?

Luca
  • 10,458
  • 24
  • 107
  • 234
  • 1
    What was your expectation? IDR frames are at the start of each GOP (Group of pictures). A GOP can be 2 seconds of video data (~50 frames). But everything is configurable most likely. Same with B pictures. If you configure the encoder in a profile/level what does not allow B pictures there won't be any. – Florian Zwoch Oct 14 '16 at 19:51
  • Well, I have about 2000 frames and I did not see any, which is why I was asking. I must say I am not very aware of the H.264 format. I will look into the default nvidia API and see what is going on... – Luca Oct 14 '16 at 20:01
  • 1
    In theory it is possible to configure the encoder to never insert any IDR frames. However this seems like a very unusual configuration. I'd say it is unlikely a default preset set this as it makes random access a real pain. So check your GOP length or Key frame interval - not sure how it is called in this API. – Florian Zwoch Oct 14 '16 at 20:04
  • @FlorianZwoch Ok, I looked a bit in more detail in the democode and I see this line: `gop_length = NVENC_INFINITE_GOPLENGTH`. Is there any vase when this should be set like that? As you say, otherwise to do random access, I will have to decode from the beginning of the file rather than the last IDR frame? – Luca Oct 16 '16 at 10:53
  • 1
    Yes, this one looks odd. It may make sense if you have a regular video with clear scene cuts in it. And if the encoder is then allowed to start a new GOP at the new scene you can get away with it - depending on your scene and use case of the video. Streamable solutions usually insert an IDR frame every two seconds. And additionally in case of a scene cut where it may makes sense to insert another one as well. – Florian Zwoch Oct 16 '16 at 11:12
  • Thanks a lot. I will change this to make it insert an IDR frame every second. This should be fine for my purposes. If you want to write an answer, please do. – Luca Oct 16 '16 at 11:41
  • 1
    If it helped you - thats enough virtual points for me. A proper answer seems like too much for for me now ;-) – Florian Zwoch Oct 16 '16 at 14:35

0 Answers0