The Importance & My Recommended Usage of I-Frame, CBR vs VBR, Shutter Speed In Your Configurations

Wildcat_1

Known around here
Dec 9, 2018
2,129
6,092
US
All

I've been asked about these 3 areas many times and even more so lately, so thought I would create a post (started small but you know me, I then decided I needed to add more information).
Therefore with that said, I wanted to share my input, perspective and recommendations here on these topics. I've broken this down into sections and if people want more technical then just DM me, don’t want to bore everyone. Apologies for the longer post.


I-Frames & Frames Within A Stream in General

Breaking down a stream, you have 3 types of frames (I, P, B). These become important when you’re talking about video compression. I’ve shared codec usage, make-up, how they work and my recommendations in the past so won’t rehash that here. The key though is to understand what frame plays what role. I-Frames (Intra Frames) are Key Frames (for those that have been around video for a long time), consist of macro blocks and are focused on intra prediction (basically focusing on matching blocks only within the the same frame). They do not offer temporal prediction which is limited to P-Frames (Predicted Frames referring to previously encoded images) that can also be used for spatial prediction too. B-Frames (Bi-directional frames can reference frames that take place before or after them). Important to point out that the H.264 codec does use macro block based compression (if people weren’t aware or hadn’t seen the previous posts)

I-Frames are used as reference points compared to other frames in the stream and generally mark the end of the GOP (group of pictures) or segmented video portion. Their primary impact (most peoples first thought) is to bandwidth, secondary is picture quality (this is of more importance to me with CCTV operations and deployments). The simplest way to look at these are, lower I-Frame interval (closer to 1 in your GUI for example), the more frequent the I-Frames and the higher the image quality (subjective to some BUT is a fact) but you also increase bandwidth requirements. Higher the I-Frame interval (further away from 1 for example), lower the frequency of I-Frames and image quality will be lower as will bandwidth. This however is also dependent on camera, codec and most importantly the subject or target. If you have fast moving objects you will almost always benefit from more I-Frames regardless of impact to storage / bandwidth (which as I mention below, you can plan for proactively).

The reason for matching your I-Frame interval to FPS (or if you see it as increasing I-Frames in general) is that you increase the opportunity for better quality frames within your capture as you are setting a ‘full image capture’ for every frame you are recording. Remember that I-Frames do not rely on previously encoded frames, only working within the same frame, this is what allows them to improve and maintain overall stream quality. The encoder you’re using (with associated codec) then utilizes I-Frames as reference (as I mentioned above) when encoding the Predicted (P-Frame) and Bi-drectional (B-Frame). As mentioned many times before, this DOES increase your bandwidth used BUT isn’t necessarily catastrophic (multi cam deployments of course do add up) for most well dialed in systems where you are focused on a crisp IVS rule (OR AI if you’re using that) critically only capturing real targets for a set period of time within the FOV. Also we have to remember as I and others have stated on many occasions, storage is ‘relatively’ cheap and certainly no one should be in a situation where they are looking to save on storage space at the expense of securing ID related captures. This is a critical part of CCTV deployment planning, live and historic retention of captured footage, and should be figured into your project plan whether it’s residential, commercial or even government related.

As I eluded to above, this is even more impactful in busy, high traffic FOV’s where artifacting can increase when using less I-Frames and can be incredibly important for special application work (ALPR/Face Recognition etc). In the case of ALPR/ANPR and facial recognition for example, matching (or exceeding in some cases) the number of I-frames (to FPS) on cameras in that environment can be highly beneficial to overall image detail in the few frames you have with critical recognition data in them.

Another area that people often don’t cover is the other added benefit of I-Frames and why having these more prevalent in your stream can assist if/when you hit a corruption event. Remember that I-Frames hold the key to corruption recovery too since they are based on image quality (full image) and not dependent on previous encoded images. Therefore, when a Predicted (P-Frame) or Bi-directional (B-Frame) frame is corrupted it benefits from the the next I-Frame to recover from the corruption by re-encoding or decoding and benefits greatly when frames beyond the I-Frame (used as the re-encode / decode point) exist.

Lastly in terms of scanning forward or backward in a video, I would be remiss if I didn’t mention that as well. Remember that I-Frames are in fact a Key Frame and therefore play a part in where a video will seek to when moving forward and backward. The longer the I-Frame interval (or Key Frame) placement the longer the seek point will be in the stream when moving forward and backward. Not the most important part of I-Frame usage but mentioning it anyway.

So, can you use less I-Frames than your FPS, YES, should you, my recommendation is NO. For most situations, rather than running the risk of less quality in each frame captured (again, subjective BUT a fact), especially in high traffic FOV’s or special applications, simply plan your storage correctly as part of your deployment and have a system that can adapt to the changing targets in FOV. Does that mean everyone should follow this rule, absolutely NOT. I advocate for what I feel works best in my experience across many large and small deployments but hey, many people run strange configs around FPS even based on a specific need or in some cases misunderstanding but thats down to individual needs, preference, understanding and deployment scenario. Also don’t forget that some NVR SW platforms also require FPS and I-Frame interval to match.


CBR vs VBR

Now, continuing on from ‘image quality’ of I-Frames vs bandwidth / storage impact, I’ll now cover CBR vs VBR. I’ll make this one super short. CBR or Constant Bit Rate is what I would and do advise 99.9% of the time. Variable Bit Rate (VBR) encoding, although ‘good’ in theory (and has improved over time) is NOT well implemented in most CCTV solutions (even pro level and cinema cameras have issues here). A big part of the problem is what I call ‘spin-up time’ to detect motion changes and adjust encoding algorithms for the motion seen within the FOV. With the right algorithm and processing power, you have options, without it, you unfortunately see issues. VBR takes longer to encode, can place more strain on the camera / NVR / NVR platform and absolutely can make or break a critical capture moment. Due to the above, I operate and advocate for the fact that it is never worth taking a chance that your required ID frame(s) is ruined by a slow processing algorithm on cam and associated codec, therefore set CBR (granted to your desired bitrate appropriate to your target requirements) and forget about it.


Shutter Speed

Now onto another critical area, that of Shutter Speed. On a well dialed in (and not cheap security or webcam style) camera, Shutter Speed ABSOLUTELY, 100% makes a difference and IS required and effective for freezing action. Your setting for shutter speed of course is determined by your target acquisition requirements or special project applications. For example, as I’ve shared for years, 1/30 is the lowest I would advise to go for human targets at slower speed, 1/60 to 1/100 minimum for more moderate targets (think humans walking quicker, light jog) and then 1/250 is the minimum for higher speed targets such as vehicles (NOT ALPR/ANPR). I recommend these to ensure motion blur free caps as much as possible.

Back to the special applications that I mentioned and ALPR is one of those where much high shutter speed IS needed to ensure crisp plate capture for manual or automated LPR work (outside of barrier based, entry chokepoints etc). In a number of cases based on height, angle, distance to target, plate within FOV, you may be able to get away with 1/500 BUT on faster moving targets and if the other dimensions at install location are not 100% on point as well (height, distance, angle) then 1/1000 or 1/2000 would be my recommended minimum. Staying on the special applications train for a second, this also depends on camera being used. While all of the settings I mention above are valid across the board, when you add into the mix special traffic cameras such as the ITC’s I’ve mentioned and reviewed, they up the ante on their abilities to capture in more harsh environments / trickier installs. This is due to not only the usual mix of traffic specific algorithms, optics and SOC pairings BUT critically in the way they process a target within FOV. I’ve spoken at length before about how Video Metadata / AI cameras are looking for a target that matches VEHICLE and only then will process a plate whereas traffic cameras do NOT need a full vehicle recognition to process for a plate directly and are amazingly accurate even at lower confidence levels. This gives you latitude in your install location and in your configuration of the camera itself. These traffic cameras also have front and rear light compensation for plates (as I’ve demonstrated before) and therefore also give further options in your configuration, improved over standard AG / light adjustment or SMART IR would on ‘standard’ (non-traffic) security cameras.

Another ‘special application’ is for face recognition, an increasingly popular deployment requirement that I and others are called in for as part of a project. This too benefits from shutter speed adjustments. You want as clear an image of facial features as possible and often times if this is NOT in a controllable environment (I.e. not an entrance with biometrics and facial ID right in front of you) then dialing in your camera, adjusting shutter speed higher, will assist here too (note: within reason and does have a point of diminishing returns for facial recognition). The goal being to reduce as much motion blur as you can (along with other factors like limiting noise reduction that crushes detail etc etc) to ensure you a) capture recognizable features clearly first time and/or b) allow for a high confidence match against your known vs unknown databases.

On the flip side of this, often times people are tempted to go with low shutter speed to improve low light situations, which it can BUT at the detriment to image quality due to horrendous blur/motion smear (remember, NEVER use AUTO). In this case ADD MORE LIGHT to the FOV, whether on-camera (not my first choice and wouldn’t advocate for this except when absolutely necessary even on newer cams) or off-camera. Continuing on the subject of lighting for a second. Lighting should also be constant wherever possible to remove the ‘bloom’ effect you can get of motion activated lights coming on and killing your image as SmartIR tries to adjust etc.

The key takeaway for people is that shutter speed DOES make a difference and does work as intended on these cameras. If you are not seeing any difference between a 1/30 and a 1/1000 shutter speed or 1/100 to 1/2000 then either something is wrong with your camera OR you need to double check your overall configuration. As I’ve mentioned here and before, critically dialing in your camera for your location, desired FOV, lighting on scene and most importantly the target requirements is an absolute must. Don’t ruin your captures by not dialing in correctly. On that note, this is why WDR and other backlight options should also be used VERY carefully as they will also introduce blur. Similarly as I mentioned above, keep NR under control, super low in the day (around 30-35 max) and no more than 40 at night. If using for LPR/NPR then you can even drop below 30 at night BUT I would never go less than 25 (this still allows the ALPR/ANPR traffic cams to work well) AND this will depend highly on your install location, lighting on scene etc. None of these cams are OR should be looked at as plug n play, they’re not as we’ve discussed many times. Dialing in your cams which includes shutter speed (remember to compensate for light impact) will take your useful captures to the next level.


Closing Thoughts

In summary, the important thing to remember is that you don’t / can’t control targets in your location BUT you do control how your cams are configured within that deployment and that is critical. You never know when someone will run up to an entrance way faster than anticipated or speed past an area at an angle that limits time in FOV. So, do you look to save bandwidth on the assumption that you may capture some of those events with critical frames OR do you set yourself up for success (as best you can) by dialing in your config to ensure your hit rate for ID frames improves and that short of a crazy event (like camera falling off of its install location), you’re covered. I’ll take and advocate for the latter and setting you up for success any day of the week in this business. So keep the above in mind, hope it helps

WC
 
@Wildcat_1 - thanks for putting this down in one place that we can point people to.

Too many come here thinking higher FPS is better and double/triple i-frames is better, and VBR saves a ton of space, but you tear these firmwares apart and find all the nuances that can improve or ruin an image.

The key I like to tell people as well that you explained is that if you set the camera to a 1/30 shutter and a 1/2000 shutter, then you either have bad settings somewhere else or you have a cheap camera that won't actually adhere to the parameters people set.

What are your thoughts on lower NR in the day than 30?
 
@Wildcat_1 - thanks for putting this down in one place that we can point people to.

Too many come here thinking higher FPS is better and double/triple i-frames is better, and VBR saves a ton of space, but you tear these firmwares apart and find all the nuances that can improve or ruin an image.

The key I like to tell people as well that you explained is that if you set the camera to a 1/30 shutter and a 1/2000 shutter, then you either have bad settings somewhere else or you have a cheap camera that won't actually adhere to the parameters people set.

What are your thoughts on lower NR in the day than 30?
Thanks for the kind words, hope it helps people. With regards to NR during the day, you can drop lower for sure just be careful with special application scenarios (face recognition, ALPR and stereo analysis capture situations).

The other thing to keep an eye on (in regards to. noise) is both IRIS control (when it exists in cam) and gain. A number of people will just assume that leaving IRIS on Auto (go manual and as low as you can get away with on scene) & Gain as 0-50 is good, it’s not and these too will add further noise through artificial bump in light through under hood algorithm. These of course then work against the amount of ‘natural noise’ you are trying to eliminate in the first place. For day caps, people may be surprised how often the cam is applying gain (in the 0-50 setting) regardless of light on scene. Try running 0-0 as your install allows and if that’s not a possibility (often times may not be) then I would definitely recommend people rethink gain settings as I’ve mentioned before (split the difference and go 0-25 etc)

HTH
 
Thanks for posting this Wildcat_1. I think this thread is informative and should be a stick thread on this sub-forum for others to see over time.

I'm not sure if this deviates from topic of your thread, but based on your experience with tweaking different cameras, what is your general advise on H.264, H.264H, and H.265? This seems to be an often-asked questions over time so I thought I'd ask. I've seen several of your video reviews of different camera and notice you prefer to use H.264H CBR at high bitrate. Is this your personal preference or is it you notice better quality overall with H.264H from your experience over time?
 
  • Like
Reactions: JDreaming
Not that I can prove it, but I'm pretty sure that, given a scenario of finite storage space per camera (let's say 10GB / day) of continuous recording (aka 24/7), then VBR will result in overall better footage to look back at than CBR - both during the boring times and the interesting times.

Sure the camera stream looks better at a constant 6Mbps, but who's paying for storing that footage for 30 days on a system with hundreds of cameras, and how many cameras do you have to sacrifice to pay for that storage cost?
 
Not that I can prove it, but I'm pretty sure that, given a scenario of finite storage space per camera (let's say 10GB / day) of continuous recording (aka 24/7), then VBR will result in overall better footage to look back at than CBR - both during the boring times and the interesting times.

Sure the camera stream looks better at a constant 6Mbps, but who's paying for storing that footage for 30 days on a system with hundreds of cameras, and how many cameras do you have to sacrifice to pay for that storage cost?

No, CBR will always result in overall better footage to look back on. If I set my bitrate to 8192 at CBR then I am getting 8192 and thus better footage to look at.

With VBR I have seen it drop to 100s bitrate and then it is a blurry mess. And depending on the field of view, the camera may not ramp up fast enough to respond to the motion with a higher bitrate and then you miss the capture you wanted.

Now VBR does provide in certain situations the ability for longer retention time if there is not a lot of movement.

BUT....most of us will set it up to record substream with no motion and mainstream with motion and run CBR for both and that will result in better overall footage to look back at compared to VBR and depending on the settings, may exceed the retention time of mainstream at VBR.
 
Thanks for posting this Wildcat_1. I think this thread is informative and should be a stick thread on this sub-forum for others to see over time.

I'm not sure if this deviates from topic of your thread, but based on your experience with tweaking different cameras, what is your general advise on H.264, H.264H, and H.265? This seems to be an often-asked questions over time so I thought I'd ask. I've seen several of your video reviews of different camera and notice you prefer to use H.264H CBR at high bitrate. Is this your personal preference or is it you notice better quality overall with H.264H from your experience over time?

@cybernetics1d Yes I find H.264H to give the best quality overall in my experience and do advocate for this. I did a full blown write up on H.264 HERE if you're interested
 
So I notice on my dahua oems and Amcrest, whenever I make adjustments to FPS, the I-frame resets by itself to twice the FPS? Why does Dahua default the cams this way? whats the thinking here? any advantage to a 15FPS/30 I-frame capture vs. a 15FPS/15 I-frame interval?
or only for faster moving objects?
 
So I notice on my dahua oems and Amcrest, whenever I make adjustments to FPS, the I-frame resets by itself to twice the FPS? Why does Dahua default the cams this way? whats the thinking here? any advantage to a 15FPS/30 I-frame capture vs. a 15FPS/15 I-frame interval?
or only for faster moving objects?

I guess they have decided the average user is more concerned with storage - It takes less storage for i-frames double the FPS. But then when you run BI, it can result in trouble with motion detection.
 
I guess they have decided the average user is more concerned with storage - It takes less storage for i-frames double the FPS. But then when you run BI, it can result in trouble with motion detection.

Ahhh. I wonder if that's why I saw a spike in storage? Out of the box my camera's were using 500mb/hour per camera(6). After getting my camera's dialed in with the recommended setting around here, my storage is now using ~4gb/hour per camera. I'm at 576gb per day. Is that mainly because I switched I Frame to match FPS at 15?
 
Last edited:
  • Like
Reactions: Flintstone61
Ahhh. I wonder if that's why I saw a spike in storage? Out of the box my camera's were using 500mb/hour per camera(6). After getting my camera's dialed in with the recommended setting around here, my storage is now using ~4gb/hour per camera. I'm at 288GB per day. Is that mainly because I switched I Frame to match FPS at 15?

Probably a combination of that and higher bitrates than the default.
 
Thanks. Very informative, though a little over my head.

I was hoping there'd be a glimmer of explanation in settings as to why one of my Dahua cams will trigger but won't PTZ (though in a wildlife position - not Human/Vehicle). I had a heron walk upto it and fill almost 60% of the image - but it still didn't follow. [In this case I am using BI's motion - not the direct Cam triggers].

Looking at the settings I have 30fps with 30iFrame - and CBR.
What's the recommendation on Smart Codec? I notice to set it "on" invokes VBR
 
  • Like
Reactions: Flintstone61
Outstanding information here, a good primer for anyone.

I would just disagree on 1 part, the VBR/CBR and VBR's usage, at least in my use cases. Andy's cameras, at least the newer ones, seem to scale up VBR as needed very fast. I could imagine some lower quality ones would definitely have issues with this.

I have many systems that are often viewed by many different stations live as opposed to just recording for playback. VBR and the higher i-frame number has a usage here. I"ll normally record the mainstream only in higher quality, and have a second and third stream with lower quality, VBR, and much higher i-frame setting for live views. For live viewing, Milestone has adaptative streaming, meaning it will load the smaller 704x5xx stream when the user is viewing a 16 camera view, then jump up to the 720p or 1080p if the user makes the camera full screen. I'm not sure if BI has it, I've always been a milestone guy. Milestone also has an option for motion detection to do it on the entire stream, not just the i-frames coming through. I tend to keep it on the i-frame only, since I normally set a 5 second prebuffer for motion, so it'll grab the previous 5 seconds as well when it detects motion.

My general setup, using Andy's cameras for reference, but I follow the general concepts for Axis, Vivotek, etc. Many of my systems have multiple recording servers, connected back by 4g/cable/fios/fiber, so it records locally onsite and is centrally controlled by the Milestone management server. Live streams can be adjusted down more depending on how its connected back for live viewing in the monitoring center.

Recording Main stream: Record only, not for live view. Match i-frame to FPS, and either highest VBR or highest CBR bit rate needed.
Live View Second Stream: 704x5xx, 5 VBR, usually 5 FPS and a 50 i-frame setting.
Live View Third Stream: 720p or 1080p, 5 VBR, 5 FPS and 50 i-frame setting.
 
  • Like
Reactions: Flintstone61
Thanks. Very informative, though a little over my head.

I was hoping there'd be a glimmer of explanation in settings as to why one of my Dahua cams will trigger but won't PTZ (though in a wildlife position - not Human/Vehicle). I had a heron walk upto it and fill almost 60% of the image - but it still didn't follow. [In this case I am using BI's motion - not the direct Cam triggers].

Looking at the settings I have 30fps with 30iFrame - and CBR.
What's the recommendation on Smart Codec? I notice to set it "on" invokes VBR

Depending on the camera you have, the AI may be overriding anything else to force a track on person/car. See this thread:



Keep in mind that the tracking is a function of the camera itself, not BI, so whether BI motion triggers or not, that does not control the tracking of the camera and that is only done from within the camera itself.

BI does not like smart codec. BI is best with no codec and straight H264 or H265. Smart Codec will drop the bitrate until it sees a person or vehicle, so it is essentially operating as smart VBR.

Most people don't use more than 15FPS for surveillance cameras. Movies are recorded at 24FPS, so I don't think you need more than that for your mobile and tablet LOL. Plus 30FPS takes up more storage.

Sure 30FPS can provide a smoother video but no police officer has said "wow that person really is running smooth". They want the ability to freeze frame and get a clean image. So be it if the video is a little choppy....and at 10-15FPS it won't be appreciable. My neighbor runs his at 60FPS, so the person or car goes by looking smooth, but it is a blur when trying to freeze frame it because the camera can't keep up. Meanwhile my camera at 15FPS with the proper shutter speed gets the clean shots.

Shutter speed is more important than FPS.

Watch these, for most of us, it isn't annoying until below 10FPS



 
Outstanding information here, a good primer for anyone.

I would just disagree on 1 part, the VBR/CBR and VBR's usage, at least in my use cases. Andy's cameras, at least the newer ones, seem to scale up VBR as needed very fast. I could imagine some lower quality ones would definitely have issues with this.

I have many systems that are often viewed by many different stations live as opposed to just recording for playback. VBR and the higher i-frame number has a usage here. I"ll normally record the mainstream only in higher quality, and have a second and third stream with lower quality, VBR, and much higher i-frame setting for live views. For live viewing, Milestone has adaptative streaming, meaning it will load the smaller 704x5xx stream when the user is viewing a 16 camera view, then jump up to the 720p or 1080p if the user makes the camera full screen. I'm not sure if BI has it, I've always been a milestone guy. Milestone also has an option for motion detection to do it on the entire stream, not just the i-frames coming through. I tend to keep it on the i-frame only, since I normally set a 5 second prebuffer for motion, so it'll grab the previous 5 seconds as well when it detects motion.

My general setup, using Andy's cameras for reference, but I follow the general concepts for Axis, Vivotek, etc. Many of my systems have multiple recording servers, connected back by 4g/cable/fios/fiber, so it records locally onsite and is centrally controlled by the Milestone management server. Live streams can be adjusted down more depending on how its connected back for live viewing in the monitoring center.

Recording Main stream: Record only, not for live view. Match i-frame to FPS, and either highest VBR or highest CBR bit rate needed.
Live View Second Stream: 704x5xx, 5 VBR, usually 5 FPS and a 50 i-frame setting.
Live View Third Stream: 720p or 1080p, 5 VBR, 5 FPS and 50 i-frame setting.

For those that find this thread and use BI, not matching FPS and iframes will result in missed motion.

The Blue Iris developer has indicated that for best reliability, sub stream frame rate should be equal to the main stream frame rate. Further, the iframe rates should equal the FPS, but at worse case be no more than double.

Your example of using 5FPS and 50 iframe a keyrate results in a KEY of 0.10. If they match it would be a KEY of 1.00. In BI a value of 0.50 or less is considered insufficient to trust for motion triggers reliably

In BI, motion detection is based on the substream, so with a FPS of 5 and iframe of 50, the KEY in BI would be 0.1, which means any object that can be in and out of the camera view in under 10 seconds will be missed as a trigger.
 
  • Like
Reactions: Jim I.
For those that find this thread and use BI, not matching FPS and iframes will result in missed motion.

The Blue Iris developer has indicated that for best reliability, sub stream frame rate should be equal to the main stream frame rate. Further, the iframe rates should equal the FPS, but at worse case be no more than double.

Your example of using 5FPS and 50 iframe a keyrate results in a KEY of 0.10. If they match it would be a KEY of 1.00. In BI a value of 0.50 or less is considered insufficient to trust for motion triggers reliably

In BI, motion detection is based on the substream, so with a FPS of 5 and iframe of 50, the KEY in BI would be 0.1, which means any object that can be in and out of the camera view in under 10 seconds will be missed as a trigger.
Good info, I haven't used BI so that is good to know! I only do motion detection on the main stream on the post above, the two others are just for Live Views only for being displayed 24/7. Sorry if there was any confusion on that.