WO2020118601A1 - 视频编码方法、装置、电子设备及存储介质 - Google Patents

视频编码方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2020118601A1
WO2020118601A1 PCT/CN2018/120828 CN2018120828W WO2020118601A1 WO 2020118601 A1 WO2020118601 A1 WO 2020118601A1 CN 2018120828 W CN2018120828 W CN 2018120828W WO 2020118601 A1 WO2020118601 A1 WO 2020118601A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
video
encoder
load rate
encoding
Prior art date
Application number
PCT/CN2018/120828
Other languages
English (en)
French (fr)
Inventor
胡小朋
Original Assignee
深圳市欢太科技有限公司
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市欢太科技有限公司, Oppo广东移动通信有限公司 filed Critical 深圳市欢太科技有限公司
Priority to CN201880098554.6A priority Critical patent/CN112840663B/zh
Priority to PCT/CN2018/120828 priority patent/WO2020118601A1/zh
Publication of WO2020118601A1 publication Critical patent/WO2020118601A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/70Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by syntax aspects related to video coding, e.g. related to compression standards

Definitions

  • the present application relates to the technical field of electronic equipment, and more specifically, to a video encoding method, device, electronic equipment, and storage medium.
  • this application proposes a video encoding method, device, electronic device, and storage medium to improve the encoding quality of video.
  • an embodiment of the present application provides a video encoding method, the method includes: when an application is detected to start video recording, acquiring a default encoding code rate corresponding to the application; determining the default encoding code Whether the bit rate is lower than the bit rate threshold; if it is lower than the bit rate threshold, then the application is controlled to select a designated soft encoder to encode the video data of the video.
  • an embodiment of the present application provides a video encoding device.
  • the device includes: a bit rate acquisition module, a bit rate judgment module, and an encoding control module, wherein the recording detection module is used to detect the start of an application When performing video recording, obtain the default encoding bit rate corresponding to the application; the bit rate determining module is used to determine whether the default encoding bit rate is lower than the bit rate threshold; the encoding control module is used if The code rate threshold controls the application to select a designated soft encoder to encode the video data of the video.
  • an embodiment of the present application provides an electronic device, including: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and It is configured to be executed by the one or more processors, and the one or more programs are configured to perform the video encoding method provided in the first aspect described above.
  • an embodiment of the present application provides a storage medium, and the computer-readable storage medium stores program code, and the program code can be called by a processor to execute the video encoding method provided in the first aspect.
  • the control application program selects the designated soft encoder to encode the video data of the video.
  • This method can determine the default coding rate according to the recorded video when the default coding rate is less than the code rate threshold, using a designated soft encoder to encode, thereby improving the flexibility of the encoding method and improving the encoding when recording low bit rate video quality.
  • FIG. 1 shows a flowchart of a video encoding method according to an embodiment of the present application.
  • FIG. 2 shows a flowchart of a video encoding method according to another embodiment of the present application.
  • FIG. 3 shows a flowchart of step S260 in the video encoding method according to an embodiment of the present application
  • FIG. 4 shows a flowchart of a video encoding method according to yet another embodiment of the present application.
  • FIG. 5 shows a block diagram of a video encoding device according to an embodiment of the present application.
  • FIG. 6 shows a block diagram of an encoding control module in a video encoding device according to an embodiment of the application.
  • FIG. 7 is a block diagram of an electronic device for performing a video encoding method according to an embodiment of the present application.
  • FIG. 8 is a storage unit for storing or carrying program codes for implementing a video encoding method according to an embodiment of the present application.
  • an electronic device can run a client with a video recording function, and then trigger the client's video recording function to perform video recording, and finally store or transmit the recorded video to other devices.
  • the methods of encoding video mainly include hard coding methods and soft coding methods.
  • hard coding is performed by a dedicated hardware module (that is, a circuit board), for example, a GPU (Graphics Processing Unit, graphics processor) is usually used for encoding.
  • Soft coding is to use CPU (Central Processing Unit, central processing unit) for coding. The implementation is simple, the parameter adjustment is convenient, and the upgrade is easy, but the CPU load is heavy and the performance is lower than hard coding.
  • hard coding technology does not occupy CPU resources, it can save CPU resources.
  • Most applications will prefer to use hard coding for video encoding, such as using the hard encoder that comes with the system.
  • the inventor found that although video encoding is performed by hard coding, the load of the CPU can be reduced, the resources of the CPU can be released, and the smoothness of the system can be improved. However, when encoding a video with a low bit rate, the encoding quality of the hard encoding method is lower than that of the soft encoding method, which results in poor quality of the recorded video.
  • the inventor after a long period of research and proposed the video encoding method, device, electronic device, and storage medium provided by the embodiments of the present application, when the application is detected to start video recording, the default encoding bit rate of the application is determined Whether it is lower than the bit rate threshold, if it is lower than the bit rate threshold, the control application chooses to specify a soft encoder to encode the video data of the video, thereby improving the flexibility of the encoding method and improving the encoding when recording low bit rate video quality.
  • an embodiment of the present application provides a video encoding method, which can be applied to electronic devices.
  • the video encoding method may include:
  • Step S110 When it is detected that the application program starts to record video, the default encoding code rate corresponding to the application program is obtained.
  • the electronic device When the electronic device records video, it encodes the acquired video data (for example, the video data collected by the camera) to obtain a video file for storage or transmission. Since hard coding can save CPU resources, applications of electronic devices usually prefer to use hard coding to encode video data. For all videos, if the hard-coding method is used for encoding, when the default encoding rate of the recorded video required by the application is low, the encoding quality will be poor, and finally the recorded video quality will be poor.
  • the default encoding code rate corresponding to the application when an application is detected to start video recording, the default encoding code rate corresponding to the application may be determined, wherein the default encoding code rate corresponding to the application is the encoding of the recorded video required by the application The bit rate in the parameter.
  • the electronic device may determine whether the application program starts video recording in various ways.
  • the electronic device can detect whether the video recording interface is called, and when receiving a call request from the application program to the video recording interface, it is determined that the application program is detected to start video recording. For example, it can be detected whether an application call request to the interface MediaProjection or MediaProjectionManage is received. When a call request to the above interface is received, the application is confirmed to start video recording.
  • the electronic device can detect whether the setting application is running in the foreground, and when the setting application is running in the foreground, it can be sure that the application starts video recording.
  • the above setting application may be an application for video recording.
  • the electronic device may store a list or list of application programs for video recording. The list or list can be freely configured by the user of the electronic device. The electronic device can first detect which application is currently running in the foreground, and then further detect whether the application currently running in the foreground is on the list. If it is, then it is determined that it is currently in the video playback state.
  • the electronic device is an Android operating system
  • the name of the application currently running in the foreground can be obtained by executing the getRunningTasks method of ActivityManager.
  • the electronic device can also obtain a list of programs used by the user through the UsageStatsManager, and identify the most recently used application recorded in the list as the current foreground application.
  • the recording control in the interface of the application is triggered, it is determined that the application starts video recording.
  • the default encoding code rate corresponding to the application program that is, the encoding code rate required by the application program to record video may be obtained.
  • the encoding parameters include: video size, resolution, code rate, format, etc.
  • the default encoding bit rate corresponding to the application program can be obtained.
  • the specific way of obtaining the default encoding bit rate corresponding to the application program may not be limited in the embodiments of the present application.
  • Step S120 Determine whether the default coding rate is lower than the code rate threshold.
  • the default encoding code rate corresponding to the application can be compared with the code rate threshold to determine whether the default encoding code rate is lower than the code rate threshold.
  • the code rate threshold is used to divide the low code rate and other code rates, that is, when the code rate is lower than the code rate threshold, it is a low code rate.
  • the specific bit rate threshold may not be limited, for example, the bit rate threshold may be 2 Mbps (megabits per second) or 1.52 Mbps.
  • Step S130 If it is lower than the code rate threshold, control the application to select a designated soft encoder to encode the video data of the video.
  • the control application program chooses to designate a soft encoder to encode the video data of the video.
  • the designated soft encoder is an encoder that uses a soft encoding method.
  • the designated soft encoder may be a third-party soft encoder or a system soft encoder.
  • the specific designated soft encoder may not be limited.
  • the designated soft encoder is used to encode the video data of the video.
  • the application can use hard coding (for example, using the system's hard encoder or other hard encoder) to encode the video data.
  • the video encoding method provided by the embodiment of the present application obtains the default encoding code rate corresponding to the application when it detects that the application starts video recording, and then determines whether the default encoding code rate is lower than the code rate threshold. When the rate is lower than the bit rate threshold, the control application chooses to specify a soft encoder to encode the video data. Compared with the hard encoding method, the video data is encoded, which improves the encoding quality and thus the quality of the recorded video.
  • FIG. 2 another embodiment of the present application provides a video encoding method, which can be applied to an electronic device.
  • the video encoding method may include:
  • Step S210 When it is detected that the application program starts video recording, the default encoding code rate corresponding to the application program is obtained.
  • Step S220 Determine whether the default coding rate is lower than the code rate threshold.
  • steps S210 and S220 reference may be made to the content of the foregoing embodiments, and details are not described herein again.
  • Step S230 If it is lower than the bit rate threshold, determine whether the application is in the set list.
  • the above setting list may be an application program for controlling video data that needs to be encoded by a designated soft encoder when recording a low bit rate video. That is to say, when the default encoding bit rate required by the applications in the list to record video is lower than the above-mentioned bit rate threshold, the above-mentioned designated soft encoder needs to be used to encode the video data.
  • the setting list may include identification information of applications in the list, and the identification information may include process names, package names, etc. Of course, specific identification information may not be used as a limitation.
  • the process name can be used to determine whether the above-mentioned application is within the setting content. Therefore, judging whether the application is in the set list may include: acquiring the process name of the application; judging whether the process name is the same as the process name of the application in the set list.
  • the process name of the application program can be obtained.
  • the process name can be obtained through Process.myPid() and RunningAppProcessInfo to obtain the process name of the processor currently running.
  • the specific method of obtaining the process name may not be limited.
  • the package name may be used to determine whether the above-mentioned application is in the set list. Therefore, determining whether the application is in the set list may include: acquiring the package name of the application; determining whether the package name is the same as the package name of the application in the set list.
  • the adb command to view the package name of the application.
  • the specific way to obtain the package name may not be limited.
  • the obtained package name is the same as the package name of the application in the setting list, it can be determined that the application that starts video recording is in the setting list; when the obtained package name is obtained.
  • the package name of the application in the above setting list is different, it can be determined that the above application for starting video recording is not in the setting list.
  • the application can use hard coding (for example, using the system's hard encoder or other hard encoder) to encode the video data.
  • Step S240 If it is in the set list, obtain the load rate of the central processor.
  • the load ratio refers to the ratio of the load of the CPU to the maximum load of the CPU.
  • the CPU load rate is not a fixed state. For example, when only one application is running, the CPU load rate may be 10%, and when two applications are running, the CPU load rate may be 20%, and when three applications are running, the CPU load may be The rate reached 35%.
  • obtaining the load rate of the CPU may include: obtaining the load rate of the central processor in real time or periodically during the video recording process. It can be understood that, after the video recording is started, the CPU load rate can also be obtained to determine whether the application program uses the specified soft encoder to encode the video data to avoid the CPU load rate being too high, which may cause a stuck or application crash. Wait. Obtaining the load factor of the CPU at regular intervals may be obtaining the load factor of the CPU at a set interval.
  • the foregoing obtaining the load rate of the central processor may include: obtaining the load rate of the central processor, including: obtaining the current load rate of the central processor; and estimating that the central processor is within a set duration The increase rate of the load rate; obtain the sum of the increase rate of the load rate and the current load rate, and use the sum as the load rate of the central processor.
  • the electronic device can estimate the running time of the application program. For example, the electronic device can record the running time of each installed application program, and divide the time into multiple time periods, and the running time of each application program corresponds to the time period, so that the time period that each application program frequently runs can be obtained. Furthermore, according to the time period during which each application program frequently runs, it can be inferred which applications will be started within a certain time period. In addition, among the applications installed in the electronic device, some applications will periodically perform some tasks, such as regularly updating, obtaining data from the network, or performing data processing. When performing the above tasks, it will increase the CPU load rate to a certain extent. Therefore, you can record the running time of each application and the CPU load rate during runtime to estimate changes in the CPU load rate.
  • the load rate of the central processor can be obtained, and the obtained load rate of the central processor can be used to determine whether to use the above-mentioned designated soft coding
  • the standard of the video data encoding device is a standard of the video data encoding device.
  • the current load rate of the CPU is obtained.
  • the operating system of the electronic device is the Android system
  • the system load condition and the process time can be obtained through the ProcessStats class in the Android system.
  • the specific implementation principle is to read the files in the /proc directory.
  • the kernel will update the files in the /proc directory and write the PID operation status into the corresponding file.
  • the current load rate of the central processor can be obtained.
  • the above way of obtaining the current load rate of the central processor is not limited in the implementation of this application.
  • the electronic device can estimate the amount of increase in the load rate of the content of the CPU in the set duration based on the running time of each application program recorded above and the load factor of the CPU at runtime. Therefore, the estimated increase in the load rate of the central processor within a set duration may include:
  • the historical load rate of the CPU corresponding to the above-mentioned video recording start application within a set duration is determined.
  • the current time is time A
  • the CPU when application 2 is running The load rate is 30%. Since the application 1 and the application 2 are running in the same time period, the maximum CPU load rate when the two are running, that is, 30%, can be taken as 30% as the above application for starting video recording Corresponding historical load rate of CPU within the set duration.
  • the amount of increase in the load rate of the CPU within the set time period can be estimated based on the above-mentioned historical load rate.
  • the above-mentioned historical load rate may be used as an increase in the load rate of the CPU within the set duration.
  • the above-mentioned set duration can be set as the above-mentioned application program for starting video recording, and the historical recording duration of recorded video. It is understandable that the electronic device can record the historical recording duration of the application each time a video is recorded.
  • the above-mentioned set duration can be the average of multiple historical recording durations recorded, or the maximum value among multiple historical recording durations . Therefore, the stability during the video recording can be ensured, and the occurrence of jams can be avoided.
  • the current load rate and the increase in the load rate can be calculated, and the sum of the two can be used as the central processor's Load rate.
  • Step S250 Determine whether the load factor is lower than the first load factor threshold.
  • the load ratio after obtaining the load ratio of the CPU of the electronic device, the load ratio can be compared with the first load ratio threshold to determine whether the load ratio is lower than the first load ratio threshold.
  • the CPU load rate can be divided into a first level and a second level, wherein the load rate below the first load rate threshold is at the first level, and the load rate not lower than the first load rate threshold is at the second level .
  • the load rate is the first level, it means that the CPU load is very low within the above set duration, that is, the tasks that need to be executed by the CPU are very small, that is, the number of threads is very low; when the load rate is the second level, It means that the load of the CPU is low within the above set duration, that is to say, fewer tasks need to be executed by the CPU, that is, the number of threads is lower, but there are more tasks that need to be executed by the CPU and the number of threads The number of threads is higher than the first level.
  • the first load rate threshold can be determined according to the parameters of the CPU and the like, which is related to the performance of the CPU. As an implementation manner, when the maximum operating frequency of the CPU is high, it can still support encoding using a designated soft encoder when the load rate reaches a high level, which can be higher than that of the CPU with a lower maximum operating frequency. For example, the maximum operating frequencies of the two CPUs are 1 GHz and 2 GHz respectively. If the first load rate threshold corresponding to the maximum operating frequency of 1 GHz is 50%, the first load rate threshold corresponding to the maximum operating frequency of 2 GHz is 65%. Of course, the above first load rate threshold is only an example, and does not represent a limitation on the specific first load rate threshold in the embodiments of the present application.
  • Step S260 If it is lower than the first load rate threshold, control the application to select a designated soft encoder to encode the video data of the video.
  • the designated soft encoder is used to perform Encoding does not overload the CPU. Therefore, you can control the application to choose a designated soft encoder to encode video data to obtain a video file.
  • the load factor of the CPU When it is determined that the load factor of the CPU is not lower than the first load rate threshold, it indicates that the load of the CPU is low within the above set duration, but at this time, the designated soft coding is used for encoding, which may cause CPU load
  • the rate is at a high level, which leads to stuttering, so you can control the application to select the system’s hard encoder or soft encoder to encode video data
  • the encoder for encoding video data includes: The encoder includes: a designated soft encoder, a system hard encoder, and a system soft encoder.
  • the hard encoder of the system is the hard encoder that comes with the system of the electronic device, such as the Android platform AVC (Advanced Video Coding, Advanced Video Coding) hard encoder.
  • the soft encoder of the system is the soft encoder that comes with the system of the electronic device, such as Google AVC soft encoder.
  • the electronic device can also be installed with a specified soft encoder.
  • the specified soft encoder can be mounted with an efficient AVC soft encoder through the OpenMax architecture.
  • This soft encoder can be open source
  • the ffmpeg AVC encoder can also be a three-party AVC encoder integrated with other manufacturers.
  • the designated soft encoder's encoding effect on the video is better than the system's soft encoder's encoding effect on the video.
  • the designated soft encoder can overcome the encoding block effect and mosaic.
  • the encoder for encoding video data in the electronic device may also include other encoders.
  • an application program when an encoder is selected, it is usually selected according to the priority relationship of the encoder, that is, an encoder with a high priority is selected to encode video data.
  • the priority relationship of the encoder selected by the application program is that the priority of the system's hard encoder is greater than that of the system's soft encoder, and the priority of the system's soft encoder is greater than that of other encoders (including the above-mentioned designated soft encoders). ). Therefore, referring to FIG. 3, controlling the application program to select a designated soft encoder to encode the video data of the video may include:
  • Step S261 Adjust the priority of the designated soft encoder to the highest priority, and the priority is the priority of the encoder selected by the application.
  • the priority relationship between the encoders according to the system is that the priority of the system's hard encoder is the largest. Therefore, the priority of the designated soft encoder can be adjusted to the highest priority, so that the application can select the designated soft encoder to encode the video data when selecting the encoder according to the priority of the encoder.
  • Step S262 Control the application to select the designated soft encoder with the highest priority to encode the video data of the video.
  • the latest priority can be transmitted to the application program, so that the application program can select the designated soft encoder to perform the video data according to the priority of the new encoder. Encoding, to realize the control application chooses the designated soft encoder to encode.
  • the video encoding method may further include: reducing the operating frequency of the image processor.
  • the application program is encoded using soft encoding, it will not use the GPU for hard encoding.
  • the GPU often has high performance, so the operating frequency of the image processor can be appropriately reduced, so that the power consumption of electronic devices reduce.
  • the specific degree to which the working frequency of the GPU needs to be reduced may not be limited in the embodiments of the present application, and it may be determined according to the performance parameters of the GPU.
  • the video encoding method provided by the embodiment of the present application obtains the default encoding bit rate corresponding to the application when it is detected that the application starts to record video, and when the default encoding bit rate is lower than the bit rate threshold, it is determined whether the application is in In the setting list, when it is determined that the application is in the setting list, it is determined whether the application uses the designated soft encoder to encode the video data according to the load rate of the CPU. Since the coding effect of the specified soft encoder is better than the hard encoder and soft encoder of the system, the encoding effect during video recording can be improved, thereby improving the video quality of the recorded video.
  • yet another embodiment of the present application provides a video encoding method, which can be applied to electronic devices.
  • the video encoding method may include:
  • Step S310 When it is detected that the application program starts video recording, the default encoding code rate corresponding to the application program is obtained.
  • Step S320 Determine whether the default encoding code rate is lower than the code rate threshold.
  • steps S310 and S320 reference may be made to the content of the foregoing embodiments, and details are not described herein again.
  • Step S330 If it is lower than the bit rate threshold, determine whether the application is in the set list.
  • a setting list is set in the electronic device.
  • the setting list is used to control an application program that needs to encode video data by specifying a soft encoder when recording a low bit rate video.
  • the above setting list can be set by the user. For example, multiple applications can be displayed in the setting interface, and the status corresponding to each application. It can be understood that if the status corresponding to the application is "off", it means that the application is removed or not added to the above In the set list, if the corresponding state of the application is "on”, it means that the application is added to the above list. Therefore, in the embodiment of the present application, the video encoding method may further include:
  • the application is set in a set list.
  • the application can be set in the setting list according to the first operation.
  • the electronic device may also be set to use the specified soft encoder.
  • the specified soft encoder can be used to encode the video data.
  • the video encoding method may further include: according to the detected second operation, opening the permission of the application to use the specified soft encoder.
  • the video encoding method may further include: if the bit rate threshold is not lower than, controlling the application program to select a hard encoder of the system or a soft encoder of the system for the video Encode video data.
  • Step S340 If it is in the set list, obtain the load rate of the central processor.
  • Step S350 determine whether the load factor is lower than the first load factor threshold.
  • Step S360 If it is lower than the first load rate threshold, control the application to select a designated soft encoder to encode the video data of the video.
  • steps S340 and S360 reference may be made to the content of the foregoing embodiments, and details are not described herein again.
  • Step S370 If it is not lower than the first load rate threshold, it is determined whether the load rate is lower than the second load rate threshold, and the second load rate threshold is greater than the first load rate threshold.
  • the load factor of the CPU if it is determined that the load factor of the CPU is not lower than the first load rate threshold, that is, the load factor of the CPU is greater than or equal to the first load rate threshold, it means that if the CPU executes the process of specifying the soft encoder at this time , May cause stuttering.
  • the CPU may cause a freeze due to the soft encoder designated by the CPU to encode the video data. Therefore, in the embodiment of the present application, when the load rate of the CPU is not less than the first load rate threshold, it can be determined that the CPU is in a state where it cannot be very low, that is, a state in which the system soft encoder cannot be used for video encoding.
  • the system soft encoder when the CPU load rate is not less than the first load rate threshold, it can be determined whether the CPU load rate is lower than the second load rate threshold, where the second load rate threshold is greater than the first load rate threshold to determine When the load rate of the CPU is not less than the first load rate threshold, can the system soft encoder be used for video encoding.
  • the second load rate threshold may be a critical value of the load rate when the CPU cannot use the system's soft encoder for video encoding, and the CPU may use the system's soft encoder for video encoding. That is to say, when the load rate of the CPU is not lower than the second load rate threshold, the load rate is at a low level, and the remaining resources of the CPU cannot support encoding using the specified soft encoder, but the system soft encoder can be used for encoding ; When the CPU load rate is lower than the second load rate threshold, the CPU load rate is at a high level, and the remaining resources of the CPU cannot support the encoding using the specified soft encoder or the system soft encoder.
  • the second load rate threshold may also be determined according to CPU performance parameters and the like.
  • Step S380 If it is lower than the second load rate threshold, control the soft encoder of the application selection system to encode the video data of the video.
  • the system soft encoder when it is determined that the load factor of the CPU is not lower than the second load rate threshold, since the remaining resources of the CPU cannot support the encoding using the designated soft encoder, but the system soft encoder can be used for encoding, so it can be used
  • the soft encoder of the system encodes the video data of the recorded video. Compared with the use of hard coding technology to encode low bit rate video, it can also improve the encoding quality of the video.
  • the control application selects and assigns a soft encoder to encode video data
  • the priority of the system’s soft encoder can be adjusted to the highest priority, and the control application selects the soft encoder of the system with the highest priority To encode video data.
  • Step S390 If it is not lower than the second load rate threshold, control the hard encoder of the application selection system to encode the video data of the video.
  • the CPU load rate when it is determined that the CPU load rate is lower than the second load rate threshold, the CPU load rate is at a high level, and the remaining resources of the CPU cannot support encoding using the specified soft encoder, nor can it support the use of system software.
  • the encoder encodes, so the application should use the system's hard encoder to encode the video data.
  • the priority of the system's hard encoder can be adjusted to the highest priority, and the control application selects the hard encoder of the system with the highest priority To encode video data.
  • the video encoding method may further include: detecting whether the load rate of the image processor is lower than the third load Rate threshold; if it is lower than the third load rate threshold, the operating frequency of the image processor is reduced.
  • the application program is encoded using soft encoding, it will not use the GPU for hard encoding.
  • the GPU often has high performance, so the operating frequency of the image processor can be appropriately reduced, so that the power consumption of electronic devices reduce.
  • the specific degree to which the working frequency of the GPU needs to be reduced may not be limited in the embodiments of the present application, and it may be determined according to the performance parameters of the GPU.
  • it can also be determined whether to reduce the working frequency of the GPU according to the actual working condition of the GPU.
  • the load rate of the GPU is lower than the third load rate threshold, it means that the GPU has more remaining resources, so the operating frequency of the GPU can be appropriately reduced to reduce the power consumption of the electronic device.
  • the specific value of the third load rate threshold can be used as a limit, and can be determined according to the performance parameters of the GPU.
  • the video encoding method provided by the embodiment of the present application obtains the default encoding bit rate corresponding to the application when it is detected that the application starts to record video, and when the default encoding bit rate is lower than the bit rate threshold, it is determined whether the application is in In the setting list, when it is determined that the application is in the setting list, it is determined whether the application uses the designated soft encoder to encode the video data according to the load rate of the CPU. Since the coding effect of the specified soft encoder is better than the hard encoder and soft encoder of the system, the encoding effect during video recording can be improved, thereby improving the video quality of the recorded video.
  • the system hard code or soft encoder is further used for encoding according to the CPU load rate.
  • the system soft encoder is used for encoding At the same time, relative to the use of hard coding technology to encode low bit rate video, it can also improve the video encoding quality.
  • FIG. 5 shows a block diagram of a video encoding apparatus 400 provided by an embodiment of the present application.
  • the video encoding device 400 is applied to the above mobile terminal.
  • the device shown in FIG. 5 will be described below.
  • the video encoding device 400 includes: a code rate acquisition module 410, a code rate judgment module 420, and an encoding control module 430.
  • the recording detection module 410 is used to obtain the default encoding bit rate corresponding to the application when it detects that the application starts video recording; the code rate determining module 420 is used to determine whether the default encoding bit rate Below the code rate threshold; the encoding control module 430 is used to control the application to select a designated soft encoder to encode the video data of the video if it is below the code rate threshold.
  • the encoding control module 430 includes: a priority adjustment unit 431 and a control execution unit 432.
  • the priority adjustment unit 431 is used to adjust the priority of the designated soft encoder to the highest priority, and the priority is the priority of the application to select the encoder;
  • the control execution unit 432 uses In order to control the application program to select the designated soft encoder with the highest priority to encode the video data of the video.
  • the encoding effect of the designated soft encoder on the video is better than that of the system soft encoder on the video.
  • the encoding control module 430 may be specifically configured to: if it is lower than the bit rate threshold, determine whether the application is in the set list; if it is in the set list, control the The application program selects a designated soft encoder to encode the video data of the video.
  • the encoding control module 430 determines whether the application is in the set list, including: acquiring the process name of the application; determining whether the process name is the same as the process name of the application in the set list.
  • the encoding control module 430 determines whether the application is in the set list, including: acquiring the package name of the application; determining whether the package name is the same as the package name of the application in the set list .
  • the video encoding device 400 may further include: a list setting module.
  • the list setting module is used to set the application in the set list according to the detected first operation.
  • the video encoding device 400 may further include: a permission enabling module.
  • the permission opening module is used to enable the application to use the specified soft encoder according to the detected second operation.
  • the video encoding device 400 may further include: a load rate acquisition module and a first load rate determination module.
  • the load rate obtaining module is used to obtain the load rate of the central processor before the controlling the application program to select a designated soft encoder to encode the video data of the video;
  • the first load rate determining module is used to determine the load rate Whether the load rate is lower than the first load rate threshold. If it is lower than the first load rate threshold, the encoding control module controls the application to select a designated soft encoder to encode the video data of the video.
  • the video encoding device 400 may further include: a second load rate determination module, a first encoding module, and a second encoding module.
  • the second load rate determination module is used to determine whether the load rate is lower than the second load rate threshold if the first load rate threshold is not lower than the first load rate threshold, and the second load rate threshold is greater than the first load Rate threshold;
  • the first encoding module is used to control the soft encoder of the application selection system to encode the video data of the video if it is below the second load rate threshold;
  • the second encoding module is used if not Below the second load rate threshold, the hard encoder of the application selection system is controlled to encode the video data of the video.
  • the load rate acquisition module may be specifically used to acquire the load rate of the central processor in real time or periodically during video recording.
  • the load rate acquisition module may be specifically used to: obtain the current load rate of the central processor; estimate the increase rate of the load rate of the central processor within a set duration; obtain the increase rate of the load rate and The sum value of the current load rate, the sum value is used as the load rate of the central processor.
  • the first load rate obtaining module estimates the increase in the load rate of the central processor within a set duration, which may include: obtaining the historical load rate of the central processor corresponding to the application within the set duration; The historical load rate estimates an increase in the load rate of the central processor within the set duration.
  • the video encoding device 400 may further include: a third encoding module.
  • the third encoding module is configured to: if the bit rate threshold is not lower than, control the application program to select a hard encoder of the system or a soft encoder of the system to encode the video data of the video.
  • the video encoding device 400 may further include: a frequency reduction module.
  • the frequency reduction module is used to reduce the working frequency of the image processor after controlling the application program to select a designated soft encoder to encode the video data of the video.
  • the video encoding device 400 may further include: a second load rate judgment module.
  • the second load rate determination module is used to detect whether the load rate of the image processor is lower than the third load rate threshold before reducing the operating frequency of the image processor. If it is lower than the third load rate threshold, the frequency reduction module reduces the operating frequency of the image processor.
  • the coupling between the modules may be electrical, mechanical, or other forms of coupling.
  • each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above integrated modules may be implemented in the form of hardware or software function modules.
  • the solution provided in this application obtains the default encoding bit rate corresponding to the application when it detects that the application starts video recording, and determines whether the default encoding bit rate is lower than the code rate threshold, and if it is lower than With this bit rate threshold, the control application program selects the designated soft encoder to encode the video data of the video.
  • This method can determine the default coding rate according to the recorded video when the default coding rate is less than the code rate threshold, using a designated soft encoder to encode, thereby improving the flexibility of the encoding method and improving the encoding when recording low bit rate video quality.
  • the electronic device 100 may be an electronic device capable of running an application program such as a smart phone, a tablet computer, an e-book.
  • the electronic device 100 in this application may include one or more of the following components: a processor 110, a memory 120, and one or more application programs, where one or more application programs may be stored in the memory 120 and configured to be configured by one Executed by one or more processors 110, and one or more programs are configured to execute the method as described in the foregoing method embodiments.
  • the processor 110 may include one or more processing cores.
  • the processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, executes or executes instructions, programs, code sets or instruction sets stored in the memory 120, and calls data stored in the memory 120 to execute Various functions and processing data of the electronic device 100.
  • the processor 110 may adopt at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA) Various hardware forms.
  • the processor 110 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), an image processing unit (Graphics Processing Unit, GPU), and a modem.
  • CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • modem modem
  • CPU mainly deals with operating system, user interface and application program, etc.
  • GPU is used for rendering and rendering of display content
  • modem is used for handling wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 110, and may be implemented by a communication chip alone.
  • the memory 120 may include random access memory (RAM) or read-only memory (Read-Only Memory).
  • the memory 120 may be used to store instructions, programs, codes, code sets, or instruction sets.
  • the memory 120 may include a storage program area and a storage data area, where the storage program area may store instructions for implementing an operating system and instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.) , Instructions for implementing the following method embodiments.
  • the storage data area may also store data created by the terminal 100 in use (such as a phone book, audio and video data, and chat history data).
  • FIG. 8 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
  • the computer readable medium 800 stores program codes, and the program codes can be called by a processor to execute the method described in the above method embodiments.
  • the computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium.
  • the computer-readable storage medium 800 has a storage space for the program code 810 that performs any of the method steps described above. These program codes can be read from or written into one or more computer program products.
  • the program code 810 may be compressed in an appropriate form, for example.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请公开了一种视频编码方法、装置、电子设备及存储介质,该视频编码方法包括:在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;判断所述默认编码码率是否低于码率阈值;如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。本方法可以提升录制的视频的编码质量。

Description

视频编码方法、装置、电子设备及存储介质 技术领域
本申请涉及电子设备技术领域,更具体地,涉及一种视频编码方法、装置、电子设备及存储介质。
背景技术
电子设备,例如电脑、手机等,已经成为人们日常生活中最常用的消费型电子产品之一。电子设备在进行视频录制时,通常会对视频数据进行编码后再进行存储或者传输。目前,在多种视频编码技术中,由于硬编码可以节省中央处理器的负载,编码效率高等优势,从而逐渐被广泛应用,但是硬编码在一些情况下的编码质量存在问题。
发明内容
鉴于上述问题,本申请提出了一种视频编码方法、装置、电子设备及存储介质,以提升视频的编码质量。
第一方面,本申请实施例提供了一种视频编码方法,所述方法包括:在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;判断所述默认编码码率是否低于码率阈值;如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
第二方面,本申请实施例提供了一种视频编码装置,所述装置包括:码率获取模块、码率判断模块以及编码控制模块,其中,所述录制检测模块用于在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;所述码率判断模块用于判断所述默认编码码率是否低于码率阈值;所述编码控制模块用于如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
第三方面,本申请实施例提供了一种电子设备,包括:一个或多个处理器;存储器;一个或多个应用程序,其中所述一个或多个应用程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行上述第一方面提供的视频编码方法。
第四方面,本申请实施例提供了一种存储介质,所述计算机可读取存储介质中存储有程序代码,所述程序代码可被处理器调用执行上述第一方面提供的视频编码方法。
本申请提供的方案,通过在检测到应用程序开始进行视频录制时,获取该应用程序对应的默认编码码率,判断该默认编码码率是否低于码率阈值,如果低于该码率阈值,则控制应用程序选择指定软编码器对视频的视频数据进行编码。本方法可以根据录制视频的默认编码码率,确定默认编码码率小于码率阈值时,采用指定软编码器进行编码,从而提升了编码方式的灵活性,且提升录制低码率视频时的编码质量。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了根据本申请一个实施例的视频编码方法流程图。
图2示出了根据本申请另一个实施例的视频编码方法流程图。
图3示出了根据本申请实施例的视频编码方法中步骤S260的流程图
图4示出了根据本申请又一个实施例的视频编码方法流程图。
图5示出了根据本申请一个实施例的视频编码装置的一种框图。
图6示出了根据本申请一个实施例的视频编码装置中编码控制模块的框图。
图7是本申请实施例的用于执行根据本申请实施例的视频编码方法的电子设备的框图。
图8是本申请实施例的用于保存或者携带实现根据本申请实施例的视频编码方法的程序代码的存储单元。
具体实施方式
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。
随着电子设备的硬件性能的提升,更多的电子设备可以支持进行视频的录制。例如,电子设备可以运行具备视频录制功能的客户端,然后通过触发客户端的视频录制功能,进行视频录制,最后将录制的视频进行存储或者传输至其他设备。
在进行视频录制时,无论最后将录制的视频存储于本地,还是传输至其他设备,为了能够降低对存储空间的占用以及便于在网络上传输,都会对生成的视频进行压缩编码。目前对视频进行编码的方式主要包括硬编码方式和软编码方式。其中,硬编码,是由专门的硬件模块(即电路板)进行编码工作,例如通常使用GPU(Graphics ProcessingUnit,图形处理器)进行编码。软编码,是使用CPU(Central ProcessingUnit,中央处理器)进行编码,实现方式简单,参数调整方便,升级容易,但CPU负载重,性能比硬编码低。
由于硬编码技术不会占用CPU的资源,可以节省CPU的资源,大多应用程序在进行视频编码时,会优先使用硬编码方式进行编码,例如使用***自带的硬编码器进行编码。
发明人经过长期研究发现,虽然采用硬编码方式进行视频编码,可以减少CPU的负载,释放CPU的资源,提升***运行流畅性。但是,在编码低码率的视频时,硬编码方式的编码质量低于软编码方式的编码质量,使录制的视频质量不佳。针对上述问题,发明人经过长时间的研究并提出了本申请实施例提供的视频编码方法、装置、电子设备以及存储介质,通过检测到应用程序开始视频录制时,判断应用程序的默认编码码率是否低于码率阈值,如果低于码率阈值,则控制应用程序选择指定软编码器对视频的视频数据进行编码,从而提升了编码方式的灵活性,且提升录制低码率视频时的编码质量。
下面对本申请实施例的视频编码方法进行详细介绍。
请参阅图1,本申请实施例提供了一种视频编码方法,可应用于电子设备,该视频编码方法可以包括:
步骤S110:在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率。
电子设备在进行视频录制时,会对获取的视频数据(例如摄像头采集的视频数据)进行编码后,得到用于存储或者传输的视频文件。由于硬编码方式可以节省CPU的资源,因此电子设备的应用程序通常会优先使用硬编码方式对视频数据进行编码。而对于所有视频,如果都采用硬编码方式进行编码,则在应用程序要求的录制视频的默认编码码率较低时,会使得编码质量较差,最后使录制的视频质量不佳。
因此,在本申请实施例中,可以在检测到应用程序开始进行视频录制时,确定应用程序对应的默认编码码率,其中,应用程序对应的默认编码码率为应用程序要求的录制视频的编码参数中的码率。
在本申请实施例中,电子设备可以通过多种方式来确定应用程序是否开始进行视频录制。
作为一种方式,电子设备可以通过检测视频录制接口是否被调用,当接收到应用程序对视频录制接口的调用请求,则确定检测到应用程序开始进行视频录制。例如,可以通过检测是否接收到应用程序对接口MediaProjection或者MediaProjectionManage 的调用请求,当接收到对上述接口的调用请求时,则确认出该应用程序开始进行视频录制。
作为另一种方式,电子设备可以通过检测设定应用程序是否在前台运行,当设定应用程序在前台运行时,则可以确应用程序开始进行视频录制。其中,上述设定应用程序可以是用于进行视频录制的应用程序。电子设备中可以存储有用于视频录制的应用程序的列表或者名单。其中,该列表或者名单可以由电子设备的用户自由配置。电子设备可以先检测当前在前台运行的应用程序是哪个,然后再进一步的检测当前前台运行的应用程序是否在该名单中,若在,那么就判定当前处于视频播放状态。其中,作为一种方式,若电子设备为Android操作***,可以通过执行ActivityManager的getRunningTasks方法来获取到当前在前台运行的应用程序的名称。此外,电子设备还可以通过UsageStatsManager来获取用户使用的程序的列表,将该列表中记录的最近使用的应用程序识别为当前的前台应用。再者,还可以通过Android自带无障碍功能,监控窗口焦点的变化,拿到焦点窗口对应包名作为当期在前台运行的应用程序。
作为又一种方式,可以通过检测应用程序的界面中的录制控件的触发状态,确认应用程序开始进行视频录制。当应用程序的界面中的录制控件被触发时,则确定应用程序开始进行视频录制。
当然,具体检测应用程序是否开始进行视频录制的方式在本申请实施例中可以不作为限定。
在本申请实施例中,在检测到应用程序开始进行视频录制时,可以获取该应用程序对应的默认编码码率,即应用程序要求录制视频的编码码率。其中,可以通过读取应用程序要求的编码参数,编码参数包括:视频尺寸、分辨率、码率、格式等。根据上述编码参数,即可得到应用程序对应的默认编码码率。当然,具体获取应用程序对应的默认编码码率的方式在本申请实施例中可以不作为限定。
步骤S120:判断所述默认编码码率是否低于码率阈值。
在获取到应用程序对应的默认编码码率之后,则可以将该应用程序对应的默认编码码率与码率阈值进行比对,以判断出默认编码码率是否低于码率阈值。其中,码率阈值用于划分低码率以及其他码率,也就是说,当码率低于码率阈值,则为低码率。具体的码率阈值可以不作为限定,例如码率阈值可以为2Mbps(兆比特每秒),也可以是1.52Mbps等。
步骤S130:如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
在本申请实施例中,当判断出上述应用程度对应的默认编码码率低于码率阈值时,则表示应用程序要求的录制视频的编码码率较低,如果此时采用硬编码方式进行编码,则会使得录制视频的编码质量较低。因此,在上述默认编码码率低于码率阈值时,则控制应用程序选择指定软编码器对视频的视频数据进行编码。其中,指定软编码器为利用软编码方式编码的编码器,指定软编码器可以为第三方的软编码器,也可以为***的软编码器,具体的指定软编码器可以不作为限定。从而,使得应用程序在编码视频数据时,利用该指定软编码器对视频的视频数据进行编码。当上述默认编码码率不低于码率阈值时,则应用程序可以采用硬编码方式(例如利用***的硬编码器,或者其他硬编码器),对视频数据进行编码。
本申请实施例提供的视频编码方法,通过在检测到应用程序开始进行视频录制时,获取应用程序对应的默认编码码率,再判断默认编码码率是否低于码率阈值,当上述默认编码码率低于码率阈值时,控制应用程序选择指定软编码器对视频数据进行编码,相比采用硬编码方式对视频数据进行编码,提升了编码质量,从而提高了录制视频的质量
请参阅图2,本申请另一个实施例提供了一种视频编码方法,可应用于电子设备, 该视频编码方法可以包括:
步骤S210:在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率。
步骤S220:判断所述默认编码码率是否低于码率阈值。
在本申请实施例中,步骤S210以及步骤S220可以参阅上述实施例的内容,在此不再赘述。
步骤S230:如果低于所述码率阈值,判断所述应用程序是否在设定名单内。
在本申请实施例中,在判断出上述应用程序所要求的录制视频的默认编码码率低于码率阈值时,还可以判断上述开始进行视频录制的应用程序是否在设定名单内容,以确定应用程序后续是否通过指定软编码器对视频数据进行编码。其中,上述设定名单可以为用于管控在进行录制低码率视频时,需要通过指定软编码器对视频数据进行编码的应用程序。也就是说,当设定名单内的应用程序录制视频时要求的默认编码码率,低于上述码率阈值时,需要使用上述指定软编码器对视频数据进行编码。设定名单中可以包括名单内的应用程序的标识信息,标识信息可以包括进程名称、包名等,当然,具体的标识信息可以不作为限定。
作为一种实施方式,可以利用进程名称判断上述应用程序是否在设定内容内。因此,判断所述应用程序是否在设定名单内,可以包括:获取所述应用程序的进程名称;判断所述进程名称是否与设定名单内应用程序的进程名称相同。
可以理解的是,上述开始进行视频录制的应用程序在运行中,因此可以获取应用程序的进程名称。其中,进程名称的获取,可以通过Process.myPid()及RunningAppProcessInfo来获取处理器当前运行的进程名称。当然,具体获取进程名称的方式可以不作为限定。当获取到的进程名称,与上述设定名单内的应用程序的进程名称相同时,则可以确定出上述开始进行视频录制的应用程序在设定名单内;当获取到的进程名称,与上述设定名单内的应用程序的进程名称不同时,则可以确定出上述开始进行视频录制的应用程序不在设定名单内。
作为另一种实施方式,可以利用包名判断上述应用程序是否在设定名单内。因此,判断所述应用程序是否在设定名单内,可以包括:获取所述应用程序的包名;判断所述包名是否与设定名单内应用程序的包名相同。
其中,可以通过adb命令查看应用程序的包名。当然,具体获取包名的方式可以不作为限定。当获取到的包名,与上述设定名单内的应用程序的包名相同时,则可以确定出上述开始进行视频录制的应用程序在设定名单内;当获取到的包名。与上述设定名单内的应用程序的包名不同时,则可以确定出上述开始进行视频录制的应用程序不在设定名单内。
进一步的,当判断出上述开始进行视频录制的应用程序在设定名单内,由于上述确定出默认编码码率低于码率阈值,因此表示该应用程序需要利用指定软编码器对编码数据进行编码。当判断出上述开始进行视频录制的应用程序不在设定名单内,则表示该应用不需要利用指定软编码器对编码数据进行编码。
当上述默认编码码率不低于码率阈值时,则应用程序可以采用硬编码方式(例如利用***的硬编码器,或者其他硬编码器),对视频数据进行编码。
步骤S240:如果在所述设定名单内,则获取中央处理器的负载率。
在本申请实施例中,当上述确定出开始进行视频录制的应用程序在设定名单内,且该应用程序对应的默认编码码率低于码率阈值时,还可以根据的中央处理器的负载率确定是否利用上述指定软编码器,对视频数据进行编码。其中,负载率为指CPU的负载与CPU的最大负载的比值。
可以理解的是,电子设备中通常安装有多个应用程序,而不同的应用程序会对应有不同的任务需要处理,并且占用CPU的资源不同,因此CPU的负载率不是固定的 状态。例如,当只有一个应用程序运行时,CPU的负载率可能为10%,而在运行有两个应用程序时,CPU的负载率可能为20%,而当运行有三个应用程序时,可能CPU负载率达到35%。
由于利用指定软编码器对视频数据编码,需要占用处理器的资源,因此,可以获取CPU的负载率,以便跟CPU的负载率,确定是否利用上述指定软编码器对视频数据编码,避免CPU的负载过高,而导致卡顿。
在本申请实施例中,由于CPU的负载率可能在不停的变化,因此获取CPU的负载率,可以包括:在视频录制过程中,实时或者定时获取中央处理器的负载率。可以理解的是,在后续开始视频录制之后,也可以获取CPU负载率,确定应用程序是否利用指定软编码器对视频数据进行编码,以避免CPU的负载率过高,而导致卡顿或者应用崩溃等。定时获取CPU的负载率可以是按照设定间隔时长获取CPU的负载率。
在本申请实施例中,上述获取中央处理器的负载率,可以包括:获取中央处理器的负载率,包括:获取中央处理器的当前负载率;预估所述中央处理器在设定时长内的负载率增加量;获取所述负载率增加量与所述当前负载率的和值,将所述和值作为所述中央处理器的负载率。
可以理解的是,虽然电子设备在运行不同应用程序时,不同的应用程序所占用CPU的资源不同,但是由于用户使用应用程序会存在习惯,因此电子设备对于应用程序的运行时间可以预估。例如,电子设备可以记录安装的各个应用程序的运行时间,并且将时间划分为多个时间段,每个应用程序的运行时间对应到时间段,从而可以得到每个应用程序经常运行的时间段。进而根据上述每个应用程序经常运行的时间段,可以推断出在某个时间段内,会有哪些应用程序启动。另外,电子设备安装的应用程序中,会存在部分应用程序会定时的进行一些任务,例如定时进行更新、从网络获取数据、或者进行数据处理等。在进行上述的任务时,会一定程度上增加CPU的负载率。因此,可以对各个应用程序的运行时间、运行时CPU的负载率进行记录,以便预估CPU的负载率变化。
因此,可以根据CPU的当前负载率,以及预估CPU在设定时长内容的负载率增加量,获取中央处理器的负载率,将获取的中央处理器的负载率作为确定是否利用上述指定软编码器对视频数据编码的标准。
其中,获取CPU的当前负载率,当电子设备的操作***为Android***时,可以通过Android***中的ProcessStats类,获取***的负载情况及进程时间。其具体实现原理是读取/proc目录下的文件,***运行时,内核会去更新/proc目录下的文件,将PID的运行情况写入相应的文件中。通过获取当前中央处理器的负载与中央处理器的最大负载的比值,即可获得中央处理器的当前负载率。当然,以上获取中央处理器的当前负载率的方式在本申请实施了中并不作为限定。
电子设备可以根据上述记录的各个应用程序的运行时间以及运行时的CPU的负载率,预估CPU在设定时长内容的负载率增加量。因此,所述预估中央处理器在设定时长内的负载率增加量,可以包括:
获取所述应用程序在所述设定时长内对应的中央处理器的历史负载率;根据所述历史负载率,预估所述中央处理器在所述设定时长内的负载率增加量。
可以理解的是,根据记录各个应用程序的运行时间,以及运行时的CPU的负载率,确定出上述开始进行视频录制的应用程序在设定时长内对应的CPU的历史负载率。例如,当前时间为时间A,在时间A对应设定时长内,常运行的应用程序有应用1以及应用2,并且可以得到应用1运行时的CPU负载率为20%,应用2运行时的CPU负载率为30%,由于应用1以及应用2在同一时间段内运行,因此可以取两者运行时的CPU负载率的最大值,即30%,将30%作为上述开始进行视频录制的应用程序在设定时长内对应的CPU的历史负载率。在得到上述历史负载率之后,则可以根据上述历史 负载率,预估CPU在设定时长内的负载率增加量。具体可以将上述历史负载率,作为CPU在所述设定时长内的负载率增加量。
其中,上述设定时长,可以设置为上述开始进行视频录制的应用程序,录制视频的历史录制时长。可以理解的是,电子设备可以记录该应用程序在每次录制视频时的历史录制时长,上述设定时长可以取记录的多次历史录制时长的平均值,或者多次历史录制时长中的最大值。从而,可以保证录制视频过程中的稳定性,避免出现卡顿。
在得到CPU的当前负载率,以及预估出CPU在设定时长内容的负载率增加量之后,则可以计算当前负载率以及负载率增加量之和,将两者的和值作为中央处理器的负载率。
步骤S250:判断所述负载率是否低于第一负载率阈值。
在本申请实施例中,在得到电子设备的CPU的负载率之后,则可以将负载率与第一负载率阈值进行比对,以判断出负载率是否低于第一负载率阈值。
其中,可以将CPU的负载率分为第一等级以及第二等级,其中,低于第一负载率阈值的负载率处于第一等级,不低于第一负载率阈值的负载率处于第二等级。负载率为第一等级时,表示在上述设定时长内CPU的负载处于非常低的情况,也就是说需要CPU执行的任务非常少,也即线程数非常低;负载率为第二等级时,表示在上述设定时长内CPU的负载处于较低的情况,也就是说需要CPU执行的任务较少,也即线程数较低,但是比第一等级时需要CPU执行的任务多,线程数也比第一等级时的线程数高。
第一负载率阈值可以根据CPU的参数等确定,其与CPU的性能有关。作为一种实施方式,在CPU的最大工作频率高时,由于其负载率达到较高水平时,其依然可以支持利用指定软编码器进行编码,可以相对最大工作频率低的CPU高。例如,两个CPU的最大工作频率分别为1GHz和2GHz,如果最大工作频率为1GHz对应的第一负载率阈值为50%,则最大工作频率为2GHz对应的第一负载率阈值为65%。当然,以上第一负载率阈值仅为举例,并不代表对本申请实施例中具体的第一负载率阈值的限定
步骤S260:如果低于所述第一负载率阈值,控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
当上述判断出CPU的负载率低于第一负载率阈值时,则表示在上述设定时长内CPU的负载处于非常低的情况,即CPU处于非常空闲的状态,此时利用指定软编码器进行编码,不会使CPU负载过大,因此,可以控制应用程序选择指定软编码器对视频数据进行编码,以得到视频文件。当上述判断出CPU的负载率不低于第一负载率阈值时,则表示在上述设定时长内CPU的负载处于较低的情况,但是此时采用指定软编码进行编码,可能会导致CPU负载率处于较高水平,而导致卡顿,因此,可以控制应用程序选择***的硬编码器或者软编码器对视频数据进行编码
在本申请实施例中,用于对视频数据进行编码的编码器包括:编码器包括:指定软编码器、***的硬编码器以及***的软编码器。其中,***的硬编码器,为电子设备的***自带的硬编码器,例如安卓平台AVC(高级视频编码,Advanced Video Coding)硬编码器。***的软编码器为电子设备的***自带的软编码器,例如谷歌AVC软编码器。除了上述***的硬编码器以及软编码器以外,电子设备还可以安装有指定软编码器,指定软编码器可以为通过OpenMax架构挂载一个高效AVC软编码器,这个软编码器可以是开源的ffmpeg AVC编码器,也可以是和其他厂商合作集成的三方AVC编码器。另外,为增加录制视频的编码效果,指定软编码器对视频的编码效果优于***的软编码器对视频的编码效果,例如指定软编码器可以克服编码块效应、马赛克等。当然,电子设备中用于对视频数据进行编码的编码器也还可以包括其他编码器。
进一步的,通常应用程序录制视频,在选择编码器时,通常根据编码器的优先级关系进行选择,即选择优先级高的编码器对视频数据进行编码。而通常应用程序选择 编码器的优先级关系为,***的硬编码器的优先级大于***的软编码器的优先级,***的软编码器的优先级大于其他编码器(包括上述指定软编码器)。因此,请参见图3,控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码,可以包括:
步骤S261:将所述指定软编码器的优先级调整为最高优先级,所述优先级为所述应用程序选择编码器的优先级。
可以理解的是,由于应用程序通常选择编码器时,依据的编码器之间的优先级关系为,***的硬编码器的优先级最大。因此,可以将上述指定软编码器的优先级调整为最高优先级,以使应用程序根据编码器的优先级,选择编码器时,可以选择指定软编码器对视频数据进行编码。
步骤S262:控制所述应用程序选择具有最高优先级的指定软编码器对所述视频的视频数据进行编码。
在将上述指定软编码器的优先级调整为最高优先级之后,则可以将最新的优先级传输至应用程序,以便应用程序根据新的编码器的优先级,选择指定软编码器对视频数据进行编码,实现控制应用程序选择指定软编码器进行编码。
在本申请实施例中,在控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之后,该视频编码方法还可以包括:降低图像处理器的工作频率。
可以理解的是,由于应用程序是利用软编码方式进行编码,不会利用GPU进行硬编码,另外,往往GPU的性能较高,因此可以适当降低图像处理器的工作频率,使电子设备的功耗降低。其中,GPU的工作频率需要降低的具体程度在本申请实施例中可以不作为限定,其可以根据GPU的性能参数确定。
本申请实施例提供的视频编码方法,通过在检测到应用程序开始进行视频录制时,获取应用程序对应的默认编码码率,当默认编码码率低于码率阈值时,判断该应用程序是否在设定名单内,当确定出该应用程序在设定名单内时,根据CPU的负载率确定应用程序是否利用指定软编码器对视频数据进行编码。由于指定软编码器的编码效果优于***的硬编码器以及软编码器,因此,可以使得视频录制时的编码效果提升,进而提高录制视频的视频质量。
请参阅图4,本申请又一个实施例提供了一种视频编码方法,可应用于电子设备,该视频编码方法可以包括:
步骤S310:在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率。
步骤S320:判断所述默认编码码率是否低于码率阈值。
在本申请实施例中,步骤S310以及步骤S320可以参阅上述实施例的内容,在此不再赘述。
步骤S330:如果低于所述码率阈值,判断所述应用程序是否在设定名单内。
在本申请实施例中,电子设备内设置有设定名单,设定名单用于管控在进行录制低码率视频时,需要通过指定软编码器对视频数据进行编码的应用程序。
上述设定名单可以由用户设置。例如,在设置界面中可以显示多个应用程序,以及每个应用程序对应的状态,可以理解的是,若应用程序对应的状态为“关”,那么表示该应用程序移除或者不加入到上述设定名单内,若应用程序对应的状态为“开”,那么表示该应用程序加入到上述名单中。因此,在本申请实施例中,该视频编码方法还可以包括:
根据检测到的第一操作,将所述应用程序设置于设定名单内。
可以理解的是,可以通过检测用户于上述设置界面中的操作,当检测到触发上述“开”控件的第一操作时,则可以根据该第一操作,将应用程序设置于设定名单内。
另外,在本申请实施例中,电子设备还可以设置有对于指定软编码器的使用权限,当应用程序具有使用指定软编码器的权限时,才可以利用上述指定软编码器对视频数 据进行编码。因此,该视频编码方法还可以包括:根据检测到的第二操作,开通所述应用程序使用所述指定软编码器的权限。
可以理解的是,与上述设定名单的设置相同的是,同样可以在权限的设置界面中,通过对各个应用程序进行权限的开或者关,设置应用程序使用指定软编码器的权限。
在本申请实施例中,该视频编码方法还可以包括:如果不低于所述码率阈值,则控制所述应用程序选择***的硬编码器或者所述***的软编码器对所述视频的视频数据进行编码。
步骤S340:如果在所述设定名单内,则获取中央处理器的负载率。
步骤S350:判断所述负载率是否低于第一负载率阈值。
步骤S360:如果低于所述第一负载率阈值,控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
在本申请实施例中,步骤S340以及步骤S360可以参阅上述实施例的内容,在此不再赘述。
步骤S370:如果不低于所述第一负载率阈值,则判断所述负载率是否低于第二负载率阈值,所述第二负载率阈值大于所述第一负载率阈值。
在本申请实施例中,如果判断出CPU的负载率不低于第一负载率阈值,即CPU的负载率大于或者等于第一负载率阈值,则表示此时如果CPU执行指定软编码器的进程,可能会导致卡顿。
当CPU的负载率不低于第一负载率阈值时,由于CPU指定软编码器进行视频数据的编码,可能会导致卡顿。因此,在本申请实施例中,当CPU的负载率不小于第一负载率阈值时,可以确定CPU处于不能非常低的状态,即不能采用***的软编码器进行视频编码的状态。
进一步的,可以在CPU的负载率不小于第一负载率阈值时,判断CPU的负载率是否低于第二负载率阈值,其中,该第二负载率阈值大于第一负载率阈值,以确定在CPU的负载率不小于第一负载率阈值时,是否可以采用***的软编码器进行视频编码。
在本申请实施例中,第二负载率阈值可以为CPU不能利用***的软编码器进行视频编码时的负载率,与CPU能利用***的软编码器进行视频编码时的负载率的临界值。也就是说,当CPU的负载率不低于第二负载率阈值时,其负载率处于较低水平,CPU的剩余资源不能支持利用指定软编码器进行编码,但是可以利用***软编码器进行编码;当CPU的负载率低于第二负载率阈值时,CPU负载率处于较高的水平,CPU的剩余资源不能支持利用指定软编码器进行编码,也不能支持利用***软编码器进行编码。当然,第二负载率阈值也可以根据CPU的性能参数等决定。
步骤S380:如果低于所述第二负载率阈值,则控制所述应用程序选择***的软编码器对所述视频的视频数据进行编码。
可以理解的,当判断出CPU的负载率不低于第二负载率阈值时,由于CPU的剩余资源不能支持利用指定软编码器进行编码,但是可以利用***软编码器进行编码,因此,可以利用***的软编码器对录制视频的视频数据进行编码,相对利用硬编码技术编码低码率视频,也能提升视频的编码质量。与控制应用程序选择指定软编码器对视频数据进行编码的方式相同的是,可以将***的软编码器的优先级调整为最高优先级,控制应用程序选择具有最高优先级的***的软编码器,对视频数据进行编码。
步骤S390:如果不低于所述第二负载率阈值,则控制所述应用程序选择***的硬编码器对所述视频的视频数据进行编码。
可以理解的是,当判断出CPU的负载率低于第二负载率阈值时,CPU负载率处于较高的水平,CPU的剩余资源不能支持利用指定软编码器进行编码,也不能支持利用***软编码器进行编码,因此,此时应用程序应利用***的硬编码器对视频数据进行编码。与控制应用程序选择指定软编码器对视频数据进行编码的方式相同的是,可以 将***的硬编码器的优先级调整为最高优先级,控制应用程序选择具有最高优先级的***的硬编码器,对视频数据进行编码。
在本申请实施例中,在控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之后,该视频编码方法还可以包括:检测图像处理器的负载率是否低于第三负载率阈值;如果低于所述第三负载率阈值,则降低图像处理器的工作频率。
可以理解的是,由于应用程序是利用软编码方式进行编码,不会利用GPU进行硬编码,另外,往往GPU的性能较高,因此可以适当降低图像处理器的工作频率,使电子设备的功耗降低。其中,GPU的工作频率需要降低的具体程度在本申请实施例中可以不作为限定,其可以根据GPU的性能参数确定。另外,在降低GPU的工作频率之前,还可以根据GPU的实际工作情况确定是否降低GPU的工作频率。当GPU的负载率低于第三负载率阈值时,表示GPU的剩余资源较多,因此,可以适当降低GPU的工作频率,以减少电子设备的功耗。其中,第三负载率阈值的具体数值可以作为限定,可以根据GPU的性能参数决定。
本申请实施例提供的视频编码方法,通过在检测到应用程序开始进行视频录制时,获取应用程序对应的默认编码码率,当默认编码码率低于码率阈值时,判断该应用程序是否在设定名单内,当确定出该应用程序在设定名单内时,根据CPU的负载率确定应用程序是否利用指定软编码器对视频数据进行编码。由于指定软编码器的编码效果优于***的硬编码器以及软编码器,因此,可以使得视频录制时的编码效果提升,进而提高录制视频的视频质量。另外,在根据CPU负载率确定不能使用指定软编码器对视频数据进行编码时,还进一步根据CPU负载率确定用***的硬编码器或者软编码器进行编码,当利用***的软编码器进行编码时,相对利用硬编码技术编码低码率视频,也能提升视频的编码质量。
请参阅图5,图5示出了本申请一个实施例提供的视频编码装置400的模块框图。该视频编码装置400应用于上述移动终端,下面将针对图5所示的装置进行阐述,所述视频编码装置400包括:码率获取模块410、码率判断模块420以及编码控制模块430。其中,所述录制检测模块410用于在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;所述码率判断模块420用于判断所述默认编码码率是否低于码率阈值;所述编码控制模块430用于如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
在本申请实施例中,请参见图6,所述编码控制模块430包括:优先级调整单元431以及控制执行单元432。其中,所述优先级调整单元431用于将所述指定软编码器的优先级调整为最高优先级,所述优先级为所述应用程序选择编码器的优先级;所述控制执行单元432用于控制所述应用程序选择具有最高优先级的指定软编码器对所述视频的视频数据进行编码。
进一步的,所述指定软编码器对视频的编码效果优于***的软编码器对视频的编码效果。
在本申请实施例中,编码控制模块430可以具体用于:如果低于所述码率阈值,判断所述应用程序是否在设定名单内;如果在所述设定名单内,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
作为一种方式,编码控制模块430判断所述应用程序是否在设定名单内,包括:获取所述应用程序的进程名称;判断所述进程名称是否与设定名单内应用程序的进程名称相同。
作为另一种方式,编码控制模块430判断所述应用程序是否在设定名单内,包括:获取所述应用程序的包名;判断所述包名是否与设定名单内应用程序的包名相同。
在本申请实施例中,该视频编码装置400还可以包括:名单设置模块。名单设置模块用于根据检测到的第一操作,将所述应用程序设置于设定名单内。
在本申请实施例中,该视频编码装置400还可以包括:权限开启模块。权限开启模块用于根据检测到的第二操作,开通所述应用程序使用所述指定软编码器的权限。
在本申请实施例中,该视频编码装置400还可以包括:负载率获取模块以及第一负载率判断模块。其中,负载率获取模块用于在所述控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之前,获取中央处理器的负载率;第一负载率判断模块用于判断所述负载率是否低于第一负载率阈值。如果低于所述第一负载率阈值,则编码控制模块控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
进一步的,该视频编码装置400还可以包括:第二负载率判断模块、第一编码模块以及第二编码模块。其中,第二负载率判断模块用于如果不低于所述第一负载率阈值,则判断所述负载率是否低于第二负载率阈值,所述第二负载率阈值大于所述第一负载率阈值;第一编码模块用于如果低于所述第二负载率阈值,则控制所述应用程序选择***的软编码器对所述视频的视频数据进行编码;第二编码模块用于如果不低于所述第二负载率阈值,则控制所述应用程序选择***的硬编码器对所述视频的视频数据进行编码。
作为一种方式,负载率获取模块可以具体用于:在视频录制过程中,实时或者定时获取中央处理器的负载率。
作为另一种方式,负载率获取模块可以具体用于:获取中央处理器的当前负载率;预估所述中央处理器在设定时长内的负载率增加量;获取所述负载率增加量与所述当前负载率的和值,将所述和值作为所述中央处理器的负载率。
第一负载率获取模块预估所述中央处理器在设定时长内的负载率增加量,可以包括:获取所述应用程序在所述设定时长内对应的中央处理器的历史负载率;根据所述历史负载率,预估所述中央处理器在所述设定时长内的负载率增加量。
在本申请实施例中,该视频编码装置400还可以包括:第三编码模块。第三编码模块用于:如果不低于所述码率阈值,则控制所述应用程序选择***的硬编码器或者所述***的软编码器对所述视频的视频数据进行编码。
在本申请实施例中,该视频编码装置400还可以包括:频率降低模块。频率降低模块用于在控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之后,降低图像处理器的工作频率。
进一步的,该视频编码装置400还可以包括:第二负载率判断模块。第二负载率判断模块用于在所述降低图像处理器的工作频率之前,检测图像处理器的负载率是否低于第三负载率阈值。如果低于所述第三负载率阈值,频率降低模块降低图像处理器的工作频率。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述装置和模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,模块相互之间的耦合可以是电性,机械或其它形式的耦合。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
综上所述,本申请提供的方案,通过在检测到应用程序开始进行视频录制时,获取该应用程序对应的默认编码码率,判断该默认编码码率是否低于码率阈值,如果低于该码率阈值,则控制应用程序选择指定软编码器对视频的视频数据进行编码。本方法可以根据录制视频的默认编码码率,确定默认编码码率小于码率阈值时,采用指定软编码器进行编码,从而提升了编码方式的灵活性,且提升录制低码率视频时的编码质量。
请参考图7,其示出了本申请实施例提供的一种电子设备的结构框图。该电子设备100可以是智能手机、平板电脑、电子书等能够运行应用程序的电子设备。本申请中的电子设备100可以包括一个或多个如下部件:处理器110、存储器120以及一个或多个应用程序,其中一个或多个应用程序可以被存储在存储器120中并被配置为由一个或多个处理器110执行,一个或多个程序配置用于执行如前述方法实施例所描述的方法。
处理器110可以包括一个或者多个处理核。处理器110利用各种接口和线路连接整个电子设备100内的各个部分,通过运行或执行存储在存储器120内的指令、程序、代码集或指令集,以及调用存储在存储器120内的数据,执行电子设备100的各种功能和处理数据。可选地,处理器110可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器110可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作***、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器110中,单独通过一块通信芯片进行实现。
存储器120可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。存储器120可用于存储指令、程序、代码、代码集或指令集。存储器120可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作***的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储终端100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
请参考图8,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读介质800中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质800可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质800包括非易失性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质800具有执行上述方法中的任何方法步骤的程序代码810的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码810可以例如以适当形式进行压缩。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种视频编码方法,其特征在于,所述方法包括:
    在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;
    判断所述默认编码码率是否低于码率阈值;
    如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
  2. 根据权利要求1所述的方法,其特征在于,编码器包括:指定软编码器、***的硬编码器以及***的软编码器,所述控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码,包括:
    将所述指定软编码器的优先级调整为最高优先级,所述优先级为所述应用程序选择编码器的优先级;
    控制所述应用程序选择具有最高优先级的指定软编码器对所述视频的视频数据进行编码。
  3. 根据权利要求2所述的方法,其特征在于,所述指定软编码器对视频的编码效果优于所述***的软编码器对视频的编码效果。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码,包括:
    如果低于所述码率阈值,判断所述应用程序是否在设定名单内;
    如果在所述设定名单内,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
  5. 根据权利要求4所述的方法,其特征在于,所述判断所述应用程序是否在设定名单内,包括:
    获取所述应用程序的进程名称;
    判断所述进程名称是否与设定名单内应用程序的进程名称相同。
  6. 根据权利要求4所述的方法,其特征在于,所述判断所述应用程序是否在设定名单内,包括:
    获取所述应用程序的包名;
    判断所述包名是否与设定名单内应用程序的包名相同。
  7. 根据权利要求4-6任一项所述的方法,其特征在于,在所述如果在所述设定名单内,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之前,所述方法还包括:
    根据检测到的第一操作,将所述应用程序设置于设定名单内。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:
    根据检测到的第二操作,开通所述应用程序使用所述指定软编码器的权限。
  9. 根据权利要求1-8任一项所述的方法,其特征在于,在所述控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之前,所述方法还包括:
    获取中央处理器的负载率;
    判断所述负载率是否低于第一负载率阈值;
    如果低于所述第一负载率阈值,则执行所述控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码的步骤。
  10. 根据权利要求9所述的方法,其特征在于,在所述判断所述负载率是否低于第一负载率阈值之后,所述方法还包括:
    如果不低于所述第一负载率阈值,则判断所述负载率是否低于第二负载率阈值,所述第二负载率阈值大于所述第一负载率阈值;
    如果低于所述第二负载率阈值,则控制所述应用程序选择***的软编码器对所述视频的视频数据进行编码;
    如果不低于所述第二负载率阈值,则控制所述应用程序选择***的硬编码器对所述视频的视频数据进行编码。
  11. 根据权利要求9或10所述的方法,其特征在于,所述获取中央处理器的负载率,包括:
    在视频录制过程中,实时或者定时获取中央处理器的负载率。
  12. 根据权利要求9或10所述的方法,其特征在于,所述获取中央处理器的负载率,包括:
    获取中央处理器的当前负载率;
    预估所述中央处理器在设定时长内的负载率增加量;
    获取所述负载率增加量与所述当前负载率的和值,将所述和值作为所述中央处理器的负载率。
  13. 根据权利要求12所述的方法,其特征在于,所述预估中央处理器在设定时长内的负载率增加量,包括:
    获取所述应用程序在所述设定时长内对应的中央处理器的历史负载率;
    根据所述历史负载率,预估所述中央处理器在所述设定时长内的负载率增加量。
  14. 根据权利要求1-13任一项所述的方法,其特征在于,在所述判断所述默认编码码率是否低于码率阈值之后,所述方法还包括:
    如果不低于所述码率阈值,则控制所述应用程序选择***的硬编码器或者所述***的软编码器对所述视频的视频数据进行编码。
  15. 根据权利要求1-14所述的方法,其特征在于,在所述控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码之后,所述方法还包括:
    降低图像处理器的工作频率。
  16. 根据权利要求15所述的方法,其特征在于,在所述降低图像处理器的工作频率之前,所述方法还包括:
    检测图像处理器的负载率是否低于第三负载率阈值;
    如果低于所述第三负载率阈值,则执行所述降低图像处理器的工作频率的步骤。
  17. 一种视频编码装置,其特征在于,所述装置包括:码率获取模块、码率判断模块以及编码控制模块,其中,
    所述录制检测模块用于在检测到应用程序开始进行视频录制时,获取所述应用程序对应的默认编码码率;
    所述码率判断模块用于判断所述默认编码码率是否低于码率阈值;
    所述编码控制模块用于如果低于所述码率阈值,则控制所述应用程序选择指定软编码器对所述视频的视频数据进行编码。
  18. 根据权利要求17所述的装置,其特征在于,编码器包括:指定软编码器、***的硬编码器以及***的软编码器,所述编码控制模块包括:优先级调整单元以及控制执行单元,其中,
    所述优先级调整单元用于将所述指定软编码器的优先级调整为最高优先级,所述优先级为所述应用程序选择编码器的优先级;
    所述控制执行单元用于控制所述应用程序选择具有最高优先级的指定软编码器对所述视频的视频数据进行编码。
  19. 一种电子设备,其特征在于,包括:
    一个或多个处理器;
    存储器;
    一个或多个应用程序,其中所述一个或多个应用程序被存储在所述存储器中并被 配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行如权利要求1-16任一项所述的方法。
  20. 一种计算机可读取存储介质,其特征在于,所述计算机可读取存储介质中存储有程序代码,所述程序代码可被处理器调用执行如权利要求1-16任一项所述的方法。
PCT/CN2018/120828 2018-12-13 2018-12-13 视频编码方法、装置、电子设备及存储介质 WO2020118601A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880098554.6A CN112840663B (zh) 2018-12-13 2018-12-13 视频编码方法、装置、电子设备及存储介质
PCT/CN2018/120828 WO2020118601A1 (zh) 2018-12-13 2018-12-13 视频编码方法、装置、电子设备及存储介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/120828 WO2020118601A1 (zh) 2018-12-13 2018-12-13 视频编码方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020118601A1 true WO2020118601A1 (zh) 2020-06-18

Family

ID=71075877

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/120828 WO2020118601A1 (zh) 2018-12-13 2018-12-13 视频编码方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN112840663B (zh)
WO (1) WO2020118601A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114157850A (zh) * 2021-11-26 2022-03-08 珠海视熙科技有限公司 一种数据传输方法、装置及计算机可读存储介质
CN114501017A (zh) * 2022-03-04 2022-05-13 百果园技术(新加坡)有限公司 一种视频编码适配方法、装置、设备及存储介质
CN115665485B (zh) * 2022-12-26 2023-04-28 杭州星犀科技有限公司 视频画面优化方法及装置、存储介质和视频终端

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103702124A (zh) * 2012-09-27 2014-04-02 深圳市快播科技有限公司 一种转码加速方法和转码器
CN104768063A (zh) * 2015-04-07 2015-07-08 天脉聚源(北京)教育科技有限公司 一种视频编码方法及装置
CN105025327A (zh) * 2015-07-14 2015-11-04 福建富士通信息软件有限公司 一种移动终端现场直播的方法及***
WO2016115531A1 (en) * 2015-01-15 2016-07-21 Huawei Technologies Co., Ltd. System and method for a message passing algorithm
CN106454413A (zh) * 2016-09-20 2017-02-22 北京小米移动软件有限公司 直播编码切换方法、装置及设备
CN107277607A (zh) * 2017-06-09 2017-10-20 努比亚技术有限公司 一种屏幕图像录制方法、终端及计算机可读存储介质
CN107948660A (zh) * 2017-11-16 2018-04-20 北京小米移动软件有限公司 视频编码适配的方法及装置
CN108769738A (zh) * 2018-06-15 2018-11-06 广州酷狗计算机科技有限公司 视频处理方法、装置、计算机设备和存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006340066A (ja) * 2005-06-02 2006-12-14 Mitsubishi Electric Corp 動画像符号化装置、動画像符号化方法及び記録再生方法
CN106131470A (zh) * 2016-06-24 2016-11-16 维沃移动通信有限公司 一种视频录制的方法及移动终端
CN107580227B (zh) * 2017-09-27 2020-06-05 维沃移动通信有限公司 一种视频编码方法、移动终端

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103702124A (zh) * 2012-09-27 2014-04-02 深圳市快播科技有限公司 一种转码加速方法和转码器
WO2016115531A1 (en) * 2015-01-15 2016-07-21 Huawei Technologies Co., Ltd. System and method for a message passing algorithm
CN104768063A (zh) * 2015-04-07 2015-07-08 天脉聚源(北京)教育科技有限公司 一种视频编码方法及装置
CN105025327A (zh) * 2015-07-14 2015-11-04 福建富士通信息软件有限公司 一种移动终端现场直播的方法及***
CN106454413A (zh) * 2016-09-20 2017-02-22 北京小米移动软件有限公司 直播编码切换方法、装置及设备
CN107277607A (zh) * 2017-06-09 2017-10-20 努比亚技术有限公司 一种屏幕图像录制方法、终端及计算机可读存储介质
CN107948660A (zh) * 2017-11-16 2018-04-20 北京小米移动软件有限公司 视频编码适配的方法及装置
CN108769738A (zh) * 2018-06-15 2018-11-06 广州酷狗计算机科技有限公司 视频处理方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN112840663B (zh) 2024-05-03
CN112840663A (zh) 2021-05-25

Similar Documents

Publication Publication Date Title
WO2018103401A1 (zh) 无线保真Wi-Fi扫描方法及相关产品
WO2020118601A1 (zh) 视频编码方法、装置、电子设备及存储介质
US10545787B2 (en) Techniques to compose memory resources across devices
WO2021057619A1 (zh) 内存回收方法、装置、电子设备及存储介质
WO2021057665A1 (zh) 数据存储方法、装置、移动终端及存储介质
US10862992B2 (en) Resource cache management method and system and apparatus
CN110764906B (zh) 内存回收处理方法、装置、电子设备以及存储介质
WO2021008348A1 (zh) 图片显示方法、装置、移动终端及存储介质
US20130166832A1 (en) Methods and electronic devices for adjusting the operating frequency of a memory
JP7186877B2 (ja) 映像デコーディング制御方法、装置、電子機器及び記憶媒体
US20130282869A1 (en) Method, apparatus, and computer program product for scheduling file uploads
US11010094B2 (en) Task management method and host for electronic storage device
WO2021057623A1 (zh) 内存回收方法、装置、电子设备及存储介质
WO2017032080A1 (zh) 一种通讯录控制方法、装置及移动终端
CN111263153B (zh) 视频编码方法、装置、设备及存储介质
CN111142788B (zh) 一种数据迁移方法、装置和计算机可读存储介质
US20140092103A1 (en) Method for adaptively adjusting framerate of graphic processing unit and computer system using thereof
WO2021077375A1 (zh) 通信频率调节方法、装置、电子设备及存储介质
CN105447820A (zh) 一种图片处理方法、装置和移动终端
WO2017198112A1 (zh) 一种切频方法、装置和计算机可读存储介质
US10484444B2 (en) Communication method, communication device, and recording medium for streaming
WO2020107970A1 (zh) 视频解码方法、装置、电子设备及存储介质
WO2023083064A1 (zh) 视频处理方法、装置、电子设备及可读存储介质
CN114281724B (zh) 数据传输方法、装置及电子设备
CN104394264A (zh) 一种防止录音中断的方法和***

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18942728

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 28.10.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18942728

Country of ref document: EP

Kind code of ref document: A1