How to Set video quality

Source: Internet
Author: User

How to Set AnyChatVideo quality?

The video quality of AnyChat SDK is mainly through the "AnyChatCoreServer" of the server. ini configuration file. This configuration is the default configuration for all rooms in the system. In earlier versions, different users cannot use different video quality parameters controlled by upper-layer applications, since "AnyChat Platform Core SDK V2.8", AnyChat provides an interface for local video quality control, which allows upper-layer applications to control the encoding quality of local videos, it provides a foundation for some specific applications. For example, a host can use high-quality video parameters when speaking, while a common user can collect common video parameters, in this way, the speaker's video effect is better than that of ordinary users. If the collected video signal has a "horizontal bar" interference.


Parameters that can be adjusted by the local video quality control interface of AnyChat SDK include "video collection resolution", "Video Frame Rate", "video bit rate", "video quality", and "Key Frame interval" and Control of "preset Parameters, parameters are defined as follows:


01. // <the local video encoding bit rate is set to the int type, and the same server configuration: VideoBitrate)

02. # defineBRAC_SO_LOCALVIDEO_BITRATECTRL 30

03. // <the local video encoding quality factor control parameter is in the int type. Same server configuration: VideoQuality)

04. # defineBRAC_SO_LOCALVIDEO_QUALITYCTRL 31

05. // <The Key Frame interval control parameter for local video encoding is in the int type. Same server configuration: VideoGOPSize)

06. # defineBRAC_SO_LOCALVIDEO_GOPCTRL 32

07. // <The Frame Rate Control Parameter of the local video encoding is in the int type, and is configured on the same server: VideoFps)

08. # define BRAC_SO_LOCALVIDEO_FPSCTRL 33

09. // <The Preset Control Parameter of local video encoding is int type, 1-5)

10. # defineBRAC_SO_LOCALVIDEO_PRESETCTRL 34

11. /// <the Width Control Parameter of the local video capture resolution is int type, which is configured on the same server: VideoWidth)

12. # defineBRAC_SO_LOCALVIDEO_WIDTHCTRL 38

13. /// <The resolution height control parameter for local video capture is int type, same as that for server configuration: VideoHeight)

14. # defineBRAC_SO_LOCALVIDEO_HEIGHTCTRL 39


The video quality control includes two modes: "average bit rate mode" (default) and "Quality Factor mode". When the bit rate is greater than 0, the "average bit rate mode" is enabled ", when the bit rate is set to 0, the "quality factor mode" is enabled ".

The typical code for setting the "average bit rate mode" is as follows:

01. DWORD dwValue = 0;

02. // set the bit rate of the local video encoding

03. dwValue = 60*1000; // 60 kbps

04. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_BITRATECTRL, (constchar *) & dwValue, sizeof (DWORD ));

05. // set the key frame interval for Local Video Encoding

06. dwValue = 20;

07. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_GOPCTRL, (constchar *) & dwValue, sizeof (DWORD ));

08. // set the Frame Rate of the Local Video Encoding

09. dwValue = 8;

10. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_FPSCTRL, (constchar *) & dwValue, sizeof (DWORD ));

11. // set the preset parameters for Local Video Encoding

12. dwValue = 3;

13. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_PRESETCTRL, (constchar *) & dwValue, sizeof (DWORD ));

14. // make the parameter settings take effect

15. BOOL bUseAppParam = TRUE;

16. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_APPLYPARAM, (constchar *) & bUseAppParam, sizeof (DWORD ));


The typical code for setting the "quality factor mode" is as follows:

01. DWORD dwValue = 0;

02. // set the bit rate of the local video encoding

03. dwValue = 0;

04. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_BITRATECTRL, (constchar *) & dwValue, sizeof (DWORD ));

05. // set the quality factor of the Local Video Encoding

06. dwValue = 4;

07. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_QUALITYCTRL, (constchar *) & dwValue, sizeof (DWORD ));

08. // set the key frame interval for Local Video Encoding

09. dwValue = 20;

10. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_GOPCTRL, (constchar *) & dwValue, sizeof (DWORD ));

11. // set the Frame Rate of the Local Video Encoding

12. dwValue = 8;

13. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_FPSCTRL, (constchar *) & dwValue, sizeof (DWORD ));

14. // set the preset parameters for Local Video Encoding

15. dwValue = 3;

16. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_PRESETCTRL, (constchar *) & dwValue, sizeof (DWORD ));

17. // make the parameter settings take effect

18. BOOL bUseAppParam = TRUE;

19. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_APPLYPARAM, (constchar *) & bUseAppParam, sizeof (DWORD ));

When the "average bit rate" mode is enabled, the quality factor parameter settings are still valid, but the system limits the maximum output bit rate. In addition, to make the set parameters take effect, you need to call the "BRAC_SetSDKOption" interface and use the "BRAC_SO_LOCALVIDEO_APPLYPARAM" flag to enable the set parameters, you can also use this flag to restore the default video quality parameters configured on the server.


AboutVideo Frame RateAndKey Frame IntervalYou can refer to the following principles for parameter settings:

1. The higher the frame rate, the smoother the video, and the maximum value is 25 FPS. At the same time, the frame rate will also have a certain impact on the bit rate and CPU resource usage. Generally, we recommend 8-12 FPS for Internet applications ), 18-25 FPS for LAN applications );

2. The key frame interval refers to the number of non-key frames between two key frames during encoding. The larger the value, the smaller the bit rate, but the lower the video quality, the smaller the value, the larger the bit rate, the better the video quality, but not too small. Generally, the recommended value is three or four times the frame rate of Internet applications), and the LAN application is equal to the frame rate ), do not lower than the frame rate;


About Local Video EncodingPreset Parameters: BRAC_SO_LOCALVIDEO_PRESETCTRL. Its value range is 1-5. It is mainly used to control CPU resource usage and image details. The smaller the value, the lower the CPU usage during encoding, however, the processing of the image details will be lost. The larger the value, the higher the CPU usage during encoding, but the processing of the image details will be more delicate. this parameter is mainly effective for high bit rates, when the bit rate is low, the video image details cannot be displayed due to the bit rate restriction. In Low Bit Rate mode, you can lower this parameter to reduce CPU utilization.


About Local Video EncodingBit Rate Parameter: BRAC_SO_LOCALVIDEO_BITRATECTRL. The unit is bps. The smaller the bit rate, the worse the video quality. The higher the bit rate, the better the video quality. This parameter is also related to the video image resolution, different Resolutions have different value ranges. For example, in Internet application scenarios, the resolution ranges from 176x144 to 10 kbps ~ 60 kbps), the resolution is 320x240, the typical value range is 50 kbps ~ 120 kbps. If it is a LAN application, the bit rate can be appropriately increased.


About Local Video EncodingQuality Factor Parameters: BRAC_SO_LOCALVIDEO_QUALITYCTRL. The value range is 1-6. The smaller the value, the lower the image quality and the lower the output bit rate. The larger the value, the higher the image quality and the higher the output bit rate.


About"Average bit rate modeAndQuality Factor ModelThe Difference and application of the two video quality control modes can be referred to the following principles:

1. "average bit rate mode": When video encoding is performed, the output bit rate is prioritized. When the picture is static, the output bit rate is low and the dynamic picture bit rate is high, the instantaneous bit rate may exceed the maximum value of the Set parameter), but the average bit rate of the output video data will remain near the set parameter. When the screen is overloaded, in order to maintain the average bit rate, the encoder will lose the quality of the image. This mode is usually applicable to Internet applications;

2. "Quality Factor mode": This mode takes effect when the bit rate parameter is set to 0. video quality is a priority for video encoding, static and dynamic images are encoded using different quantization factors to maintain a fixed picture quality. When the picture is static, the bit rate is low. When the picture is moving, the bit rate is high. This mode is usually used by LAN applications. Because there is no limit on the bit rate in this mode, when a large image is running, the bit rate changes a lot to maintain a fixed image quality, so this mode is not suitable for Internet applications.

3. If you want to obtain high-quality video effects in the Internet environment and permit network bandwidth, we recommend that you use the "average bit rate" mode ", only the video quality parameter VideoQuality can be appropriately increased, and the video bit rate parameter can be set as needed. Low Bit Rate, low video quality, high bit rate requires a high video quality.


Note: "AnyChatPlatform Core SDK" V4.0 allows each user to set the video collection resolution independently. When the upper-layer application does not set the video collection resolution and video quality control parameters, the client uses the default server configuration parameters. Earlier versions only support video quality-related parameters and do not support video collection resolution settings. The typical code for setting the local video collection resolution is as follows:


01. DWORD dwValue = 0;

02. // set the width of the local video collection.

03. dwValue = 320;

04. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_WIDTHCTRL, (constchar *) & dwValue, sizeof (DWORD ));

05. // set the height of local video collection

06. dwValue = 240;

07. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_HEIGHTCTRL, (constchar *) & dwValue, sizeof (DWORD ));

08. // make the parameter settings take effect

09. BOOL bUseAppParam = TRUE;

10. BRAC_SetSDKOption (BRAC_SO_LOCALVIDEO_APPLYPARAM, (constchar *) & bUseAppParam, sizeof (DWORD ));




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.