Measuring and graphing I-frame gaps in videos

I’ve been mired in IPTV related work for a while now, popping my head up occasionally to grab a breath and take a look at some other neglected things in my day-to-day job. It isn’t long before I’m back into it though, and all the time I’m picking up more knowledge about the world of TV.

One thing that was brought to me recently was some failures related to a network PVR system having trouble ingesting encrypted video content. According to the support team for the software, I-frames in the content were too far apart to ingest properly. The person working on the issue at our company was interested in seeing just how far apart they were, so I set to creating a little script to do just that.

It turned out to be relatively simple using ffprobe, which is part of the ffmpeg suite. Using that data, it’s then possible to plot the I-frame gaps with gnuplot.


I-Frame gaps

The script below will take the video filename as an argument, then output tab delimited data appropriate for use with gnuplot. It looks for I-frames, grabs the relevant fields (pkt_dts_time and coded_picture_number), concatenates and formats them, then does some simple calculations using the time. ffprobe is capable of doing some of the filtering done here, but this was a quick and dirty method.

This will create gnuplot compatible data that can then be graphed. For example,

The output of that script can be redirected to a file, then used with the following gnuplot script to create the graph seen above.

Putting that all together, the following will output plot.png for you to view.

2 thoughts on “Measuring and graphing I-frame gaps in videos

  1. Oren



    I’m trying to trace your BASH, SED and AWK commands using Windows findstr to replicate your plot.dat formation, so far miserably unsuccessfully :\

    Could you please share your final plot.dat document?



    Thank you,



Leave a Reply

Your email address will not be published. Required fields are marked *