Video coding method and device, electronic equipment and storage medium

By dynamically adjusting video encoding parameters, the problem of poor video fluency of electronic devices in real-time video systems is solved, and smooth and stable video streaming transmission is achieved.

CN118632077APending Publication Date: 2024-09-10CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410694095.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The smoothness of videos uploaded by electronic devices in real-time video systems often does not meet viewing requirements, and lags or interruptions often occur.

Method used

During the process of collecting video streams, the processor idle rate and video encoding parameters of the electronic device are obtained every preset time period, and the video encoding parameters, including video encoding resolution, frame rate and image quality, are adjusted according to the idle rate to ensure encoding Video processing smoothness.

Benefits of technology

It implements video encoding processing based on real-time processing capabilities to avoid lags and interruptions, ensuring that the smoothness of the video meets viewing needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118632077A
    Figure CN118632077A
Patent Text Reader

Abstract

The embodiment of the invention discloses a video coding method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining an idle rate of a processor of the electronic equipment and a first parameter value of a video coding parameter at preset time intervals in a process of collecting a first video stream; the video coding parameters are parameters for carrying out real-time video coding on the first video stream, and the video coding parameters comprise video coding resolution, video coding frame rate and video coding image quality; determining an adjustment parameter value of the video coding parameter according to the idle rate under the condition that the idle rate is located outside the preset idle rate interval; determining a second parameter value of the video coding parameter according to the first parameter value and the adjustment parameter value; and coding the first video stream according to the second parameter value to obtain a second video stream.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of Internet technology, and in particular, relates to a video encoding method, device, electronic device and storage medium. Background Art

[0002] With the development of information technology, electronic devices are widely used in various production and life scenarios. Among them, mobile inspection is a kind of inspection task completed by using modern mobile terminal technology, such as safety inspection, line inspection and railway inspection.

[0003] In the mobile inspection scenario, electronic devices need to be connected to the video surveillance system as the front-end of mobile video surveillance collection. The electronic devices shoot videos and transmit video streams to the platform, so that monitoring personnel can understand the real-time status of mobile front-end points in real time. When using electronic devices as front-end video collection devices, the electronic devices need to encode and upload the audio and video data collected by the camera in real time.

[0004] Currently, when electronic devices are used as video acquisition and upload terminals in real-time video systems, the smoothness of the videos uploaded by the electronic devices usually does not meet viewing requirements, that is, freezes or even interruptions occur. Summary of the invention

[0005] The embodiments of the present application provide a video encoding method, apparatus, device and storage medium, which can solve the problem that the smoothness of videos uploaded by current electronic devices usually does not meet viewing requirements.

[0006] In a first aspect, an embodiment of the present application provides a video encoding method, the method comprising:

[0007] In the process of collecting the first video stream, obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality;

[0008] When the idle rate is outside a preset idle rate interval, determining an adjustment parameter value of the video encoding parameter according to the idle rate;

[0009] Determining a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value;

[0010] The first video stream is encoded according to the second parameter value to obtain a second video stream.

[0011] In a second aspect, an embodiment of the present application provides a video encoding device, the video encoding device comprising:

[0012] An acquisition module is used to acquire an idle rate of a processor of the electronic device and a first parameter value of a video encoding parameter at a preset time interval during the process of acquiring the first video stream; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate, and video encoding image quality;

[0013] A determination module, configured to determine, when the idle rate is outside a preset idle rate interval, an adjustment parameter value of the video encoding parameter according to the idle rate;

[0014] The determination module is further used to determine a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value;

[0015] The encoding module is used to encode the first video stream according to the second parameter value to obtain a second video stream.

[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the method in the first aspect or any possible implementation of the first aspect.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the method in the first aspect or any possible implementation of the first aspect is implemented.

[0018] In an embodiment of the present application, during the process of collecting the first video stream, the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter are obtained at preset time intervals; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality; when the idle rate is outside the preset idle rate interval, it means that the processing of the electronic device is insufficient or the processing capacity is excessive. At this time, according to the idle rate, the adjustment parameter value of the video encoding parameter can be determined in real time and dynamically; according to the first parameter value and the adjustment parameter value determined in real time, the reasonable second parameter value of the video encoding parameter in the current state of the electronic device can be determined; according to the second parameter value, the first video stream is encoded and processed, and the video encoding processing can be performed based on the real-time processing capability of the electronic device, avoiding the occurrence of freezes and interruptions, and obtaining a smooth and stable second video stream. Thus, the fluency of the second video obtained by encoding the first video stream can meet the viewing needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0020] Figure 1 is a scene graph of a video encoding method provided in an embodiment of the present application;

[0021] Figure 2 is a flowchart of a video encoding method provided by an embodiment of the present application;

[0022] Figure 3 is a structural diagram of a video encoding device provided in an embodiment of the present application;

[0023] Figure 4 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application and are not configured to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.

[0025] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0026] The following is a brief introduction to the technical terms involved in this application.

[0027] Video encoding resolution, the number of horizontal and vertical pixels of a video image, is usually expressed as the number of horizontal pixels multiplied by the number of vertical pixels. Typical video resolutions are usually described by width × height. Common resolutions include: 4096 × 2160 (4K), 2048 × 1080 (2K), 1920 × 1080 (1080p Full HD), 1280 × 720 (720p HD), 720 × 480 (DVD), 640 × 480 (VGA).

[0028] Video encoding frame rate refers to the number of image frames displayed continuously per second during video playback. It is usually measured in "fps" (Frames Per Second) to measure the smoothness of the video and the smoothness of the picture. The higher the frame rate, the smoother the action in the video will look.

[0029] Video encoding quality, the image quality obtained during the video encoding process, is a factor that needs to be comprehensively considered when compressing video. Its goal is to minimize the file size while maintaining the clarity and quality of the video image.

[0030] Among them, Constant Rate Factor (CRF) is a parameter used to control the quality of video compression, commonly used in encoders such as x264 and x265. The value range of CRF is usually 0 to 51. In practical applications, the common value range is 0 to 30.

[0031] For example, a CRF of 0 indicates lossless compression. This value means there will not be any visible quality loss, but the file size may be very large.

[0032] CRF is 18-28, which is the default recommended range and is suitable for most situations. 18 is very high quality, while 28 is lower quality. Usually, the video quality does not change significantly within this range.

[0033] CRF is >28, meaning that values ​​above 28 will result in higher compression, but will introduce more visual artifacts, especially at higher values.

[0034] The video encoding method provided in the embodiment of the present application can be applied to at least the following application scenarios, which are described below.

[0035] Mobile inspection is an inspection task that can only be completed on the move by utilizing modern technologies such as modern mobile terminal technology, mobile communication technology, and computer technology, such as mobile law enforcement, safety inspection, line / pipeline / equipment inspection, road / railway inspection, etc.

[0036] In mobile inspection scenarios, electronic devices need to be connected to the video surveillance system as mobile video surveillance acquisition front-ends. The electronic devices record videos and transmit video streams to the platform, making it convenient for monitoring personnel to understand the real-time status of mobile front-end points in real time.

[0037] When using an electronic device as a front-end video acquisition device, the electronic device needs to upload the audio and video data collected by the electronic device camera in real time. Since the application opening status of the electronic device is different at every moment and the various APPs occupy different electronic device resources, the available resources for encoding video data in the electronic device are constantly changing. This will cause the electronic device to be used as the video acquisition and upload end in the real-time video system. The uploaded video fluency does not meet the viewing requirements, thereby affecting the system client's real-time video viewing and subsequent video playback.

[0038] In many scenarios, the current video encoding scheme often causes the video uploaded by the electronic device in real time to freeze or even be interrupted when played by the real-time video application system client. The specific scenarios include:

[0039] When an electronic device uses WiFi and the WiFi network is good, for electronic devices that do not support GPU, the more APP programs are running in the background, that is, the less CPU resources are left in the current electronic device, the more laggy the real-time video captured by the electronic device will be when played on the real-time video application system client.

[0040] When the electronic device uses WiFi and the WiFi network is good, and the electronic device supports GPU and the electronic device uses GPU encoding for the device, the more APP programs that occupy GPU resources running in the background, that is, the less the remaining GPU usage and GPU video memory resources of the current electronic device, the more the real-time video captured by the electronic device will be played on the real-time video application system client.

[0041] If only CPU-consuming programs are run in the background, without occupying GPU usage and GPU video memory resources, the CPU memory resources must be consumed to more than 90% of the entire electronic device to cause the real-time video captured by the electronic device to be played on the real-time video application system client.

[0042] When an electronic device uses WiFi and the WiFi network is good, but the CPU resources and GPU resources of the electronic device cannot meet the encoding requirements, for example, when an electronic device supports video encoding with a maximum resolution of 1920x1080, a frame rate of 10 frames per second, and an image encoding quality of 20, and the encoding parameters are set to a resolution of 3840x2160, 10 frames per second, and an image encoding quality of 20, then when playing the real-time video captured by the electronic device on the real-time video application system client, there will be freezes.

[0043] Figure 1 It is a scene graph of a video encoding method provided in an embodiment of the present application.

[0044] like Figure 1 As shown, the scenario of the video encoding method involves an electronic device 100 , a server 200 , and an electronic device 300 .

[0045] The electronic device 100 is used to collect a first video stream; and

[0046] In the process of collecting the first video stream, obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality;

[0047] When the idle rate is outside the preset idle rate range, determining an adjustment parameter value of the video encoding parameter according to the idle rate;

[0048] Determining a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value;

[0049] Encode the first video stream according to the second parameter value to obtain a second video stream;

[0050] The second video stream is transmitted to the server 200 .

[0051] Server 200, configured to receive a second video stream; and

[0052] The second video stream is distributed to the electronic device 300 .

[0053] The electronic device 300 is used to receive a second video stream; and play the second video stream.

[0054] Figure 2 It is a flowchart of a video encoding method provided in an embodiment of the present application.

[0055] like Figure 2 As shown, the video encoding method may include steps 110 to 140, and the method is applied to a video encoding device, as shown below:

[0056] Step 110, in the process of collecting the first video stream, obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality;

[0057] Step 120, when the idle rate is outside the preset idle rate range, determining an adjustment parameter value of a video encoding parameter according to the idle rate;

[0058] Step 130, determining a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value;

[0059] Step 140: Encode the first video stream according to the second parameter value to obtain a second video stream.

[0060] In an embodiment of the present application, during the process of collecting the first video stream, the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter are obtained at preset time intervals; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality; when the idle rate is outside the preset idle rate interval, it means that the processing of the electronic device is insufficient or the processing capacity is excessive. At this time, according to the idle rate, the adjustment parameter value of the video encoding parameter can be determined in real time and dynamically; according to the first parameter value and the adjustment parameter value determined in real time, the reasonable second parameter value of the video encoding parameter in the current state of the electronic device can be determined; according to the second parameter value, the first video stream is encoded and processed, and the video encoding processing can be performed based on the real-time processing capability of the electronic device, avoiding the occurrence of freezes and interruptions, and obtaining a smooth and stable second video stream. Thus, the fluency of the second video obtained by encoding the first video stream can meet the viewing needs.

[0061] The contents of step 110 to step 140 are described below respectively:

[0062] This involves step 110 .

[0063] During the process of acquiring the first video stream, the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter are obtained at preset time intervals; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameters include: video encoding resolution, video encoding frame rate and video encoding image quality.

[0064] Since the video encoding process involves the video compression process, video compression is a computationally intensive process, in which the main factor consuming CPU resources or GPU resources includes video encoding parameters. Therefore, it is important to obtain the idle rate and real-time parameter value of the video encoding parameters of the electronic device at every preset time.

[0065] Video encoding parameters may include:

[0066] Coding standards, different video coding standards have different compression algorithms and complexities. Some encoders have more complex algorithms and require more computing resources.

[0067] Compression parameters, different compression parameter settings may affect the processing complexity of the encoder. Higher compression quality, lower bit rate, higher resolution, etc., usually require more computing resources.

[0068] Video resolution and frame rate. Processing higher resolution videos and higher frame rate videos usually requires more computing resources. More pixel data and more frames require more processing.

[0069] Hardware acceleration, using hardware acceleration can significantly reduce the burden on the CPU. Many modern systems and devices support hardware acceleration to speed up the video encoding process.

[0070] Encoders and versions. Different versions of the same encoder may have different optimizations and efficiencies. Updating to a higher version of the encoder may bring better performance and efficiency.

[0071] Parallel processing capabilities: Multi-core processor systems can more efficiently process video encoding tasks in parallel to improve performance.

[0072] The characteristics of video content also affect the consumption of CPU resources. For example, videos with intense motion may require more computing resources to maintain picture quality.

[0073] In the real-time video system, the main selections are video compression method, pure CPU or hardware acceleration, namely GPU method, video resolution, video frame rate and video encoding quality for comparison and optimization.

[0074] Therefore, by obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at preset time intervals, it is possible to automatically adjust according to factors such as the CPU idle rate or GPU idle rate of the current electronic device to ensure the quality and smoothness of the video generated by the encoding, thereby improving the user viewing experience.

[0075] In a possible embodiment, before step 110, the following steps may also be included:

[0076] Obtaining hardware type information of the electronic device, the hardware type information including: chip type and chip model;

[0077] A first parameter value of a video encoding parameter is determined according to the hardware type information.

[0078] A chip, also known as an integrated circuit, or microcircuit, microchip, wafer / chip is a way of miniaturizing circuits in electronics and is often manufactured on the surface of a semiconductor wafer.

[0079] When electronic device manufacturers produce and design electronic devices, they usually use chip models to identify device performance. For example, Qualcomm Snapdragon 800 series chips correspond to high-end electronic devices, and high-end models are generally equipped with GPU chips.

[0080] Since there are many types and manufacturers of GPU chips, it is considered that high-end models are equipped with high-performance GPU chips, and low-end models are equipped with low-performance GPU chips. GPU chips used in electronic devices are no longer classified separately. That is, when the idle rate of the GPU chip is 90%-100%, the initial resolution, initial frame rate and initial encoding quality are consistent with the CPU.

[0081] Therefore, by determining the first parameter value of the video encoding parameter according to the hardware type information, the first parameter value can be adapted to different terminal devices, making the video content easier to spread, thereby increasing the accessibility and dissemination range of the video content.

[0082] As shown in Table 1, the maximum resolution, frame rate, and bit rate supported by each chip model.

[0083] Table 1

[0084]

[0085] The step of determining the first parameter value of the video encoding parameter according to the hardware type information includes:

[0086] Determine an initial idle rate of a processor when an application is started; the application is a program for performing real-time video encoding on a first video stream; wherein the processor includes a GPU and a CPU; when the GPU is used for encoding processing, the initial idle rate is the idle rate of the GPU, and when the CPU is used for encoding processing, the initial idle rate is the idle rate of the CPU;

[0087] A first parameter value of a video encoding parameter is determined according to the hardware type information and the initial idle rate.

[0088] Wherein, the processor includes a GPU and a CPU.

[0089] In the case of using a GPU for encoding processing, the initial idle rate is the idle rate of the GPU, that is, the initial idle rate of the GPU when the application is started is determined.

[0090] In the case of using a CPU to perform encoding processing, the initial idle rate is the idle rate of the CPU, that is, the initial idle rate of the CPU when the application is started is determined.

[0091] When the CPU idle rate is 90%-100%, the first parameter value of the video encoding parameter can be determined, and the first parameter value of the video encoding parameter includes: the basis of the initial resolution, the initial frame rate and the initial encoding quality.

[0092] During actual use, the initialization will calculate a suitable resolution, frame rate and encoding quality based on the current encoding method and idle rate. Subsequently, the resolution, frame rate and encoding quality will be adjusted in real time as the occupancy rate increases, and finally return to a suitable value.

[0093] Table 2

[0094]

[0095]

[0096]

[0097] Exemplarily, when the chip type is Qualcomm, the chip model is Snapdragon 800 series, and the idle rate is 90%-100%, the first parameter values ​​of the video encoding parameters may include:

[0098] The first parameter value of the video encoding resolution is 2048×1080;

[0099] The first parameter value of the video encoding frame rate is 90%-100%;

[0100] The first parameter value of the video encoding image quality is 30-18.

[0101] Therefore, by determining the first parameter value of the video encoding parameter based on the hardware type information and the initial idle rate, the first parameter value of the video encoding parameter can be determined based on factors such as the CPU idle rate or GPU idle rate of the current electronic device to ensure the quality and smoothness of the encoded video, thereby improving the user viewing experience.

[0102] In a possible embodiment, before step 110, the following steps may also be included:

[0103] Obtaining hardware environment information of electronic devices;

[0104] A video encoding method is determined according to the hardware environment information, so as to perform real-time video encoding processing on the first video stream based on the video encoding method.

[0105] The hardware environment information is used to indicate the video encoding methods supported by the electronic device.

[0106] The hardware environment information of the current electronic device is obtained to determine whether the video encoding mode supported by the electronic device is a GPU mode or a CPU mode.

[0107] If the current electronic device supports GPU video encoding, the GPU video encoding is used; if the current electronic device does not support GPU video encoding, the CPU video encoding is used;

[0108] Android determines whether it has GPU encoding mode by using the MediaCodecList class and related methods to obtain the encoder supported by the device and determine whether the current electronic device has GPU encoding mode.

[0109] IOS determines whether it has GPU encoding method: Apple provides some developer tools and APIs that can be used to determine the encoding capabilities of the device. VideoToolbox is a framework for processing video encoding and decoding on the iOS platform. Developers can use it to check the encoders supported by the device and the capabilities of the encoders to determine whether the current electronic device has GPU encoding method.

[0110] Therefore, by determining the video encoding method according to the hardware environment information of the electronic device, it is convenient to perform real-time video encoding processing on the first video stream based on the video encoding method suitable for the electronic device.

[0111] In a possible embodiment, before step 110, the following steps may also be included:

[0112] Obtaining system information of an operating system of an electronic device;

[0113] Determine the idle rate based on the system information of the operating system.

[0114] If the electronic device supports GPU video encoding, check the GPU idle rate;

[0115] If the electronic device supports the CPU video encoding method, the CPU idle rate is checked.

[0116] The calculation method of GPU idle rate corresponding to GPU video encoding mode is as follows:

[0117] System information of the operating system of the electronic device, including: Android system and IOS system;

[0118] If the system information of the operating system of the electronic device is the Android system, the method for calculating the GPU idle rate of the electronic device is: use the GPU rendering entry in the Android Profiler or the developer options to monitor the GPU usage rate, and use the getRenderPerfStats method in the SurfaceFlinger instance to obtain the current GPU idle rate.

[0119] If the system information of the operating system of the electronic device is IOS system, the method for calculating the GPU idle rate of the electronic device is: use the Instruments tool of Xcode to monitor the GPU usage rate. At the same time, obtain GPU performance related information through Metal APIs such as MPSKernel and MPSDevice to calculate the GPU idle rate.

[0120] The CPU idle rate calculation method corresponding to the CPU video encoding method is as follows:

[0121] If the system information of the operating system of the electronic device is the Android system, the method for calculating the CPU idle rate of the electronic device is as follows: In Android applications, because the Android system does not directly provide a simple API to obtain the current CPU usage rate, the android.os.Process class can be used to obtain the CPU usage of the top 50 processes with the highest CPU usage, and then the CPU usage rate is calculated by summing them up, and then the CPU idle rate is obtained.

[0122] If the system information of the operating system of the electronic device is an IOS system, the CPU idle rate calculation method of the IOS system electronic device is: using the ProcessInfo class to obtain basic system information such as the CPU usage rate of the device, and then calculating the CPU idle rate.

[0123] Therefore, by acquiring the system information of the operating system, the idle rate can be quickly determined in a manner suitable for the electronic device based on the operating system of the electronic device itself.

[0124] In a possible embodiment, the preset duration includes:

[0125] T1, the video encoding parameter corresponding to T1 is the video encoding image quality;

[0126] The video encoding parameter corresponding to T2 and T1 is the video encoding frame rate;

[0127] T3, the video encoding parameter corresponding to T1 is the video encoding resolution;

[0128] T1 is smaller than T2, and T2 is smaller than T3.

[0129] When encoding a video, there is a mathematical relationship between CPU or GPU resource consumption and the resolution, frame rate, and image quality of the video encoding. These relationships are usually not linear and are affected by specific encoders, algorithms, and hardware.

[0130] Based on laboratory test and analysis data, considering ensuring video quality as much as possible without video freezes or interruptions, the impact of encoding parameters on resource consumption is as follows: video encoding resolution >> video encoding frame rate >> video encoding image quality.

[0131] That is, adjusting the video encoding resolution has the greatest impact on resource consumption, adjusting the video encoding frame rate has the second greatest impact on resource consumption, and adjusting the video encoding image quality has the greatest impact on resource consumption.

[0132] If the adjustment time is too short, the CPU fluctuation will be more obvious and the life of the electronic device will be seriously affected, such as the electronic device continues to heat up, etc. In order to ensure the continuous and stable video encoding and transmission, it is necessary to ensure that the impact of adjusting the video encoding parameters on resource consumption is relatively low.

[0133] Therefore, T1 is set smaller than T2, and T2 is set smaller than T3, that is, the preset duration corresponding to the video encoding image quality is smaller than the preset duration corresponding to the video encoding frame rate, and smaller than the preset duration corresponding to the video encoding resolution.

[0134] Exemplarily, T1 = 2 seconds; T2 = 10 seconds; T3 = 30 seconds.

[0135] That is, the first parameter value of the video coding image quality may be obtained every 2 seconds, and when the idle rate is outside the preset idle rate interval, the adjustment parameter value of the video coding parameter is determined according to the idle rate, and the second parameter value of the video coding parameter is determined according to the first parameter value and the adjustment parameter value of the video coding image quality;

[0136] Every 10 seconds, obtain a first parameter value of a video encoding frame rate, and determine an adjustment parameter value of the video encoding parameter according to the idle rate when the idle rate is outside a preset idle rate interval, and determine a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value of the video encoding frame rate;

[0137] Every 30 seconds, obtain a first parameter value of a video encoding resolution, and determine an adjustment parameter value of the video encoding parameter according to the idle rate when the idle rate is outside a preset idle rate interval, and determine a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value of the video encoding resolution;

[0138] Therefore, by first adjusting the video encoding image quality, then adjusting the video encoding frame rate, and finally adjusting the video encoding resolution, continuous and stable video encoding and transmission can be ensured.

[0139] Exemplarily, the steps to be performed before step 110 include:

[0140] Determine whether the current system is Android or IOS:

[0141] IOS and Android use different APPs. Huawei electronic devices use HarmonyOS2, and this system is compatible with Android's operating environment, so the electronic devices can use Android's APPs.

[0142] Determine whether to encode via GPU or CPU:

[0143] According to the getCodecInfos method in the MediaCodecInfo class, get the list of encoders and use the getCapabilitiesForType method to get the capabilities supported by each encoder, check whether the encoder supports hardware acceleration, and thus determine whether it is a GPU encoder. The query result on P40 is that GPU encoding is supported, so the current encoding mode is set to GPU encoding.

[0144] Get the initialization parameters of the encoding:

[0145] According to the getHardware and getModel methods in the android.os.Build class, we can get the system information and compare it with the information table provided by the manufacturer. We can conclude that the chip type is HiSilicon and its chip signal is Kirin 900 series.

[0146] Use "android.os.Debug" and "android.os.Process" to first obtain the process IDs of the top 50 GPU occupants, then obtain the GPU occupancy of each process in turn, and finally accumulate the total to obtain the idle rate of the current system GPU is 85%.

[0147] According to the current GPU idle rate of 85% and the chip is Kirin 900, by querying Table 1.2, it can be obtained that the current initial video encoding resolution is 1920×1080, the frame rate is 30, and the encoding quality is 18.

[0148] Idle rate statistics:

[0149] Create a thread to calculate the GPU idle rate once a second and store the GPU idle rate in an array.

[0150] Actual frame rate statistics:

[0151] In the actual encoding thread, the number of encoded frames is counted by recording the parameter +1 for each frame of data encoded, and clearing it every 10 seconds. The clearing operation is performed in the video encoding frame rate thread.

[0152] This involves step 120 .

[0153] When the idle rate is outside the preset idle rate range, an adjustment parameter value of the video encoding parameter is determined according to the idle rate.

[0154] When the idle rate is within the preset idle rate range, there is no need to determine the adjustment parameter value of the video encoding parameter, that is, there is no need to adjust the video encoding parameter.

[0155] The CPU occupancy rate range during normal operation is relatively flexible because it depends on many factors, including application requirements, system load, and processor performance. Generally, the corresponding relationship between CPU occupancy rate and working status is as follows:

[0156] The electronic device is in idle state: Normally, when the device is in idle state and no large number of tasks are running, the CPU usage will be very low, usually between 0% and 10%. This means that the CPU is processing some basic system tasks or almost no tasks.

[0157] Electronic devices are in normal use: In normal use, such as browsing the web, light application use, general document editing, etc., the CPU usage may be between 10% and 50%. This means that the processor is processing some moderate tasks.

[0158] Electronic devices are under high load: When running demanding applications, video editing, gaming, or doing a lot of data processing, the CPU usage may exceed 50% and remain at a higher level. This does not necessarily mean that there is a problem with the system, but the processor is under a higher load.

[0159] The normal operating range of the GPU can vary depending on the usage, specific application or nature of the task. Generally, the corresponding relationship between GPU occupancy and working status is as follows:

[0160] The electronic device is in a steady or idle state: In an idle or steady state, the GPU utilization is usually very low, close to 0% or very close to this value. This means that the GPU is not being used to process graphics tasks during this period.

[0161] The electronic device is in light use: When performing general graphics processing, simple applications, or basic graphics tasks, the GPU usage may be between 10% and 40%. This range indicates that the GPU is handling lighter graphics tasks.

[0162] The GPU usage rate may exceed 40% and remain at a high level when the electronic device is in moderate to heavy use: When running graphics-intensive applications, video editing, 3D games, or other tasks that require complex graphics processing. In these cases, the GPU is usually more active in processing graphics tasks.

[0163] The correspondence between the CPU and GPU occupancy rates and the working status of the electronic device is described as follows. The ultimate goal of the embodiments of the present application is to ensure that the final utilization rate of the CPU or GPU of the electronic device is within a preset idle rate range so that the operation of the electronic device is in a stable state.

[0164] The preset idle rate range may be: 40%-70%.

[0165] In a possible embodiment, step 120 may specifically include the following steps:

[0166] When the idle rate is less than the lower limit of the preset idle rate interval, determining an adjustment parameter value according to the relationship between the idle rate and the preset level, the adjustment parameter value is used to indicate a reduction in the parameter value level of the video encoding parameter;

[0167] When the idle rate is greater than an upper limit of a preset idle rate interval, determining an adjustment parameter value according to a relationship between the idle rate and a preset level, the adjustment parameter value is used to indicate an increase in a parameter value level of a video encoding parameter;

[0168] The preset level relationship includes adjusting the relationship between the parameter value and the parameter value level.

[0169] The preset level relationship includes adjusting the relationship between the parameter value and the parameter value level, which may specifically include:

[0170] Video resolution involved:

[0171] Level 1: 2K

[0172] Level 2: 1080P

[0173] Level 3: 720P

[0174] Level 4: 480P.

[0175] Involving video image encoding quality:

[0176] Level 1: 18;

[0177] Level 2: 23;

[0178] Level 3: >28 for adjustment.

[0179] Involving frame rate adjustment:

[0180] Level 1: 30;

[0181] Level 2: 25;

[0182] Level 3: 20;

[0183] Level 4: 15;

[0184] Level 5:10.

[0185] Specifically, when using GPU encoding, the specific adjustment method is:

[0186] Adjustment of video resolution:

[0187] Count the average GPU idle rate every 30 seconds:

[0188] If the average idle rate of the GPU is less than 40%, the video encoding resolution is reduced by one level. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding resolution is 1280×720, the video encoding resolution is adjusted to 640×480.

[0189] If the current video encoding resolution is the minimum video encoding resolution of 640×480 supported by the current GPU, no video encoding resolution adjustment is performed;

[0190] If the average idle rate of the GPU is greater than 70%, the current video encoding resolution is increased by one level (for example, if the HiSilicon Kirin 800 series is currently used and the current video encoding resolution is 1280×720, the video encoding resolution is adjusted to 1920×1080);

[0191] If the current video encoding resolution is the highest video encoding resolution (1920×1080) supported by the current GPU, no video encoding resolution adjustment is performed.

[0192] Adjustments involving frame rate:

[0193] Count the average GPU idle rate every 10 seconds:

[0194] If the average idle rate of the GPU is less than 40%, the video encoding frame rate will be reduced by one level. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding frame rate is 30, the video encoding frame rate will be adjusted to 25.

[0195] If the current video encoding frame rate is the minimum video encoding frame rate 10 supported by the current GPU, no video encoding frame rate adjustment is performed;

[0196] If the average idle rate of the GPU is greater than 70%, the current video encoding frame rate is increased by one level. For example, if the current video encoding frame rate is 15 and the HiSilicon Kirin 800 series is used, the video encoding frame rate is adjusted to 20.

[0197] If the current video encoding frame rate is the highest video encoding frame rate (30) supported by the current GPU, no video encoding frame rate adjustment is performed.

[0198] Adjustment of video image encoding quality:

[0199] Count the average GPU idle rate every 2 seconds:

[0200] If the average idle rate of the GPU is less than 40%, the video encoding quality is reduced by one level. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding quality is 28, the video encoding quality is adjusted to 23.

[0201] If the current video encoding quality is the minimum video encoding quality 18 supported by the current GPU, no video encoding quality adjustment is performed;

[0202] If the average idle rate of the GPU is greater than 70%, the current video encoding quality is increased by one level. For example, if the HiSilicon Kirin 800 series is used and the current video encoding quality is 23, the video encoding quality is adjusted to 28.

[0203] If the current video encoding quality is the highest video encoding quality (28) supported by the current GPU, no video encoding quality adjustment is performed.

[0204] In addition, for (3) videos with higher resolution, higher frame rate, and higher image quality, more CPU usage is required compared to GPU encoding. When using CPU encoding, the specific adjustment method is as follows:

[0205] Statistics on the average CPU idle rate every 30 seconds:

[0206] If the average CPU idle rate is less than 20%, the video encoding resolution is reduced by one level. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding resolution is 1280×720, adjust the video encoding resolution to 640×480.

[0207] If the current video encoding resolution is the minimum video encoding resolution of 640×480 supported by the current CPU, no video encoding resolution adjustment is performed;

[0208] If the average CPU idle rate is greater than 80%, the current video encoding resolution is increased by one level. For example, for HiSilicon Kirin800 series, if the current resolution is 1280×720, the video encoding resolution is adjusted to 1920×1080.

[0209] If the current video encoding resolution is the highest video encoding resolution (1920×1080) supported by the current GPU, no video encoding resolution adjustment is performed.

[0210] Statistics on the average CPU idle rate every 10 seconds:

[0211] If the average CPU idle rate is less than 20%, the video encoding frame rate is reduced by one level. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding frame rate is 25, adjust the video encoding frame rate to 20.

[0212] If the current video encoding frame rate is the minimum video encoding frame rate 10 supported by the current CPU, no video encoding frame rate adjustment is performed;

[0213] If the average CPU idle rate is greater than 80%, the current video encoding frame rate is increased by one level. For example, for HiSilicon Kirin800 series, if the current video encoding frame rate is 25, the video encoding frame rate is adjusted to 20.

[0214] If the current video encoding frame rate is 30, the highest video encoding frame rate supported by the current CPU, no video encoding frame rate adjustment is performed.

[0215] The average CPU idle rate is counted every 2 seconds:

[0216] If the average CPU idle rate is less than 20%, the video encoding quality is reduced. For example, if the current Qualcomm Snapdragon 600 series chip is used and the video encoding quality is 23, adjust the video encoding quality to 18.

[0217] If the current video encoding quality is the minimum video encoding quality 18 supported by the current CPU, no video encoding quality adjustment is performed;

[0218] If the average CPU idle rate is greater than 80%, the current video encoding quality is increased by one level. For example, for HiSilicon Kirin800 series, if the current video encoding quality is 23, the video encoding quality is adjusted to 28.

[0219] If the current video encoding quality is the highest video encoding quality 28 supported by the current GPU, no video encoding quality adjustment is performed.

[0220] This involves step 130 .

[0221] A second parameter value of the video encoding parameter is determined according to the first parameter value and the adjustment parameter value.

[0222] For example, the video encoding parameter is the video encoding quality, the first parameter value is 23, the parameter value is adjusted to increase by one level, and the second parameter value of the video encoding parameter is 28, that is, the video encoding quality is adjusted to 28.

[0223] Exemplarily, the parameter adjustment schemes corresponding to different video encoding parameters are described below:

[0224] Adjustments related to video encoding quality:

[0225] Create a thread to repeat the following operations: take the average of the two most recent GPU idle rates from the GPU idle rate array every 2 seconds to get the average idle rate of the current GPU within 2 seconds, and then set the video encoding quality parameters.

[0226] On the electronic device, it was found that the average GPU idle rate in the first 2 seconds was 38%, which is less than 40%. At this time, the video encoding quality was adjusted to 23; when checking the second 2 seconds, the GPU idle rate was 42%, which is 40%-70%, so there is no need to adjust the video encoding quality parameters at this time.

[0227] If the GPU idle rate is greater than 70% and the video encoding quality parameter value is 23 or 28, the video encoding quality parameter will be adjusted to a higher value: 23 is adjusted to 18, 28 is adjusted to 23, and the above operation is repeated until the program ends.

[0228] Adjustment of video encoding frame rate:

[0229] Create a thread to repeat the following operations: every 10 seconds, take the average of the most recent 10 GPU idle rates from the GPU idle rate array to get the average idle rate of the current GPU within 10 seconds, divide the actual encoding count by 10 to get the actual video encoding frame rate, and then set the video encoding frame rate parameters according to the actual encoding frame rate and GPU idle rate.

[0230] On the electronic device, the first calculated GPU average idle rate is 42%, which is between 40% and 70%. The actual frame rate is 29 (within 1 frame difference from the current 30, no adjustment is required), so no adjustment is required. If the GPU average idle rate is less than 40% or the current frame rate - the actual frame rate is greater than 1, the encoding frame rate is set to the current value - 5. If the current encoding frame rate is not the minimum frame rate of 10, no adjustment is made if the current frame rate is 10. The above operation is looped until the program ends.

[0231] Adjustment of video encoding resolution:

[0232] Create a thread to repeat the following operations: every 30 seconds, take the average of the most recent 30 GPU idle rates from the GPU idle rate array to get the average idle rate of the current GPU within 30 seconds, and then set the video encoding resolution parameters according to the GPU idle rate.

[0233] On electronic devices, the first calculated average GPU idle rate is 39%, which is between 20% and 80%, so no adjustment is needed. If the average GPU idle rate is less than 20%, the video encoding resolution is reduced to 1280X720.

[0234] If the current encoding resolution is not the minimum resolution of 640X480, that is, if the current video encoding resolution is 640X480, no adjustment will be made. If the average GPU idle rate is greater than 80%, the video encoding resolution will be adjusted up one level to 2048X1080 (2K). If the current video encoding resolution is 2048X1080, which is the highest level, it will not be adjusted up. The above operations are repeated until the program ends.

[0235] This involves step 140 .

[0236] The first video stream is encoded according to the second parameter value to obtain a second video stream.

[0237] The embodiments of the present application can adapt to the requirements of different devices and platforms, ensuring that appropriate video quality can be provided on various electronic devices, tablets, computers, smart TVs and other devices.

[0238] Therefore, by encoding the first video stream according to the second parameter value, a second video stream is obtained, which can be adaptively acquired and automatically adjusted according to the hardware performance of the scene and the current operating environment factors of the electronic device, reducing the need for manual adjustment, improving the efficiency of video content production, and being able to adjust the quality of the video stream to avoid video freezes, delays or interruptions, providing a more stable video viewing experience.

[0239] In an embodiment of the present application, during the process of collecting the first video stream, the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter are obtained at preset time intervals; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality; when the idle rate is outside the preset idle rate interval, it means that the processing of the electronic device is insufficient or the processing capacity is excessive. At this time, according to the idle rate, the adjustment parameter value of the video encoding parameter can be determined in real time and dynamically; according to the first parameter value and the adjustment parameter value determined in real time, the reasonable second parameter value of the video encoding parameter in the current state of the electronic device can be determined; according to the second parameter value, the first video stream is encoded and processed, and the video encoding processing can be performed based on the real-time processing capability of the electronic device, avoiding the occurrence of freezes and interruptions, and obtaining a smooth and stable second video stream. Thus, the fluency of the second video obtained by encoding the first video stream can meet the viewing needs.

[0240] Based on the above Figure 2 The video encoding method shown in the embodiment of the present application also provides a video encoding device, such as Figure 3 As shown, the video encoding device 200 may include:

[0241] The acquisition module 210 is used to acquire the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time during the process of acquiring the first video stream; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality;

[0242] A determination module 220, configured to determine an adjustment parameter value of a video encoding parameter according to the idle rate when the idle rate is outside a preset idle rate interval;

[0243] The determination module 220 is further configured to determine a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value;

[0244] The encoding module 230 is used to encode the first video stream according to the second parameter value to obtain a second video stream.

[0245] In a possible embodiment, the acquisition module 210 is further used to acquire hardware type information of the electronic device, where the hardware type information includes: chip type and chip model;

[0246] The determination module 220 is further configured to determine a first parameter value of the video encoding parameter according to the hardware type information.

[0247] In a possible embodiment, the determination module 220 is specifically configured to:

[0248] Determine an initial idle rate of the processor when an application is started; the application is a program for performing real-time video encoding on the first video stream; wherein the processor includes a GPU and a CPU; when the GPU is used for encoding processing, the initial idle rate is the idle rate of the GPU, and when the CPU is used for encoding processing, the initial idle rate is the idle rate of the CPU;

[0249] A first parameter value of the video encoding parameter is determined according to the hardware type information and the initial idle rate.

[0250] In a possible embodiment, the acquisition module 210 is further configured to acquire hardware environment information of the electronic device;

[0251] The determination module 220 is further configured to determine a video encoding method according to the hardware environment information, so as to perform real-time video encoding processing on the first video stream based on the video encoding method.

[0252] In a possible embodiment, the preset duration includes:

[0253] T1, the video encoding parameter corresponding to T1 is the video encoding image quality;

[0254] T2, the video encoding parameter corresponding to T1 is the video encoding frame rate;

[0255] T3, the video encoding parameter corresponding to T1 is the video encoding resolution;

[0256] The T1 is smaller than the T2, and the T2 is smaller than the T3.

[0257] In a possible embodiment, the determination module 220 is specifically configured to:

[0258] In the case where the idle rate is less than the lower limit of the preset idle rate interval, determining the adjustment parameter value according to the idle rate and the preset level relationship, the adjustment parameter value is used to indicate the parameter value level of the video encoding parameter to be reduced;

[0259] In a case where the idle rate is greater than an upper limit of the preset idle rate interval, determining the adjustment parameter value according to the idle rate and the preset level relationship, the adjustment parameter value being used to indicate an increase in the parameter value level of the video encoding parameter;

[0260] The preset level relationship includes adjusting the relationship between the parameter value and the parameter value level.

[0261] In a possible embodiment, the acquisition module 210 is further configured to acquire system information of the operating system of the electronic device;

[0262] The determination module 220 is further configured to determine the idle rate according to the system information of the operating system.

[0263] In an embodiment of the present application, during the process of collecting the first video stream, the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter are obtained at preset time intervals; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality; when the idle rate is outside the preset idle rate interval, it means that the processing of the electronic device is insufficient or the processing capacity is excessive. At this time, according to the idle rate, the adjustment parameter value of the video encoding parameter can be determined in real time and dynamically; according to the first parameter value and the adjustment parameter value determined in real time, the reasonable second parameter value of the video encoding parameter in the current state of the electronic device can be determined; according to the second parameter value, the first video stream is encoded and processed, and the video encoding processing can be performed based on the real-time processing capability of the electronic device, avoiding the occurrence of freezes and interruptions, and obtaining a smooth and stable second video stream. Thus, the fluency of the second video obtained by encoding the first video stream can meet the viewing needs.

[0264] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.

[0265] The electronic device may include a processor 301 and a memory 302 storing computer program instructions.

[0266] Specifically, the processor 301 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0267] The memory 302 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 302 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 302 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 302 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 302 is a non-volatile solid-state memory. In a specific embodiment, the memory 302 includes a read-only memory (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.

[0268] The processor 301 implements any one of the video encoding methods in the embodiments shown in the figure by reading and executing the computer program instructions stored in the memory 302.

[0269] In one example, the electronic device may further include a communication interface 303 and a bus 310. Figure 3 As shown, the processor 301, the memory 302, and the communication interface 303 are connected via a bus 310 and communicate with each other.

[0270] The communication interface 303 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0271] Bus 310 includes hardware, software or both, and the parts of electronic equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 310 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0272] The electronic device can execute the video encoding method in the embodiment of the present application, thereby realizing the combination Figure 2 Describes the video encoding method.

[0273] In addition, in combination with the video encoding method in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, the Figure 2 Video encoding method.

[0274] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.

[0275] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0276] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0277] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A video encoding method, characterized in that: The method comprises: In the process of collecting the first video stream, obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate and video encoding image quality; When the idle rate is outside a preset idle rate interval, determining an adjustment parameter value of the video encoding parameter according to the idle rate; Determining a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value; The first video stream is encoded according to the second parameter value to obtain a second video stream.

2. The method according to claim 1, characterized in that In the process of acquiring the first video stream, before obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time, the method further includes: Acquire hardware type information of the electronic device, the hardware type information including: chip type and chip model; A first parameter value of the video encoding parameter is determined according to the hardware type information.

3. The method according to claim 2, characterized in that The determining, according to the hardware type information, a first parameter value of the video encoding parameter comprises: Determine an initial idle rate of the processor when an application is started; the application is a program for performing real-time video encoding on the first video stream; wherein the processor includes a GPU and a CPU; when the GPU is used for encoding processing, the initial idle rate is the idle rate of the GPU, and when the CPU is used for encoding processing, the initial idle rate is the idle rate of the CPU; A first parameter value of the video encoding parameter is determined according to the hardware type information and the initial idle rate.

4. The method according to claim 1, characterized in that: In the process of acquiring the first video stream, before obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time, the method further includes: Acquiring hardware environment information of the electronic device; A video encoding method is determined according to the hardware environment information, so as to perform real-time video encoding processing on the first video stream based on the video encoding method.

5. The method according to claim 1, characterized in that The preset duration includes: T1, the video encoding parameter corresponding to T1 is the video encoding image quality; T2, the video encoding parameter corresponding to T1 is the video encoding frame rate; T3, the video encoding parameter corresponding to T1 is the video encoding resolution; The T1 is smaller than the T2, and the T2 is smaller than the T3.

6. The method according to claim 1, characterized in that When the idle rate is outside the preset idle rate interval, determining the adjustment parameter value of the video encoding parameter according to the idle rate includes: In the case where the idle rate is less than the lower limit of the preset idle rate interval, determining the adjustment parameter value according to the idle rate and the preset level relationship, the adjustment parameter value is used to indicate the parameter value level of the video encoding parameter to be reduced; In a case where the idle rate is greater than an upper limit of the preset idle rate interval, determining the adjustment parameter value according to the idle rate and the preset level relationship, the adjustment parameter value being used to indicate an increase in the parameter value level of the video encoding parameter; The preset level relationship includes adjusting the relationship between the parameter value and the parameter value level.

7. The method according to claim 1, characterized in that In the process of acquiring the first video stream, before obtaining the idle rate of the processor of the electronic device and the first parameter value of the video encoding parameter at every preset time, the method further includes: Acquiring system information of the operating system of the electronic device; The idle rate is determined according to system information of the operating system.

8. A video encoding device, characterized in that: The video encoding device comprises: An acquisition module is used to acquire an idle rate of a processor of the electronic device and a first parameter value of a video encoding parameter at a preset time interval during the process of acquiring the first video stream; the video encoding parameter is a parameter for real-time video encoding of the first video stream, and the video encoding parameter includes: video encoding resolution, video encoding frame rate, and video encoding image quality; A determination module, configured to determine, when the idle rate is outside a preset idle rate interval, an adjustment parameter value of the video encoding parameter according to the idle rate; The determination module is further used to determine a second parameter value of the video encoding parameter according to the first parameter value and the adjustment parameter value; The encoding module is used to encode the first video stream according to the second parameter value to obtain a second video stream.

9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the video encoding method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the video encoding method according to any one of claims 1 to 7 is implemented.