Image coding method, device, computer equipment and storage medium

By detecting the encoder type supported by the device and selecting a standard software encoder for processing, the problem of inability to achieve image encoding without hardware encoding environment or hardware driver is solved, and the compatibility and usability of the encoding system is improved.

CN113066140BActive Publication Date: 2025-02-25GUANGZHOU HUYA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110336468.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-29
Publication Date
2025-02-25
Estimated Expiration
2041-03-29

AI Technical Summary

Technical Problem

The prior art cannot realize image encoding when there is no hardware encoding environment or hardware driver, resulting in low compatibility and availability of the encoding system.

Method used

By detecting the encoder type supported by the current device, selecting a standard software encoder type (such as the X264 software encoder) for encoding processing, ensuring that image encoding can be achieved in any hardware environment.

Benefits of technology

Improves the compatibility and availability of the encoding system, ensuring efficient image encoding can be achieved without a hardware encoding environment or without hardware drivers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113066140B_ABST
    Figure CN113066140B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an image encoding method, device, computer equipment and storage medium. The method comprises: in at least one standard encoder type, detecting the supported encoder type of the current device, wherein the supported encoder type at least comprises a standard software encoder type; selecting an encoder according to each of the supported encoder types, and encoding the image data to be encoded. The embodiment of the present invention can be compatible with a hardware-free encoding environment and improve the availability of the encoding system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data processing, and in particular to an image encoding method, apparatus, computer equipment and storage medium. Background Art

[0002] With the continuous development of computer technology, personal computer hardware is iterating rapidly, and more and more people are using personal computers to perform operations such as video encoding, which is particularly frequent in the live broadcast industry.

[0003] Existing personal computers have different hardware components, and there are great differences in central processing units (CPUs) and graphics cards. In addition, multi-platform encoding solutions usually only consider hardware encoding.

[0004] In the above encoding method, once there is a problem with the driver or system settings, the system will not be able to provide normal encoding services. Summary of the invention

[0005] The embodiments of the present invention provide an image encoding method, an apparatus, a computer device and a storage medium, which are compatible with a hardware-free encoding environment and improve the availability of the encoding system.

[0006] In a first aspect, an embodiment of the present invention provides an image encoding method, including:

[0007] Detects the supported encoder types of the current device among at least one standard encoder type.

[0008] Detecting a supported encoder type of the current device among at least one standard encoder type, wherein the supported encoder type at least includes a standard software encoder type;

[0009] According to the types of supported encoders, an encoder is selected and encoding is performed on the image data to be encoded.

[0010] In a second aspect, an embodiment of the present invention further provides an image encoding device, including:

[0011] A supported encoder type detection module, used to detect a supported encoder type of a current device from at least one standard encoder type, wherein the supported encoder type includes at least a standard software encoder type;

[0012] The encoding processing module is used to select an encoder according to the types of supported encoders and perform encoding processing on the image data to be encoded.

[0013] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an image encoding method as described in any one of the embodiments of the present invention is implemented.

[0014] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image encoding method as described in any one of the embodiments of the present invention.

[0015] The embodiment of the present invention tests multiple standard encoder types, detects the supported encoder types supported by the current device, adopts the supported encoder types, selects the encoder for encoding processing, and the supported encoder types include at least standard software encoder types to be compatible with any hardware device, thereby solving the problem in the prior art that encoding cannot be achieved when there is no hardware encoding environment or no hardware driver. It can be compatible with no hardware encoding environment and no hardware driver, thereby improving the compatibility of the encoding system, improving the availability of the encoding system, and improving the encoding accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 is a flowchart of an image encoding method in Embodiment 1 of the present invention;

[0017] Figure 2a is a flowchart of an image encoding method in Embodiment 2 of the present invention;

[0018] Figure 2b is a flow chart of a method for testing encoder types and encoding data formats in Embodiment 2 of the present invention;

[0019] Figure 2c is a schematic diagram of the structure of a coding system in Embodiment 2 of the present invention;

[0020] Figure 3 is a schematic diagram of an application scenario in Embodiment 3 of the present invention;

[0021] Figure 4 is a structural schematic diagram of an image encoding device in Embodiment 4 of the present invention;

[0022] Figure 5 It is a structural diagram of a computer device in Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0024] Embodiment 1

[0025] Figure 1 This is a flowchart of an image encoding method in Embodiment 1 of the present invention. This embodiment is applicable to the case where an encoder supported by the current device is selected to encode image data. This method can be executed by the image encoding device provided by the embodiment of the present invention. The device can be implemented in software and / or hardware and can generally be integrated into a computer device. Figure 1 As shown, the method of this embodiment specifically includes:

[0026] S110 , detecting supported encoder types of a current device in at least one standard encoder type, where the supported encoder types at least include standard software encoder types.

[0027] The standard encoder type is the type of the pre-packaged encoder. The packaged encoder can be edited, for example, a new encoder can be added, an already packaged encoder can be modified, or an already packaged encoder can be deleted. The standard encoder type is used as the detection range of the supported encoder types of the current device to detect the supported encoder types. The supported encoder type can refer to the encoding type of the encoder that the current device can operate normally. The standard encoder type is the type of multiple pre-packaged encoders, and is also the encoding type of the encoder that the current device can support at most. The standard encoder type includes the supported encoder type. If the current device supports all standard encoder types, the standard encoder type is the same as the supported encoder type, that is, an encoder of a standard encoder type can be arbitrarily selected from them to encode the image data.

[0028] Optionally, the standard software encoder type encoder includes a central processing unit-based software encoder.

[0029] In fact, most hardware devices are equipped with a central processing unit (CPU). The software encoder based on the CPU can be applied to almost all hardware devices and has universality. In fact, the software encoder based on the CPU can ignore the hardware environment and hardware driver of the hardware device and only needs the CPU to implement image encoding. Exemplarily, the software encoder based on the central processing unit is the X264 software encoder.

[0030] By adopting a CPU-based software encoder, accurate compatibility with hardware devices with different hardware conditions can be achieved, the compatibility and versatility of the encoding system can be improved, and the application scenarios of the encoding system can be increased.

[0031] S120, selecting an encoder according to the supported encoder types, and performing encoding processing on the image data to be encoded.

[0032] The number of supported encoder types is at least one, and each supported encoder type can be screened to determine a supported encoder type, and an encoder matching the selected supported encoder type is selected to perform an encoding processing operation. The image data to be encoded can be a single image or a video frame in a video.

[0033] The encoding process is performed on the image data to be encoded, and an encoder instance may be created and the encoding process operation may be performed through the encoder instance.

[0034] At present, the video field used analog technology in the early stage, and has now developed into digital technology. The benefits of digital technology may include: high reliability, the ability to eliminate transmission and storage losses, and the convenience of computer processing and network transmission. After digitization, video processing has entered the field of computer technology, and audio and video processing is essentially computer data processing. The original video data generated after the image information is collected has a very large amount of data. For some applications where the data is directly played locally after collection, there is no need to consider compression technology. However, in reality, more application scenarios involve the transmission and storage of videos. The transmission network and storage devices cannot tolerate the huge amount of original video data. The original video data must be encoded and compressed before transmission and storage. In the existing methods, hardware encoding is usually used to encode the image data to be encoded. For example, Intel hardware encoder, AMD hardware encoder or Nvidia hardware encoder. However, this multi-platform hardware encoding method only considers hardware encoding. Once there is a problem with the driver or encoding system settings, the encoding system will not be able to provide normal encoding services. In fact, due to the extremely fast update and iteration of desktop computers and laptops, the computer configurations of each user are uneven, but they can be roughly divided into three situations: only integrated graphics card, only independent graphics card, and both integrated graphics card and independent graphics card. The graphics cards are divided into three platforms: Intel, AMD and Nvidia. Different combinations of motherboards, CPUs, image processors (Graphics Processing Unit, GPU) and driver versions may cause problems with encoding capabilities.

[0035] The embodiment of the present invention can make the encoding system have high availability by at least selecting an encoder of the standard software encoder type for encoding, and can still use the CPU for software encoding when there is no hardware environment or a hardware driver problem. Specifically, by integrating the X264 software encoder, any machine still has the software encoding capability that relies solely on the CPU when the integrated graphics card and the independent graphics card cannot encode normally, thereby enhancing the compatibility of the entire video encoding system.

[0036] The embodiment of the present invention tests multiple standard encoder types, detects the supported encoder types supported by the current device, adopts the supported encoder types, selects the encoder for encoding processing, and the supported encoder types include at least standard software encoder types to be compatible with any hardware device, thereby solving the problem in the prior art that encoding cannot be achieved when there is no hardware encoding environment or no hardware driver. It can be compatible with no hardware encoding environment and no hardware driver, thereby improving the compatibility of the encoding system, improving the availability of the encoding system, and improving the encoding accuracy.

[0037] Embodiment 2

[0038] Figure 2a This is a flow chart of an image encoding method in Embodiment 2 of the present invention, and this embodiment is embodied based on the above embodiment. In at least one standard encoder type, the supported encoder type of the current device is detected, which is embodied as follows: establishing a test subprocess; running at least one encoder of a hardware encoder type through the test subprocess to encode the test image data, the standard encoder type includes at least one hardware encoder type and the standard software encoder type; detecting the encoding results of the encoders of each of the hardware encoder types, the encoding results include encoding success results and encoding failure results; determining the hardware encoder type and the standard software encoder type associated with the encoding success result as the supported encoder type of the current device.

[0039] The method of this embodiment specifically includes:

[0040] S210, establishing a test subprocess.

[0041] For descriptions not described in detail in the embodiments of the present invention, reference may be made to the descriptions of the above embodiments.

[0042] The test subprocess is used to detect whether the encoder of each hardware encoder type can run normally in the current device. The hardware encoder type is detected through an independent test subprocess. The main process sets a signal timeout for the subprocess. Even if the subprocess crashes or freezes, it does not affect the main process. The hardware encoder type can be detected without affecting the normal use of the user, improving the stability of the encoding system.

[0043] S220, respectively running at least one encoder of a hardware encoder type through the test sub-process to encode the test image data, wherein the standard encoder type includes at least one hardware encoder type and the standard software encoder type.

[0044] In fact, the encoder of the standard software encoder type is considered to be applicable to various hardware devices, and the encoder of the hardware encoder type is adapted to different hardware devices, so the encoder of the hardware encoder type can be detected. That is, the standard software encoder type must be the supported encoder type of the current device.

[0045] Among them, the detection of the hardware encoder type actually creates an encoder instance of the hardware encoder type, uses the encoder instance to encode the image data, and detects whether the encoding process is normal and / or whether the encoded data is correct. If it is determined that there is no abnormality in the encoding process, and / or the encoded data is correct, it is determined that the current device has the encoding capability of the encoder of the hardware encoder type, that is, the current device supports the encoder of the hardware encoder type. If there is an abnormality in the encoding process, and / or the encoded data is wrong, it is determined that the current device does not have the encoding capability of the encoder of the hardware encoder type, that is, the current device does not support the encoder of the hardware encoder type. The test image data is used to detect whether the encoder of each hardware encoder type can encode successfully. The test image data can be preset image data.

[0046] S230, detecting encoding results of encoders of each of the hardware encoder types, wherein the encoding results include encoding success results and encoding failure results.

[0047] The encoding result may refer to whether the encoding process of the hardware encoder type encoding the test image data is abnormal and whether the encoded data obtained by encoding is correct. The encoding success result is used to describe that the current device has the encoding capability of the encoder of the hardware encoder type, that is, the current device supports the encoder of the hardware encoder type. The encoding failure result is used to describe that the current device does not have the encoding capability of the encoder of the hardware encoder type, that is, the current device does not support the encoder of the hardware encoder type.

[0048] S240: Determine the hardware encoder type associated with the encoding success result and the standard software encoder type as supported encoder types of the current device.

[0049] By detecting whether the encoding results of the encoders of each hardware encoder type are successful, it is used to detect whether there are no abnormalities in the encoding process and the encoded data is correct. The encoding success result indicates that the encoding process runs normally and the encoded data is correct; the encoding failure result indicates that the encoding process runs abnormally and no encoded data is obtained, or the encoding process runs abnormally and the encoded data is wrong, or the encoding process runs normally and the encoded data is wrong.

[0050] The number of hardware encoder types associated with the encoding success result is at least 0. The encoder of the hardware encoder type associated with the encoding success result is actually an encoder that can run normally on the current device. The encoder of the standard software encoder type does not require additional configuration of the operating environment and driver, and can run normally on the current device. Therefore, the hardware encoder type associated with the encoding success result and the standard software encoder type can be determined as the supported encoder types of the current device.

[0051] In actual use, users do not really care which encoder to use, nor do they care which encoder the current machine supports. Moreover, the hardware and software conditions of each potential user's machine vary greatly. Therefore, how to obtain the supported encoder type and encoding data format of the current device and automatically select the encoder with the best performance for the user can improve the user experience. The embodiment of the present invention enumerates and tests all standard encoder types and encoding data formats in the encoding system through an independent detection subprocess, obtains the combination relationship of supported encoder types and encoding data formats supported by the current device, and then returns the combination relationship to the caller. The supported encoder type and encoding data format combination relationship may include: supporting encoder type of X264 encoder and encoding data format AVC; supporting encoder type of AMD encoder and encoding data format AVC; supporting encoder type of AMD encoder and encoding data format Hevc; supporting encoder type of AMD encoder and encoding data format Hevc; supporting encoder type of Intel QSV encoder and encoding data format AVC; supporting encoder type of Intel QSV encoder and encoding data format Hevc; supporting encoder type of Intel QSV encoder and encoding data format VP9; supporting encoder type of Intel QSV encoder and encoding data format AV1; supporting encoder type of Nvidia encoder and encoding data format AVC; supporting encoder type of Nvidia encoder and encoding data format Hevc.

[0052] In a specific example, the test flow for supported encoder types and encoded data formats is as follows Figure 2b shown.

[0053] S271, obtain the standard encoder type and encoding data format.

[0054] Standard encoder types and encoding data formats can be stored in a list. The list stores multiple pairs of standard encoder types and encoding data formats, and the corresponding relationship is many-to-many. The same standard encoder type can correspond to different encoding data formats, that is, encoders of the same standard encoder type can encode to obtain results of different encoding data formats. The encoding data formats corresponding to different standard encoder types can be the same, that is, encoders of different standard encoder types can encode to obtain results of the same encoding data format.

[0055] S272, specify the current standard encoder type and encoding data format.

[0056] A pair of standard encoder types and encoding data formats are obtained in sequence and determined as the current standard encoder type and encoding data format.

[0057] S273, input default encoding parameters.

[0058] The default encoding parameters are preset encoding parameters for test purposes. You can adapt the standard encoder type and configure the encoding parameters for different test purposes.

[0059] S274, determine whether the encoder is initialized successfully; if yes, execute S274; otherwise, execute S276.

[0060] S275, input test image data.

[0061] The test image data is image data in a video in an encoded data format.

[0062] S276, destroy the current encoder.

[0063] Destroy the current encoder to release resources and avoid resource waste.

[0064] S277, determine whether the encoding is successful; if so, execute S278; otherwise, execute S276.

[0065] S278, clean up resources and destroy the current encoder.

[0066] S279: If the standard encoder type and encoding data format are determined, the corresponding identification information is returned.

[0067] The identification information is used to distinguish different pairs of standard encoder types and encoding data formats. Each pair of standard encoder type and encoding data format is configured with identification information to distinguish it from other pairs.

[0068] S280, determine whether all the standard encoder types and encoded data formats have been traversed; if so, end; otherwise, execute S272.

[0069] In fact, it is determined that each pair of standard encoder types and encoding data formats has been traversed.

[0070] S250, selecting an encoder according to the supported encoder types, and performing encoding processing on the image data to be encoded.

[0071] Optionally, selecting an encoder according to each of the supported encoder types includes: when the hardware encoder type associated with the successful encoding result is empty, determining the standard software encoder type as the target supported encoder type; when the hardware encoder type associated with the successful encoding result is not empty, selecting the target hardware encoder type according to the preset priorities of each hardware encoder type and determining it as the target supported encoder type; selecting an encoder that matches the target supported encoder type.

[0072] The priority of the hardware encoder type is used to filter the hardware encoder type. Usually the hardware encoder type with the highest priority is selected and determined as the target hardware encoder type. The target hardware encoder type is used as the target support encoder type.

[0073] The hardware encoder type associated with the encoding success result is empty, indicating that the current device does not support any encoder of the hardware encoder type, that is, any encoder of the hardware encoder type cannot run normally and / or obtain correct encoding data in the current device. Therefore, a common standard software encoder type is selected and determined as the target supported encoder type. In fact, the supported encoder type at this time only includes the standard software encoder type. The only supported encoder type is determined as the target supported encoder type.

[0074] The hardware encoder type associated with the encoding success result is not empty, indicating that the current device supports at least one encoder of the hardware encoder type, that is, there is at least one encoder of the hardware encoder type that runs normally in the current device and obtains correct encoding data. Generally, the efficiency and quality of hardware encoding are higher than those of software encoding. When the supported encoder types include hardware encoder types, the encoder of the hardware encoder type is usually selected for encoding processing. When the supported encoder types include multiple hardware encoder types, the hardware encoder type that is adapted can be selected according to the hardware environment or the encoding data format; or, the encoder of the hardware encoder type with the highest priority can be selected for encoding processing. The priority of the hardware encoder type based on the independent graphics card is higher than that of the hardware encoder type based on the integrated graphics card; if there are both integrated graphics cards and independent graphics cards, the selection can be made according to the encoding data format.

[0075] By selecting an encoder of a standard software encoder type for encoding processing when the current device does not support any hardware encoder type, and selecting an encoder of the hardware encoder type with the highest priority for encoding processing according to the priority of the hardware encoder types when the current device supports at least one hardware encoder type, the hardware device can be accurately adapted, a compatible and best-performing encoder can be provided for encoding processing, encoding efficiency can be improved, and the quality of encoded data can be improved.

[0076] Optionally, the image encoding method further includes: in response to an encoding processing request, calling an interface that matches the encoding processing request; and processing a specified encoder according to the encoding processing request through the matching interface.

[0077] The encoding system encapsulates encoders of multiple standard encoder types. Since the encoders of each standard encoder type have their own system of use processes, integrating and encapsulating encoders of multiple standard encoder types can improve the scalability and ease of use of the encoding system. An independent external interface wrapper layer can be designed to simplify and classify the relevant operations of the encoder. The caller does not need to understand the actual calling process of each encoder, but only needs to be familiar with the wrapper layer to put it into use, which increases the ease of use of the encoding system; by inputting the supported encoder type to generate the corresponding hidden layer encoder instance, when a new encoder needs to be added, it only needs to be simply encapsulated according to the wrapper layer to add it to the encoding system. Exemplarily, the encoding system encapsulates the x264 encoder (standard software encoder type), AMD encoder, Intel QSV encoder and Nvidia encoder, among which the latter three encoders are all hardware encoder types.

[0078] The interface is an external interface pre-configured in the encoding system. The interface is used to receive requests and feedback the response results of the requests. There are multiple external interfaces configured in the encoding system, and different interfaces provide different functions or services. According to the received request, the matching interface can be queried, and the matching interface can be called to respond to the received request. The encoding processing request may refer to a service request associated with the encoder input by the user. The encoding processing request specifies the encoder, and the encoder can usually be specified by specifying the encoding type. Processing the specified encoder according to the encoding processing request may refer to responding to the encoding processing request, that is, performing operations such as querying, adding, modifying or deleting on the specified encoder.

[0079] In a specific example, the structural diagram of the coding system is as follows Figure 2cAs shown, exemplarily, the wrapper layer in the coding system includes the following interfaces: query interface: used to input the coding type. If the coding system encapsulates an encoder of the input coding type, query whether the encoder has the hardware environment or hardware driver required for the input coding type; test interface: used to input the coding type. If the coding system encapsulates an encoder of the input coding type, use the default coding parameters to initialize and encode the encoder of the input coding type, so as to simply test whether the encoder of the input coding type can work normally; initialization interface: used to input coding-related parameters and initialize the encoder of the specified standard encoder type; bit rate adjustment interface: used to input the specified bit rate, so as to adjust the specified standard encoder. The established bit rate of the encoder type can take effect in real time; forced key frame interface: used to specify the next input image as the key frame; synchronous encoding interface: used to input image data and output encoded stream data; asynchronous encoding interface: used to return immediately after inputting image data, and pass the encoded data to the caller through callback when the encoder encoding is completed; release encoding data interface: used to input encoding data and release related memory; get encoding status interface: used to obtain the current encoding status, such as encoding errors, need for more continuous image data, and encoder busy status information; register callback interface: used to register asynchronous encoding callbacks; unregister callback interface: used to unregister asynchronous encoding callbacks; destroy encoder interface: used to destroy the current encoder.

[0080] By configuring multiple interfaces and calling the matching interface according to the received request to perform corresponding operations on the specified encoder, the encoding system encapsulated with multiple encoders can be flexibly controlled to improve the encoding flexibility, and it can adapt to various application scenarios to realize different encoding functions.

[0081] Optionally, the encoding processing of the image data to be encoded includes: receiving standard encoding parameters; in an encoding parameter mapping relationship, querying target encoding parameters that match the standard encoding parameters, the encoding parameter mapping relationship including the correspondence between the standard encoding parameters and the encoding parameters associated with each of the standard encoder types; using the target encoding parameters to encode the image data to be encoded.

[0082] The standard encoding parameters are used to convert to encoding parameters that match each standard encoder type. The encoding parameters that match the standard encoder type can be directly parsed and processed by the encoder of the standard encoder type. The standard encoding parameters may refer to unified encoding parameters formed by integrating the encoding parameters that match each standard encoder type. The encoding parameter mapping relationship is used to convert the standard encoding parameters into encoding parameters that match each standard encoder type. If the encoder cannot recognize the standard encoding parameters, the standard encoding parameters are converted into target encoding parameters that the encoder can recognize, and the encoder can use the target encoding parameters to encode the image data to be encoded.

[0083] In fact, each standard encoder type has its own encoding parameters. Unified encoding parameters can improve the usability of the entire encoding system, which is very important for achieving platform independence of encoding parameters. By parsing and translating the encoding parameters of each standard encoder type, classifying encoding parameters with equal or similar effects, and converting the same and similar encoding parameters into customized unified encoding parameters through mapping, standard encoding parameters are formed, so that the caller does not need to understand the encoding parameters of each standard encoder type. With simple familiarity with the unified encoding parameters, the encoding parameters of each standard encoder type can be accurately controlled, and the differences in encoding parameters are directly removed, thereby achieving platform independence of encoding parameters. Encoding parameters can include: Preset, Profile, rcMode and other parameters.

[0084] The Preset parameters are used to adjust the balance between encoding speed and quality. The gear subdivisions of the Preset parameters are different for video encoders of various standard encoder types. For example, the Preset parameters corresponding to the X264 encoder include: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, and veryslow. The Preset parameters corresponding to the AMD encoder include: Speed, Balanced, and Quality. The Preset parameters corresponding to the Intel QSV encoder include: MFX_TARGETUSAGE_1, MFX_TARGETUSAGE_2, MFX_TARGETUSAGE_3, MFX_TARGETUSAGE_4, MFX_TARGETUSAGE_5, MFX_TARGETUSAGE_6, and MFX_TARGETUSAGE_7. The Preset parameters corresponding to the Nvidia encoder include: NV_ENC_PRESET_P1_GUID, NV_ENC_PRESET_P2_GUID, NV_ENC_PRESET_P3_GUID, NV_ENC_PRESET_P4_GUID, NV_ENC_PRESET_P5_GUID, NV_ENC_PRESET_P6_GUID, and NV_ENC_PRESET_P7_GUID.

[0085] Profile parameters are used to set the image quality level. H264 Baseline profile and Main profile are both for 8-bit sample data, 4:2:0 format (YUV) video sequences. Under the same configuration, High profile (HP) can reduce the bit rate by 10% compared to Main profile (MP). Depending on the application field, Baseline profile is mostly used in real-time communication, Main profile is mostly used in streaming media, and High profile is mostly used in broadcasting and storage. Baseline Profile: Basic image quality. Supports I / P frames, only supports non-interlaced (Progressive) and CAVLC; Mainprofile: Mainstream image quality. Provides I / P / B frames, supports non-interlaced (Progressive) and interlaced (Interlaced), and also supports CAVLC and CABAC; High profile: Advanced image quality. Based on the main profile, 8x8 internal prediction, custom quantization, lossless video encoding and more YUV formats are added. The corresponding profile parameters of the X264 encoder in the encoding data format H264 include: baseline, Main, High, high10, high422, and high444. The corresponding profile parameters of the AMD encoder in the encoding data format H264 include: ConstrainedBaseline, Baseline, Main, ConstrainedHigh, and High. The corresponding profile parameters of the Intel QSV encoder in the encoding data format H264 include: MFX_PROFILE_AVC_BASELINE, MFX_PROFILE_AVC_MAIN, MFX_PROFILE_AVC_EXTENDED, MFX_PROFILE_AVC_HIGH, and MFX_PROFILE_AVC_HIGH_422. The corresponding profile parameters of the Intel QSV encoder in the encoding data format H265 include: MFX_PROFILE_HEVC_MAIN, MFX_PROFILE_HEVC_MAIN10, MFX_PROFILE_HEVC_MAINSP, and MFX_PROFILE_HEVC_REXT.The corresponding Profile parameters of Nvidia encoder under the encoding data format H264 include: NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID, NV_ENC_H264_PROFILE_BASELINE_GUID, NV_ENC_H264_PROFILE_MAIN_GUID, NV_ENC_H264_PROFILE_HIGH_GUID, NV_ENC_H264_PROFILE_HIGH_444_GUID, NV_ENC_H264_PROFILE_STEREO_GUID, NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY, NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID and NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID, etc. The Profile parameters corresponding to the Nvidia encoder under the encoding data format H265 include: NV_ENC_HEVC_PROFILE_MAIN_GUID, NV_ENC_HEVC_PROFILE_MAIN10_GUID and NV_ENC_HEVC_PROFILE_FREXT_GUID, etc.

[0086] The goal of video encoding (lossy) is to save as many bits (bitrate) as possible while maintaining video quality as much as possible. rcMode rate control is an important tool for balancing bitrate and quality.

[0087] The rcMode parameters corresponding to the X264 encoder include: X264_RC_CQP, X264_RC_CRF, and X264_RC_ABR, etc. The rcMode parameters corresponding to the AMD encoder include: ConstantQP / / CQP, LatencyConstrainedVariableBitrate / / VBR_LAT (latency constraint), PeakConstrainedVariableBitrate / / VBR (peak constraint), and ConstantBitrate / / CBR, etc. The rcMode parameters corresponding to the Intel QSV encoder include: MFX_RATECONTROL_CBR, MFX_RATECONTROL_VBR, and MFX_RATECONTROL_CQP, etc. The rcMode parameters corresponding to the Nvidia encoder include: NV_ENC_PARAMS_RC_CONSTQP, NV_ENC_PARAMS_RC_VBR, NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ, NV_ENC_PARAMS_RC_CBR_HQ, and NV_ENC_PARAMS_RC_VBR_HQ.

[0088] Exemplarily, in the standard encoding parameters, the Preset parameters may include: Preset_1, Preset_2, Preset_3, Preset_4, Preset_5, Preset_6, Preset_7, Preset_Best_Speed, Preset_Balance, and Preset_Best_Quality, etc. Among them, Preset_1 to Preset_7 indicate that the speed is getting slower and the quality is getting better. Preset_Best_Speed ​​is equivalent to Preset_1, Preset_Balance is equivalent to Preset_4, and Preset_Best_Quality is equivalent to Preset_7. In the standard encoding parameters, the Profile parameters do not distinguish between the encoding data formats H264 and H265, and the Profile parameters may include: Profile_Baseline, Profile_Main, Profile_Main10, Profile_MainSP, Profile_High, Profile_High10, Profile_High422, Profile_High444, and Profile_Rext, etc. In the standard coding parameters, the rcMode parameter may include: RcMode_CBR, RcMode_VBR, RcMode_CQP, RcMode_CBR_LOWDELAY_HQ, RcMode_CBR_HQ and RcMode_VBR_HQ, etc.

[0089] In a specific example, the standard encoding parameter Preset_1 can be mapped to the ultrafast target encoding parameter corresponding to the X264 encoder, the Speed ​​target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_1 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P1_GUID target encoding parameter corresponding to the Nvidia encoder.

[0090] The standard encoding parameter Preset_2 can be mapped to the superfast target encoding parameter corresponding to the X264 encoder, the Speed ​​target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_2 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P2_GUID target encoding parameter corresponding to the Nvidia encoder.

[0091] The standard encoding parameter Preset_3 can be mapped to the veryfast target encoding parameter corresponding to the X264 encoder, the Balanced target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_3 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P3_GUID target encoding parameter corresponding to the Nvidia encoder.

[0092] The standard encoding parameter Preset_4 can be mapped to the fast target encoding parameter corresponding to the X264 encoder, the Balanced target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_4 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P4_GUID target encoding parameter corresponding to the Nvidia encoder.

[0093] The standard encoding parameter Preset_5 can be mapped to the medium target encoding parameter corresponding to the X264 encoder, the Balanced target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_5 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P5_GUID target encoding parameter corresponding to the Nvidia encoder.

[0094] The standard encoding parameter Preset_6 can be mapped to the slow target encoding parameter corresponding to the X264 encoder, the Quality target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_6 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P6_GUID target encoding parameter corresponding to the Nvidia encoder.

[0095] The standard encoding parameter Preset_7 can be mapped to the veryslow target encoding parameter corresponding to the X264 encoder, the Quality target encoding parameter corresponding to the AMD encoder, the MFX_TARGETUSAGE_7 target encoding parameter corresponding to the Intel QSV encoder, or the NV_ENC_PRESET_P7_GUID target encoding parameter corresponding to the Nvidia encoder.

[0096] By customizing important encoding parameters to simplify the mapping process of important encoding parameters of each standard encoder type, the use threshold of the encoding system of multiple standard encoder types is lowered, and it has a certain platform independence, that is, it has encoder type independence, which can improve the versatility and ease of use of the encoding system.

[0097] Optionally, the image encoding method also includes: monitoring the encoding processing process of the image data to be encoded; during the monitoring process, capturing abnormal events and performing abnormal processing, the abnormal events including high system resource usage events, abnormal encoding results or high difference between output and input quantities events.

[0098] During the programming process, due to problems such as excessive system resource usage or abnormal coding, the coding results may not meet expectations. It is necessary to monitor and handle the abnormalities in the coding process to improve coding reliability. The coding process can be monitored through an independent monitoring thread. Abnormal events may include high system resource usage events, abnormal coding results, or high difference between output and input quantities. Monitoring indicators include hardware model, system resource usage, coding input data, and output results.

[0099] Among them, hardware model monitoring: low-configuration CPUs and GPUs may not be able to perform high frame rate and high bit rate encoding operations. Due to performance limitations, in the actual encoding process, the encoding results often fail to meet expectations, which is specifically manifested as screen freezes or high latency. For such cases, the monitoring thread will count the machine model of the current device and mark it, and generate an abnormal encoding result event to be captured by the encoding system. System resource monitoring: video encoding will occupy certain system resources, including but not limited to CPU and GPU. Assuming that the current system resource usage is already relatively high, and the remaining system resources cannot meet the encoding operation, the encoding result will not meet expectations. For such cases, the monitoring thread will monitor and count the overall resource usage of the CPU and GPU. When the system resource usage is too high, a high system resource usage event is generated and captured by the encoding system. Correspondingly, the exception handling method may include: through the callback method, the alarm information is transmitted to the caller in real time. According to the alarm information, the user can close idle applications or lower encoding parameters such as bit rate and frame rate. Monitoring of encoding input data and output results: In video encoding application scenarios, the client may receive a distorted, black or green screen. The encoding system provides the caller with a dump capability, including input data and output data, to rule out problems caused by the encoder, thereby further locating the specific cause. In addition, the monitoring thread will compare the input data and output data at the second level. When it is found that the difference between the amount of input data and the amount of output data within a certain period of time exceeds a certain threshold, the event of a high difference between the output and input quantities is captured by the encoding system. Accordingly, the exception handling method may include: notifying the caller of the exception through a callback so as to proceed to the next step of exception handling.

[0100] By monitoring the encoding process, capturing abnormal events and handling them, the stability, fault tolerance and reliability of the encoding system can be improved.

[0101] In addition, on the Windows platform, some drivers are not very compatible with related hardware. Calling the Application Programming interface (API) may cause a crash, resulting in an abnormal exit of the entire process. For example, the Nvidia graphics card MX250 will crash when initializing the cuda environment parameters. Without affecting the normal use of users, how to avoid the possible crash of the hardware encoder initialization is the focus of attention. The use of the encoder can be double-protected in the following two ways: 1. Use the traditional try-catch to capture and process the modules that may have exceptions; 2. Before starting the encoding operation, use an independent subprocess to detect the standard encoder type. The main process sets a signal timeout for the subprocess, and even if the subprocess crashes or freezes, it will not affect the main process; the encoder detection of each standard encoder type is independent of each other and does not affect each other. The current encoder detection is completed and returns immediately, but the subsequent encoder test will be affected by the process of the subprocess running the current encoder.

[0102] The embodiment of the present invention detects the supported encoder type of the current device by testing the sub-process to detect whether the encoder of the hardware encoder type can encode normally, which can avoid the main process detection from affecting the normal operation of the main process and improve the stability of the encoding system. At the same time, only the hardware encoder type is detected to avoid detecting the software encoding type, which can reduce the amount of detection data and improve the detection efficiency of the supported encoder type.

[0103] Embodiment 3

[0104] Figure 3 This is a flowchart of an image encoding method in Embodiment 3 of the present invention. This embodiment is a specific application scenario. The method of this embodiment specifically includes:

[0105] S301, the child process detects a list of standard encoder types.

[0106] The standard encoder type list includes at least one hardware encoder type and a standard software encoder type.

[0107] S302, determine whether the detection is successful; if yes, execute S303; otherwise, execute S304.

[0108] Determine whether the detection of any hardware encoder type of the child process is successful. If all are unsuccessful, select an encoder of the standard software encoder type for encoding. If at least one hardware encoder type is detected successfully, select an encoder of one of the hardware encoder types for encoding.

[0109] In addition, the encoding data format supported by the current device can also be detected at the same time, that is, it can be detected which encoding data format of the video or image can be encoded by the current device.

[0110] S303, determine whether the hardware encoding capability is available; if yes, execute S305; otherwise, execute S304.

[0111] If at least one hardware encoder type is detected successfully, the current device has hardware encoding capability; if all hardware encoder types fail to be detected, the current device does not have hardware encoding capability.

[0112] S304, select X264 software encoder.

[0113] The encoder of the standard software encoder type is the X264 software encoder.

[0114] S305, prefer independent graphics card and optional integrated graphics card.

[0115] The hardware encoder type's encoder is based on the discrete graphics card, the integrated graphics card, or both.

[0116] S306, input encoder type and video encoding format.

[0117] The user enters the encoder type and video encoding format.

[0118] S307, determine whether the encoding type input by the user is a supported encoder type; if yes, execute S308; otherwise, end.

[0119] If the encoding type entered by the user is not a supported encoder type that the current device does not support, the encoding is stopped, and an encoding failure prompt message is provided to the user, and a supported encoder type can also be provided to the user. If the encoding type entered by the user is a supported encoder type that the current device supports, the encoding process is started.

[0120] S308, input encoding parameters such as resolution, bit rate, frame rate (Frames Per Second, FPS) and output data format.

[0121] The encoding parameters are used to provide the encoder with the encoding process.

[0122] S309, determine whether the encoder instance is successfully initialized or reset; if yes, execute S310; otherwise, end.

[0123] If no encoder instance exists, initialize the encoder instance of the target supported encoder type; if there is an encoder instance that has not been destroyed, reset the encoder instance.

[0124] S310: Input image data to be encoded for encoding.

[0125] S311, determine whether to end encoding; if yes, execute S310; otherwise, execute S316.

[0126] It is determined whether the user inputs an instruction to stop encoding. For example, if the user does not want to continue encoding, he can input an instruction to stop encoding, and then the encoding is determined to be ended; otherwise, the encoding is determined not to be ended.

[0127] S312, determine whether there is a video frame output; if yes, execute S310; otherwise, execute S310.

[0128] Determine whether there is output, that is, determine whether the encoding process is running normally.

[0129] S313, exporting the encoded data and related video information.

[0130] The encoded data and associated video information, such as data format, are output to the encoding requester.

[0131] S314, determine whether the monitoring data output is normal; if so, execute S310; otherwise, execute S315.

[0132] Determine whether the output encoded data is correct, etc.

[0133] S315, exception handling.

[0134] In abnormal situations, early warning information is generated and provided to users, and corresponding abnormal location information is provided.

[0135] S316, determine whether there is encoded data in the encoder; if yes, execute S317; otherwise end.

[0136] If the encoded data exists, it indicates that there is still encoded data that has not been output to the encoding requesting party; if the encoded data does not exist, it indicates that all the encoded data has been output to the encoding requesting party.

[0137] S317, output the encoded data and end.

[0138] By flushing the encoded data in the encoder, the cached encoded data is output to the encoding requester and resources are released, ending the encoding process normally.

[0139] Under the Windows platform, the embodiment of the present invention encapsulates encoders of multiple standard encoder types through a self-built wrapper interface layer, detects encoders of multiple standard encoder types by an independent process to avoid crashes, traverses and obtains supported encoder types and encoding data formats supported by the current machine, simplifies and maps encoding parameters used by encoders of multiple standard encoder types, configures an abnormal monitoring and processing mechanism, and uses the software encoder X264 supported by any hardware device, thereby realizing a video encoding system with high simplicity, high availability, high scalability and high compatibility.

[0140] Embodiment 4

[0141] Figure 4 Schematic diagram of an image encoding device in Embodiment 4 of the present invention. Embodiment 4 is a corresponding device for implementing the image encoding method provided by the above embodiments of the present invention, which can be implemented in software and / or hardware and can generally be integrated into a computer device.

[0142] Accordingly, the device of this embodiment may include:

[0143] A supported encoder type detection module 410, configured to detect a supported encoder type of a current device from at least one standard encoder type, wherein the supported encoder type includes at least a standard software encoder type;

[0144] The encoding processing module 420 is used to select an encoder according to the supported encoder types and perform encoding processing on the image data to be encoded.

[0145] The embodiment of the present invention tests multiple standard encoder types, detects the supported encoder types supported by the current device, adopts the supported encoder types, selects the encoder for encoding processing, and the supported encoder types include at least standard software encoder types to be compatible with any hardware device, thereby solving the problem in the prior art that encoding cannot be achieved when there is no hardware encoding environment or no hardware driver. It can be compatible with no hardware encoding environment and no hardware driver, thereby improving the compatibility of the encoding system, improving the availability of the encoding system, and improving the encoding accuracy.

[0146] Furthermore, the supported encoder type detection module 410 is specifically used to: establish a test sub-process; run at least one encoder of the hardware encoder type through the test sub-process to encode the test image data, the standard encoder type includes at least one hardware encoder type and the standard software encoder type; detect the encoding results of the encoders of each of the hardware encoder types, the encoding results include encoding success results and encoding failure results; determine the hardware encoder type and the standard software encoder type associated with the encoding success result as the supported encoder types of the current device.

[0147] Furthermore, the encoding processing module 420 is specifically used to: when the hardware encoder type associated with the successful encoding result is empty, determine the standard software encoder type as the target supported encoder type; when the hardware encoder type associated with the successful encoding result is not empty, select the target hardware encoder type according to the preset priority of each hardware encoder type and determine it as the target supported encoder type; select an encoder that matches the target supported encoder type.

[0148] Furthermore, the image encoding device also includes: an interface response module, which is used to call an interface matching the encoding processing request in response to the encoding processing request; and process the specified encoder according to the encoding processing request through the matching interface.

[0149] Furthermore, the encoding processing module 420 is specifically used to: receive standard encoding parameters; in the encoding parameter mapping relationship, query the target encoding parameters that match the standard encoding parameters, and the encoding parameter mapping relationship includes the correspondence between the standard encoding parameters and the encoding parameters associated with each of the standard encoder types; use the target encoding parameters to encode the image data to be encoded.

[0150] Furthermore, the image encoding device also includes: a monitoring module for monitoring the encoding processing process of the image data to be encoded; during the monitoring process, abnormal events are captured and abnormal processing is performed, and the abnormal events include high system resource occupancy events, abnormal encoding results, or high difference between output and input quantities.

[0151] Furthermore, the standard software encoder type encoder includes a central processing unit-based software encoder.

[0152] The above-mentioned device can execute the method provided by the embodiment of the present invention, and has the corresponding functional components and beneficial effects of executing the method.

[0153] Embodiment 5

[0154] Figure 5 A schematic diagram of the structure of a computer device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0155] like Figure 5As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16). The computer device 12 may be a device attached to the bus.

[0156] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0157] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0158] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a compact disk read-only memory (CD-ROM), a digital video disk (DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program components that are configured to perform the functions of the various embodiments of the present invention.

[0159] A program / utility 40 having a set (at least one) of program components 42 may be stored, for example, in system memory 28, such program components 42 including, but not limited to, an operating system, one or more application programs, other program components, and program data, each of which or some combination may include an implementation of a network environment. Program components 42 generally perform the functions and / or methods of the embodiments described herein.

[0160] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the computer device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN)) through a network adapter 20. As shown, the network adapter 20 communicates with other components of the computer device 12 through the bus 18. It should be understood that although Figure 5 Not shown, other hardware and / or software components may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays (Redundant Arrays of Inexpensive Disks, RAID) systems, tape drives, and data backup storage systems.

[0161] The processing unit 16 executes the programs stored in the system memory 28 to execute various functional applications and data processing, such as implementing the method provided by any embodiment of the present invention.

[0162] Embodiment 6

[0163] Embodiment 6 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the image encoding method provided in all the embodiments of the present invention is implemented:

[0164] That is, when the program is executed by the processor, it is implemented as follows: among at least one standard encoder type, the supported encoder type of the current device is detected, and the supported encoder type includes at least a standard software encoder type; according to each of the supported encoder types, an encoder is selected, and encoding processing is performed on the image data to be encoded.

[0165] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a RAM, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.

[0166] Computer-readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0167] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0168] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a LAN or WAN, or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0169] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. An image coding method, characterized in that: include: Detecting a supported encoder type of the current device among at least one standard encoder type, wherein the supported encoder type at least includes a standard software encoder type; According to the types of supported encoders, an encoder is selected, and encoding is performed on the image data to be encoded; The detecting, in at least one standard encoder type, a supported encoder type of the current device comprises: Create a test subprocess; Run at least one encoder of a hardware encoder type through the test subprocess to encode the test image data, wherein the standard encoder type includes at least one hardware encoder type and the standard software encoder type; Detecting encoding results of encoders of each of the hardware encoder types, the encoding results including encoding success results and encoding failure results; the encoding success results indicate that the current device supports the encoder of the hardware encoder type; the encoding failure results indicate that the current device does not support the encoder of the hardware encoder type; The hardware encoder type associated with the encoding success result and the standard software encoder type are determined as supported encoder types of the current device.

2. The method according to claim 1, characterized in that The selecting an encoder according to each of the supported encoder types includes: When the hardware encoder type associated with the encoding success result is empty, the standard software encoder type is determined as the target supported encoder type; When the hardware encoder type associated with the encoding success result is not empty, a target hardware encoder type is selected according to the preset priorities of the hardware encoder types, and is determined as the target supported encoder type; Select an encoder that matches an encoder type supported by the target.

3. The method according to claim 1, characterized in that Also includes: In response to the encoding processing request, calling an interface matching the encoding processing request; The designated encoder is processed according to the encoding processing request through the matching interface.

4. The method according to claim 1, characterized in that: The encoding process of the image data to be encoded includes: Receive standard encoding parameters; In the encoding parameter mapping relationship, querying the target encoding parameter matching the standard encoding parameter, the encoding parameter mapping relationship including the correspondence between the standard encoding parameter and the encoding parameter associated with each of the standard encoder types; The target encoding parameters are used to encode the image data to be encoded.

5. The method according to claim 1, characterized in that Also includes: Monitoring the encoding process of the image data to be encoded; During the monitoring process, abnormal events are captured and handled, including high system resource usage events, abnormal encoding results, or high difference between output and input quantities.

6. The method according to claim 1, characterized in that The standard software encoder type encoders include central processing unit based software encoders.

7. An image encoding device, characterized in that: include: A supported encoder type detection module, used to detect a supported encoder type of a current device from at least one standard encoder type, wherein the supported encoder type includes at least a standard software encoder type; An encoding processing module, used for selecting an encoder according to each of the supported encoder types, and performing encoding processing on the image data to be encoded; The encoder type detection module is specifically used to establish a test subprocess; Run at least one encoder of a hardware encoder type through the test subprocess to encode the test image data, wherein the standard encoder type includes at least one hardware encoder type and the standard software encoder type; Detecting encoding results of encoders of each of the hardware encoder types, the encoding results including encoding success results and encoding failure results; the encoding success results indicate that the current device supports the encoder of the hardware encoder type; the encoding failure results indicate that the current device does not support the encoder of the hardware encoder type; The hardware encoder type associated with the encoding success result and the standard software encoder type are determined as supported encoder types of the current device.

8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the image encoding method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the image encoding method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Video decoding method and device

    CN105992056A

  • Video decoding method and device and storage medium

    CN112087633A