Understanding and Solving low frame rate issues and dropped frames when Solar/Lunar imaging

A place to post guides, instructions and HOWTO documents on the use of SharpCap and Astrophotography in general
Forum rules
One tutorial per topic please.
Please only post content that you have created in this form.
Tutorials should be either in PDF format as an attachment or written in the first post of the topic. Links to video tutorials you created are also acceptable.
Post Reply
User avatar
Site Admin
Posts: 12970
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK

Understanding and Solving low frame rate issues and dropped frames when Solar/Lunar imaging


Post by admin »

Hi folks,

this has come up several times recently, so it seems like a good idea to write a full guide on how to understand this sort of problem and what to do to try to solve the issue.

I'm going to divide this up into two sections - the first is what to look for if you see slow frame rates or dropped frames while just viewing the images on screen. The second is related to issues that occur when capturing images to file.

1. Problems with low frame rates / dropped frames when viewing images (not capturing)

If you experience problems with low frame rates only when capturing, please ignore this section and check out section 2 instead. This section describes the possible causes of low frame rates or dropped frames when SharpCap is just displaying the camera video on screen and is not actually saving to file.

The first thing to understand is that there are a number of things that might limit the frame rate that you can achieve with a camera in SharpCap, and the frame rate you see will be determined by whichever of those things has the lowest limit. The major constraints on frame rate are

1. Exposure time
2. The maximum frame rate of the sensor in your camera
3. The rate that image data can be transferred to your computer over the USB cable
4. How quickly your PC can accept and process the data for display

Let's look at each of those in turn...

Exposure Time

The exposure control may limit the frame rate of the camera, depending on the exposure value set. For instance if you have an exposure of 100ms (0.1s) set, you will never get a frame rate of more than 10fps, since there is only time for 10 exposures of 100ms each in a single second. Similarly 50ms exposures will allow no more than 20fps, 33ms will allow up to 30fps and 20ms up to 50fps. It's always worth checking the exposure isn't the cause of the problem before looking into any of the other possibilities. If you have encountered problems due to the exposure length, try setting a lower exposure and higher gain to allow faster frame rates.

Maximum Frame Rate of the Sensor

Each camera sensor has a maximum frame rate that it can capture at. For older or lower spec sensors connected via USB3 to the computer, this may be the limiting factor in terms of frame rate. Normally this maximum frame rate will be part of the camera specifications published by the manufacturer. Often you may be able to achieve a higher frame rate by using a smaller capture area (using the camera in ROI mode). On some cameras, the reduction in image height is key to increasing the frame rate.

As an example, the ZWO 120MM-S has a maximum of about 37-38 fps at full resolution over USB3.

The rate at which data can be transferred over the USB cable

Each type of USB connection has a theoretical data rate limit. These are:

USB 1.0 : 1.5 Mbps (megabits per second)
USB 1.1 : 12 Mbps
USB 2.0 : 480 Mbps
USB 3.0 : 5000 Mbps (5 Gbps)
USB 3.1 : 10000 Mbps (10 Gbps)

These days you will mostly see USB2 and USB3 cameras, so we will concentrate on the rates for those flavours of USB. The values given above are in bits per second, so we have to divide by 8 to get bytes per second. Additionally it's not possible to hit the maximum theoretical value due to overheads in transmission, time delays and so on. Typically in good conditions you might get up to 60 to 70% of the theoretical value.

So, in terms of bytes per second we have these limits

USB 2.0 : up to approx 42 MBps (Megabytes per second - note the big B)
USB 3.0 : up to approx 440 MBps

Now, if you are operating your camera in an 8 bit mode, 1 byte is required to transfer each pixel, so we can calculate that the ZWO 120MM-S camera might get up to about 35fps on USB2 (42 Megabytes divided by the number of pixels per frame, which is 1280*960). A USB3 connected camera with a sensor of about 20 Megapixels will be limited to about 20-22 fps due to the data flow limit of USB3.

Note that if you operate your camera in 12,14 or 16 bit mode, 2 bytes are required to transfer each pixel, so the lmiting frame rates will typically be half of those seen in 8 bit modes

Important The figures given above are 'best case' numbers in optimal conditions. That means

* The setting for USB Speed for the camera is set to the maximum speed (usually the largest value, but the smallest value for QHY cameras)
* No external USB hubs or active extension cables
* Total USB cable length no more than 4 to 4.5m for USB2 and 3 to 3.5m for USB3
* USB3 connection throughout for USB3 speeds (ie USB3 port, USB3 cable, USB3 camera)
* No bad connections/dodgy cables
* No other devices sharing the USB bandwidth (note that adjacent ports on many PCs are connected to an internal USB hub, so two devices plugged into adjacent ports may be sharing bandwidth with each other)

If you do have bad USB connections or over-long cables, these can lead to a big drop in frame rate (or possibly no frames at all), even if the camera seems to be working otherwise.

If your frame rate is being limited by USB bandwidth then your options are as follows

* Ensure a USB3 connection for USB3 cameras
* Reduce cable lengths and/or remove hubs
* Reduce Capture area (use camera in ROI mode)
* Reduce bit depth to 8 from 12/14/16
* Optimize USB speed controls (turn up for most camera types, down for QHY). However sometimes adjusting too far for performance causes issues

PC Performance

If you have a high frame rate or high resolution camera and are using it on a low-spec, low power or old PC, you may end up in the situation where the PC struggles to keep up with the flow of image data from the camera. This will usually be shown by the CPU usage hitting 100% in Task Manager when the camera is running.

SharpCap tries to keep the camera running as efficiently as possibly by using multiple cores on your CPU (if available) and by dropping the rate at which the display is updated, however in some cases that will not be enough.

If the frame rate is lower than expected, the CPU usage hits 100% (or near to) with the camera in use then consider the following options

* Use the camera in ROI mode to reduce the amount of data per frame
* Ensure other applications are not running at the same time as they may be consuming CPU resources
* Consider trying a more powerful PC if possible

Final Notes

One more thing worth checking is the 'Frame Rate Limit' control. This defaults to 'Maximum', however if it is set to another value then it deliberately limits the rate that SharpCap will process frames from the camera. It is intended to be used for things like timelapse captures, but if it has been adjusted and you forget to reset it to 'Maximum' then it may limit the frame rate of the camera.

2. Problems with low frame rates / dropped frames that only happen when capturing to file

If you experience problems when you are *not* capturing, please start with section 1 above. The information below will only help you with frame rate issues that occur when capturing images to file.

In general there are four main reasons that SharpCap might give lower frame rates while capturing

1. The extra CPU work needed for saving causes excessinve CPU load
2. The SSD or hard disk that you are saving to cannot keep up with the rate of data coming from the camera
3. Other software (for instance antivirus software) is trying to inspect the data being written and causing a backlog
4. Using a USB drive for capture that shares bandwidth with the camera

An important thing to watch when trying to solve this sort of issue is the 'Memory' status in the status bar at the bottom of the SharpCap window. When SharpCap cannot save the frames as quickly as they arrive from the camera, the amount of memory in use storing frames waiting to be saved will start to rise, so that instead of seeing 'Memory: 2 of 1000 frames used' you will see '452 of 1000 frames used' and eventually '998 of 1000 frames used' or similar. Once the number of frames of memory used gets close to the maximum, SharpCap has to start throwing away frames from the camera as it has no space left to store them.

Extra CPU Load while saving

On a low power or older computer, this may show up as 100% CPU load, but it's also possible for the same problem to happen on a more modern and powerful PC without the CPU level hitting 100%. SharpCap uses one core of the CPU for the saving process, and if the amount of work to be done exceeds the capability of a single core then the writing to file will not be able to keep up with the capture from the camera.

If this problem is occurring, the number of frames used in the memory status will start to rise straight away when you start capturing.

One important thing to check for if you see this sort of problem is to make sure that you are saving to either SER or AVI file, since they have the best performance. SER in particular is very simple and requires little CPU calculation. If you have mistakenly left SharpCap capturing to a still file format (such as PNG, FITS or TIFF), the performance is likely to be very poor as it takes much longer to write a single frame to an image file than it does to add one more frame to a video file.

Other things you can do to improve performance if you suspect this is the problem

* Avoid writing to file formats that use compression, since that requires more CPU. Avoid PNG, WMV, TIFF
* Reduce the capture area (run the camera in ROI mode) to reduce the amount of data being saved

SSD or Disk cannot keep up

If you are capturing to the correct file format (SER, or possibly AVI) and see reduced frame rates when capturing then this is the most likely cause. You may notice the number of frames of memory in use begin to rise immediately on capturing, or possibly it will stay low for some time before starting to rise. Eventually, the number of frames of memory in use will get close to the maximum and SharpCap will start dropping frames.

This is most likely to happen when capturing from high speed cameras to older style spinning platter hard disks, since they are generally slower than SSD drives. However, SSD drives are not always as fast as they should be - this is explained further below.

The first thing to check when you encounter this problem is that you are not saving more data than you need to. If you are capturing in 12/14/16 bit mode and you don't really need to then change to 8 bit mode and you will halve the amount of data that needs to be written to disk. If you are capturing using a colour camera in RGB24 or RBG32 then switch to RAW8 mode instead - that will reduce the data written by a factor of 3 or 4! RAW8 mode saves a single byte per pixel image, whereas RGB24 requires 3 bytes per pixel and RGB32 requries 4...

The next thing to do is to make sure that your hard disk or SSD is optimised to accept new data as rapidly as possible. Hard disks can be slow to save new data if the free space on the disk is spread out into lots of small blocks rather than all being in one area. SSDs can be slow to save new data if you have recently freed up space by deleting files but the disk hasn't got around to wiping those areas yet (writing new data to SSD is fast, wiping old data to allow a new write can be slow). In either case, the procedure to prepare for high speed capture is the same:

* Clear as much space as you can on the disk you are going to capture to. Ideally move old captures to another disk
* Go to the Windows 'Disk Tools' and choose to Optimise (SSD) or Defragment (Hard Disk) the disk - let the process complete

This should give you the best chance of getting the highest save rate out of your equipment.

Note that modern SSDs often have different 'zones' of storage space. The bulk of the device will be set up to store as much data as possible, but will not be able to save at anything like the maximum speed advertised by the manufacturer. A small fraction (maybe 10% or so) of the space will be set up to be able to save data at the maximum speed. If this is the case and you have a 512Gb SSD then you will be able to save about 50Gb of data at maximum speed before suddenly saving becomes very slow. If you leave the computer running for a while then the SSD will gradually move the data from the high speed write section to the bulk storage section, which should let you do another few 10s of Gb of capture at maximum speed. Alternatively you can move the captured data to another device then go through the delete and optimise steps above to make the SSD ready for capturing again.

Antivirus Software

In general, antivirus software will leave video files alone and not cause any problems. In particular, the SER file format is little known outside astronomy, so is probably ignored by most antivirus software. However, if you see high CPU usage in task manager for an antivirus program during capture, you may be able to adjust the settings of the antivirus software to exclude the 'SharpCap Captures' folder.

USB Drives

Relatively cheap SSD devices that connect over USB can be an attractive way to add more storage to a computer. However, if you use them for capturing camera video then there could be a problem.

Never plug both the camera and the SSD in to the same USB port via a hub. When you start to capture, the data being read from the camera and the data being written to the SSD will be competing for the available transfer bandwidth across the USB port and you will likely get poor results.

Since adjacent USB ports on a computer may be both connected to an internal hub, avoid using adjacent ports for the camera and the capture disk. Or at the very least be aware of this as a possibility if you see poor capture performance.

Well, that's all for the moment - I've run out of steam... If I think of anything else that is relevant I will come back and edit it into this post.


Post Reply