Estimating remaining video recording time
I am developing a piece of software that records video from a live source to WMV files (using WMV1 compression).
I am attempting to provide a rough estimate of the recording time remaining, based on the space left on the storage hard drive. I cannot simply base the output file size on the bit-rate of the codec, unfortunately, since the video compression means that the output size varies wildly according to the co开发者_如何学Gomplexity of the image.
Any thoughts?
FYI I am using C# and DirectShow.
This is a really good question. Unfortunately, there's no sure-fire way of doing this, but you have two basic options:
- Calculate ahead of time the average space used per given time unit at a given bitrate, based on experimentation or data from the codec provider.
- Start by using technique #1, but then also create a mechanism for determining the average space being used during a given recording, by dividing the space currently in use by the file from the total recording time. Then, use this metric to determine the amount of time remaining.
Option 1 is a quick and easy way to get started. Option 2 requires a bit more programming, but your estimate will be substantially more accurate. After all, compression in these instances is based on what you are recording. Recording a solid green screen for 1 hour takes substantially less disk than recording a moving background with continuously changing foreground, or maybe a fractal sequence. There's no way to do a good estimate ahead of time.
You can only estimate future compression size by using the compression rates received in the last x seconds. Dont have it too large a value, or too small.
Too small a time period will mean that the time could wildly change [depending on the amount of motion in the video] and too long a time will mean the time will be very unaccurate.
I'd guess a time of 30 seconds could provide a reasonable degree of accuracy
精彩评论