The concept of frame rate and bit rate

There are many concepts in audio and video, frame rate and bit rate are two common concepts.

Readers often hear expressions such as "what is the refresh frame rate" or "the bit rate is relatively high, so the network speed is required to be better".

This article introduces the concept of frame rate and bit rate of audio and video.

Xiaocheng also introduced other concepts of audio and video before. Readers can follow the WeChat public account of "Guangzhou Xiaocheng" and check related articles in the menu item "Audio and Video -> Basic Concepts and Processes".

(1) Frame rate

The frame rate represents the frequency, that is, the frequency of the operation in a period of time.

The specific meaning of the frame rate needs to be introduced in two scenarios, one is the scene during acquisition, and the other is the scene during display.

(a) When collecting

For natural sounds or images to be converted into objects in the computer, acquisition is necessary.

For image collection, the camera or screen is generally used as input, and pictures are taken or captured according to certain rules (Xiaocheng introduced video recording before, readers can refer to this article).

In this rule for obtaining pictures, there is an indicator, which can be called "the speed of taking pictures". Obviously, the faster the image is taken, the better the details of the changes can be captured, but the total number of images is also greater. If these images are stored on disk or transmitted over the network, the storage space and occupied bandwidth are factors to be considered. , and this is related to the "speed of taking pictures".

"Image capture speed" is generally defined by how many images are taken in a unit of time (such as one second), that is, how many frames are in one second, and the unit is fps. For example, "this movie of mine is 25fps", which is 1 second Inside I took 25 pictures.

When Xiao Cheng introduced "extract pictures from videos" before, the parameter -r passed to ffmepg is to take several pictures per second, which is also the concept of "picture taking speed", but this is extracted from existing videos, and Not extracted from the camera or screen.

(b) When displayed

The captured pictures are encoded and compressed, stored or transmitted, decoded, and finally displayed.

When displaying pictures, there are also some display rules, and one of these rules can be called "drawing speed".

"Drawing speed" is to draw several pictures per second, and the unit is also fps.

Also, in the case of continuous source pictures, the faster you draw, the smoother theoretically. However, the faster you draw, the more strenuous you are, and you may not even be able to draw that fast.

How fast "drawing speed" should be, depends on your purpose and actual ability. The general desired effect is to make the picture appear smooth, and to keep the display components less busy.

Xiaobai: So, how many fps is considered smooth?

Xiaocheng: It depends on how the content changes. If you don’t exercise often, then 15fps can be used; if you are in intense motion, you need to draw faster, such as 30fps, 60fps or higher. Of course, the premise is that the acquisition is smooth.

Drawing too slowly or drawing too fast, what problems can it cause? This is related to the code logic. Generally speaking, for video, if there is sound and image, then the problem of sound and picture synchronization should be considered. One of the implementation logic can use sound as the main, and the image will be rendered behind the pts of the sound, otherwise it will wait. If this is the case Logic, then, if you draw too slowly, the image will not keep up with the sound, and if you draw too fast, it will not be a problem (just more judgment). If it is other processing logic, it is necessary to analyze specific problems.

In general, the "image acquisition speed" during acquisition and the "drawing speed" during display are called frame rates.

Generally speaking, if you say the frame rate of a video, it refers to the frame rate at the time of acquisition.

Xiaobai: Can I have 15fps in one second and 30fps in one second?

Xiaocheng: This is called dynamic frame rate (vfr) , which is not expanded here.

Next, Xiao Cheng demonstrates how to change the frame rate of the video.

Here we use FFmpeg to change the frame rate of the video . For the installation and use of FFmpg, readers can refer to the articles introduced by Xiaocheng before.

Before the frame rate change, it looked like this:
Before changing the frame rate

Use the ffmepg command to modify the frame rate and change it to 1fps (similar to acquisition, take a picture in 1 second):

ffmpeg -i moments.mp4 -y -r 1 moments_1fps.mp4

After changing the frame rate, it looks like this:
After changing the frame rate

Then, with these two different capture frame rates (1fps on the left, 25fps on the right), the corresponding video effects are as follows:
Different capture frame rates

(2) Code rate

Bit rate, also called bit rate, is a concept used in encoding and compression. Audio and video data is finally represented by binary numbers (bit), and the amount of data in 1 second is the bit rate . The unit is bps, or kbps, such as "I use 128kbps to encode mp3 files".

The more bits per second, the more details that can be expressed (such as high-frequency information of sound, etc.), the more disk space it occupies, and the more bandwidth it occupies if it is transmitted.

Here is a demonstration, use the ffmepg command to change the bit rate .

Before the bit rate change, it looks like this:
Before modifying the bit rate

Use the ffmpeg command to modify the bit rate :

ffmpeg -i moments.mp4 -y -b:v 50K -b:a 0K moments_50k_br.mp4

After the bit rate is changed, it looks like this:
After modifying the bit rate

For two different bit rates (left 50kbps, right 388kbps), the playback effect of the corresponding video is as follows:
different bit rates

It can be seen that the one on the left is very blurred, and even there is a mosaic, because the bit rate is too small and the compression is too severe.

Finally, talk about the relationship between file size and bit rate.

File size = Bitrate * Duration. This applies to the case of a fixed bit rate, which is the total bit rate (audio + video + other). Generally, the duration of audio and video can be calculated according to this formula.

Similarly, you can use the ffmpeg command to modify the file size (truncate a section from the beginning):

ffmpeg -i moments.mp4 -y -fs 100K moments_fs_100k.mp4


To sum up, this article introduces the concept of frame rate and bit rate. Frame rate generally reflects the speed of acquisition during acquisition; code rate is a concept during encoding, which reflects how many bits are used to describe audio or video data per unit time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324794494&siteId=291194637