
Estimated Compressed Video Quality Parameters
![]()
Estimated compressed video quality parameters.
![]()
If you have ever used video stream compression programs, you have probably come across parameters such as the size (size) of the output file or its bit rate among the characteristics of the output file, and wondered: how to choose the correct value?
Sound files
As a general rule, these problems do not arise with audio files, because the quality of the sound is determined almost unambiguously by its bit rate (that is, the reproduction rate of the transmission, usually expressed in kilobits per second). If we see that the bit rate of a compressed audio file (mp3) is 128 kpbs (kilobits per second), then we understand that the sound quality corresponds to a CD disc, if it is 64 or 96 kbps, then this already It is low. sound quality, if 256 kbps is High quality studio sound, etc.
Although within itself the sound quality is also characterized by parameters such as the sampling frequency, but as a general rule this parameter is already included in the bit rate and, therefore, the sound quality is usually determined by the Bit rate. Those. if we see an mp3 file with music with a description that is compressed with a quality of 128 kbps, then we already want to say that it is stereo sound with a sampling frequency of 44 or 48 khz.
Introductory
With video, things get a bit more complicated. The video has parameters such as size and frame rate. Therefore, knowing just one bit rate is not enough; you need to additionally know the frame size and the number of frames per second. Therefore, looking at the video parameters, for example, 640×480 (frame size), 25 fps (frames per second), 1300 kbps (bit rate), it is difficult for a beginner to say anything about its quality, even approximately. Similarly, setting the parameter 1300 kbps when compressing video, it is not clear what we get in the output. And this is essential, since the process of recompressing video movies takes several hours.
The quality of the video stream compression is most unequivocally determined by the “bits / pixel” ratio, which means the average number of bits spent in 1 pixel of the image. Also, I will denote this coefficient with the letter K (because I don’t know how it is normally denoted).
If we take a 24-bit color depth encoded in RGB format (that is, when the red, green and blue channels are encoded at 8 bits per channel), then the uncompressed video stream will have a value of K = 24. The Modern video codecs give a good quality picture at a fairly low K value. For XviD and DivX codecs, good image quality will be at a K-value in the range of 0.25-0.35, for H264 – in the range 0.15-0.2 (that is, the video stream is compressed by file size more than 100 times relative to uncompressed). I don’t know the values of other codecs, but the worse (older) the codec is, the higher the value of K, in which there will be a good image quality.
The coefficient is calculated using the following formula:
The code:
K = (size * 8) / (width * height * fps * time)
Where:
size: size of the video stream in bytes
width, height – frame size (width and height) in pixels
fps: number of frames per second
time – video transmission time in seconds
At the same time, don’t forget that 1 kilobyte equals 1024 bytes (not 1000) and consequently 1 megabyte equals 1024 kilobytes = 1048576 bytes.
It should be understood that the above K values for codecs are taken for “average” video. If the video is a hand-drawn cartoon or a flash cartoon, then the quality will be good even with lower values of the coefficient. If the video contains a lot of movement and constant changes in color and brightness (for example, an anthill), then for good quality the video should be compressed with a higher value of the coefficient. If you do not need a clear image (for example, when you need to shoot some physical exercises, but at the same time the clear contours of the face and surrounding objects are not important to us), then the coefficient can be reduced. Etc.
Typically, compression programs ask you to specify the bit rate (usually in kilobits per second) or the size of the target file (usually in kilobytes). Starting from the fact that the bit rate is the file size in bits divided by the time in seconds, the corresponding parameters are calculated using the formulas



















