Search code examples
rtmptcpdump

How to tell if a frame is a KEY frame in RTMP stream


I use a third party server that emits RTMP stream but I don't have full control over that server.

However, I can still make it emit a rtmp stream to any location of my choice.

I was told by the third party that the key frame rate they are emitting is at least 1 per second. But i just want to verify that myself

I tried to use tcpdump to inspect my incoming RTMP stream.

But I wonder how i can tell if a packet contains a keyframe? And how do I tell the frequency at which the key frames are arriving to my server?


Solution

  • I was able to set up a nginx-rtmp server according to the tutorial here to reflect the third party stream.

    And then use ffprobe to get the key frames.

    ./ffprobe -select_streams v -show_frames -show_entries frame=pict_type -of csv rtmp://<server>/live/<stream-name> | grep -n I 
    

    This commandline will output an index, and then a frame which contains keyword "I". According to wikipedia, an "I" frame is basically the key frame.