CN111263162A - Video compression method, device, equipment and storage medium - Google Patents

Video compression method, device, equipment and storage medium Download PDF

Info

Publication number
CN111263162A
CN111263162A CN202010084333.2A CN202010084333A CN111263162A CN 111263162 A CN111263162 A CN 111263162A CN 202010084333 A CN202010084333 A CN 202010084333A CN 111263162 A CN111263162 A CN 111263162A
Authority
CN
China
Prior art keywords
code rate
preset
video
estimated
mode
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202010084333.2A
Other languages
Chinese (zh)
Other versions
CN111263162B (en
Inventor
张文忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bigo Technology Singapore Pte Ltd
Original Assignee
Guangzhou Baiguoyuan Information Technology Co Ltd
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 Guangzhou Baiguoyuan Information Technology Co Ltd filed Critical Guangzhou Baiguoyuan Information Technology Co Ltd
Priority to CN202010084333.2A priority Critical patent/CN111263162B/en
Publication of CN111263162A publication Critical patent/CN111263162A/en
Application granted granted Critical
Publication of CN111263162B publication Critical patent/CN111263162B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/184Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being bits, e.g. of the compressed video stream

Landscapes

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

Abstract

The embodiment of the invention discloses a video compression method, a video compression device, video compression equipment and a storage medium. Wherein, the method comprises the following steps: when a video hard coding compression event is triggered, acquiring first video data with preset duration in original video data; compressing the first video data by using a CQ mode, and determining an estimated code rate according to a compression result; and compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video, wherein the preset mode is different from the CQ mode. The technical scheme provided by the embodiment of the invention can reasonably determine the code rate adopted in the hard coding compression, gives consideration to the video compression quality and the compression efficiency, and effectively improves the video compression effect.

Description

Video compression method, device, equipment and storage medium
Technical Field
The embodiments of the present invention relate to the field of video processing, and in particular, to a video compression method, apparatus, device, and storage medium.
Background
With the continuous development of multimedia information technology, video information is emerging in large quantities. Video data has become an important information carrier in real life as an integrated medium for expressing information.
The video data contains a large amount of image and sound information, and is generally large in size, and in some scenes, the video data needs to be compressed and encoded so as to facilitate transmission or storage of videos. Currently, conventional compression coding schemes may include soft coding and hard coding. Wherein, soft coding generally refers to using a Central Processing Unit (CPU) to perform compression coding operation, and the speed is relatively slow; hard coding generally refers to performing compression coding operations using a non-CPU, such as a Graphics Processing Unit (GPU) or a dedicated Digital Signal Processor (DSP), and is slow. For mobile devices, in some application scenarios with certain requirements on compression efficiency, a hard coding scheme needs to be adopted, but the compression effect of the current hard coding scheme is not ideal enough, and improvement is needed.
Disclosure of Invention
The embodiment of the invention provides a video compression method, a video compression device, video compression equipment and a storage medium, which can optimize the existing video compression scheme.
In a first aspect, an embodiment of the present invention provides a video compression method, where the method includes:
when a video hard coding compression event is triggered, acquiring first video data with preset duration in original video data;
compressing the first video data by using a constant quality CQ mode, and determining an estimated code rate according to a compression result;
and compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video, wherein the preset mode is different from the CQ mode.
In a second aspect, an embodiment of the present invention provides a video compression apparatus, including:
the data extraction module is used for acquiring first video data with preset duration in original video data when a video hard coding compression event is triggered;
the estimated code rate determining module is used for compressing the first video data by utilizing a constant quality CQ mode and determining an estimated code rate according to a compression result;
and the video compression module is used for compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video, wherein the preset mode is different from the CQ mode.
In a third aspect, an embodiment of the present invention provides a mobile device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the video compression method according to the embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a video compression method as provided by an embodiment of the present invention.
According to the video compression scheme provided by the embodiment of the invention, when the video needs to be subjected to hard coding compression, the first video data with preset duration in the original video data is obtained, the first video data is compressed by utilizing a CQ mode, the estimated code rate is determined according to the compression result, and the original video data is compressed by adopting a preset mode except the CQ mode according to the estimated code rate, so that the target compressed video is obtained. By adopting the technical scheme, the code rate adopted during hard coding compression can be reasonably determined, the video compression quality and the compression efficiency are considered, and the video compression effect is effectively improved.
Drawings
Fig. 1 is a schematic flowchart of a video compression method according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of another video compression method according to an embodiment of the present invention;
fig. 3 is a block diagram of a video compression apparatus according to an embodiment of the present invention;
fig. 4 is a block diagram of a mobile device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
In order to facilitate understanding of the embodiments of the present invention, the following description is provided. In some application scenarios, for example, in the process of using a real-time chat tool, it is often necessary to share a video, such as sending a video to an opposite party, or sharing a video in a circle of friends, and when an original video is large (for example, a resolution or a code rate exceeds a certain threshold), it is necessary to perform compression coding locally to reduce a video volume, and then upload the video to a server for relaying or directly send the video to the opposite party. Wherein, the compression coding can adopt soft coding or hard coding. For soft coding, generally applied to a non-real-time call scenario, a Constant Rate Factor (CRF) mode is generally used, that is, a quality Factor is specified, and a maximum code Rate is set, so that an encoder adaptively selects a proper code Rate gear according to video complexity to perform coding, but the speed of soft coding is slow, and especially for low-end devices with poor performance, the coding time consumption is too long, which is the greatest disadvantage of soft coding. Compared with soft coding, the compression speed of hard coding is higher, but the compression effect has a larger relation with a specific system version, a hardware chip and the like. At present, for mobile devices, support on hard coding is far from friendly of soft coding, most of them only support a Variable Bit Rate (VBR) code control mode, some support Constant Bit Rate (CBR) code control modes, and only a few support Constant Quality (CQ) code control modes really well. Wherein, the code rate refers to the bit rate in unit time and is used for measuring the unit time volume of the video; VBR means that the bit rate of each frame of video coding is varied; CBR means that the bit rate of each frame of video coding is constant; CQ means that the quality of each frame of video coding is constant, where the quality can be measured with reference to Peak Signal to Noise Ratio (PSNR) of the image. The VBR and CBR need to specify the size of the compressed code rate in advance, and encode according to the set fixed code rate regardless of the complexity of the source video. Due to the diversity of original video contents, the fixed bitrate value cannot adapt to different video contents, when a video picture is relatively complex, the fixed bitrate value may cause poor quality of a coded video due to too low, and conversely, when the video picture is relatively simple, the fixed bitrate value may cause unnecessary bitrate waste due to too high, thereby increasing the transmission bandwidth cost. For the CQ mode, the quality of each frame of video coding is constant, that is, the CQ mode can dynamically adjust the bitrate according to the complexity of the video picture. Although most mobile devices are available, the CQ mode is limited by the internal hardware configuration of the device, the operating system, and the like, and the encoding result is often uncontrollable, so that it is difficult to directly apply the CQ mode to the actual hard-coding compression. In the embodiment of the invention, the CQ mode and other coding modes are combined, the code rate adopted in the hard coding compression is reasonably determined, the video compression quality and the code rate balance are considered, and the video compression effect is effectively improved. It should be noted that the above usage scenarios are only used as schematic illustrations, and the video compression scheme of the embodiment of the present invention is applicable to any scenarios involving video hard-coding compression.
Fig. 1 is a flowchart of a video compression method according to an embodiment of the present invention, which may be implemented by a video compression apparatus, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in a mobile device. As shown in fig. 1, the method includes:
step 101, when a video hard coding compression event is triggered, acquiring first video data with preset duration in original video data.
For example, the triggering condition of the video hard-coding compression event may be determined according to a specific application scenario. Taking a video sharing scenario as an example, assume that when a user uses an instant messaging application program, the user sends a video when chatting one to one or more people, or when sharing the video in a circle of friends, a community, a forum, a post, or the like, the user determines that a video hard coding compression event is triggered when determining that the shared video needs to be hard coding compressed according to a video hard coding compression event triggering condition set by the adopted application program. For example, the video hard-coding compression event triggering condition may be that a bitrate corresponding to the original video exceeds a preset bitrate threshold or a resolution corresponding to the original video reaches a preset resolution threshold, and the hard-coding compression condition is met. When the video hard-coding compression event trigger condition is not satisfied, the original video may not be compressed. If the original video is not compressed, the original video can be directly shared, for example, the original video is uploaded to a corresponding server. In addition, the code rate corresponding to the original video exceeds a preset code rate threshold or the resolution corresponding to the original video is detected to exceed a preset resolution threshold as a video compression condition, and if the video compression condition is met but the hard coding compression condition is not met, soft coding can be adopted for video compression. Wherein, the hard-coding compression condition can be decided according to the self-setting of the application program.
In the embodiment of the present invention, the preset duration may be set according to an actual situation, and may be a fixed value, such as 1 second or 2 seconds, or may be a dynamic value, for example, determined according to the total duration of the original video (for example, a preset proportion of the total duration, which may also be freely set, such as 10%). The specific position of the first video data relative to the original video data and the specific acquisition manner are not limited. Taking the preset time length as 2 seconds as an example, the specific position may be a start position of the original video, such as the previous 2 seconds, the specific position may also be an end position of the original video, such as the last 2 seconds, and the specific position may also be any position, such as randomly acquiring 2 seconds long video data in the original video.
Optionally, a code rate value, that is, a preset code rate, may be preset. When the total length of the original video is less than or equal to the preset time length, the compression processing can be directly carried out by adopting the preset code rate. The preset code rate can be set according to the actual situation, for example, according to the actual situation of the application program which needs to share the video.
And step 102, compressing the first video data by using a constant quality CQ mode, and determining an estimated code rate according to a compression result.
As mentioned above, although CQ mode is available for most mobile devices, the encoding result is often uncontrollable due to the limitations of hardware configuration inside the device and operating system, so that it is difficult to directly apply CQ mode in the actual hard-coded compression. That is, if the overall original video is compressed by using the CQ mode, the overall compression effect is not ideal, and may not be as good as the VBR mode and the CBR mode in terms of compression efficiency, video picture quality, and stability. In the embodiment of the invention, part of data in the original video data is extracted first, and the CQ mode is utilized to compress the part of data, so that the reasonable code rate is estimated and used by other modes, and the effect of dynamically determining the code rate according to the complexity of a video picture is achieved.
In the embodiment of the invention, the specific mode of determining the estimated code rate according to the compression result is not limited. Illustratively, a video frame included in the first video data is compressed by using a CQ mode to obtain a compressed video frame, and an estimated bitrate is determined according to a bit size corresponding to the compressed video frame. Optionally, the estimated code rate may be determined according to the compressed video frame with the largest corresponding bit size, may also be determined according to the compressed video frame with the largest corresponding bit size, and may also be determined according to the total bit size corresponding to the compressed video frame. When the estimated code rate is determined according to a certain compressed video frame, the estimated code rate can be determined according to the quotient of the bit size of the compressed video frame and the duration corresponding to the compressed video frame. When the estimated code rate is determined according to the total bit size corresponding to the compressed video frame, the estimated code rate can be determined according to the quotient of the total bit size corresponding to the compressed video frame and the preset duration.
And 103, compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video.
Illustratively, the preset mode may include a variable bitrate VBR mode and/or a constant bitrate CBR mode. In the two modes, as described above, the size of the compressed code rate needs to be specified in advance, but in the embodiment of the present invention, the specified code rate can be dynamically determined according to the estimated code rate, and after the compression processing is performed, the obtained target compressed video can ensure a better compression effect.
According to the video compression method provided by the embodiment of the invention, when the video needs to be subjected to hard coding compression, first video data with preset duration in original video data is obtained, a CQ mode is utilized to compress the first video data, an estimated code rate is determined according to a compression result, and the original video data is compressed by adopting a preset mode except the CQ mode according to the estimated code rate, so that a target compressed video is obtained. By adopting the technical scheme, the code rate adopted during hard coding compression can be reasonably determined, the video compression quality and the compression efficiency are considered, and the video compression effect is effectively improved.
In some embodiments, the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video includes: and under the condition that the estimated code rate is the same as the preset code rate, compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video. The method has the advantages that when the estimated code rate is the same as the preset code rate, the preset code rate is reasonable, other transformation is not needed, the estimated code rate is directly adopted for compression, and the compression efficiency is improved.
In some embodiments, it may further include: under the condition that the estimated code rate is different from the preset code rate, mapping the estimated code rate from an estimated code rate range to a set mapping code rate range by referring to the preset code rate based on an equivalent mapping principle to obtain a mapping code rate, wherein the preset code rate is contained in the estimated code rate range and the set mapping code rate range; and compressing the original video data by adopting a preset mode according to the mapping code rate to obtain a target compressed video. The method has the advantage that the finally adopted mapping code rate can be more reasonably limited by setting the estimated code rate range and setting the mapping code rate range. The estimated code rate range and the set mapping code rate range can be set according to actual conditions, such as actual conditions of an application program needing video sharing.
Further, recording an upper limit value of the estimated code rate range as a first code rate, and recording a lower limit value of the estimated code rate range as a second code rate; recording the upper limit value of the range of the set mapping code rate as a third code rate and recording the lower limit value as a fourth code rate; determining the mapping code rate by using the estimated code rate, the preset code rate, the estimated code rate range and the set mapping code rate range based on the equivalence mapping principle, wherein the determining comprises the following steps:
when the estimated code rate is smaller than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-second code rate)/(preset code rate-second code rate) ═ mapping code rate-fourth code rate)/(estimated code rate-fourth code rate);
when the estimated code rate is greater than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-preset code rate)/(first code rate-preset code rate) ═ mapping code rate-preset code rate)/(third code rate-preset code rate).
By the calculation of the formula, the mapping code rate can be quickly and accurately obtained, the original video data is compressed in a preset mode according to the mapping code rate, a target compressed video with high picture quality can be quickly obtained, and the video compression effect is further improved.
In some embodiments, when the estimated code rate is less than or equal to the second code rate, determining a mapping code rate as the second code rate; and when the estimated code rate is greater than or equal to the first code rate, determining a mapping code rate as the first code rate. The advantage of this arrangement is that the estimated bitrate is limited to a reasonable bitrate range according to the specific requirements of the application.
In some embodiments, the compressing the first video data using CQ mode includes: configuring a CQ mode local to the equipment and starting a hard encoder; and in the case that the hard encoder is successfully started, performing compression processing on the first video data by using the hard encoder. This has the advantage that it can be quickly determined whether the device supports the CQ mode. Illustratively, the configuration of the CQ mode may be performed through an interface in the operating system of the device for configuring the hard encoder. For example, when the operating system of the device is android, the CQ mode may be configured through decoupling provided by the android. After configuring the CQ mode, if the hard encoder can be successfully started, indicating that the apparatus supports the CQ mode, the hard encoder may be used to perform compression processing on the first video data.
In some embodiments, it may further include: and under the condition that the hard encoder fails to start, sending the first video data to a corresponding server to instruct the server to compress the first video data by utilizing a CQ mode, determining an estimated code rate according to a compression result, and returning the estimated code rate. The method has the advantages that when the device does not support the CQ mode locally, the first video data can be sent to the server, the server determines the estimated code rate instead, and follow-up operation is carried out according to the estimated code rate returned by the server, so that the reliability of the video compression scheme in the embodiment of the invention is improved.
In some embodiments, the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video includes: configuring a local preset mode of the equipment and restarting a hard encoder; and compressing the original video data through the hard encoder according to the estimated code rate to obtain a target compressed video. The advantage of this arrangement is that by configuring the default mode and restarting the hard encoder, video compression using the default mode can be quickly and accurately achieved.
Fig. 2 is a schematic flowchart of another video compression method according to an embodiment of the present invention, which combines a CQ mode and a VBR mode to compress a video, as shown in fig. 2, where the method includes:
step 201, when a video hard coding compression event is triggered, acquiring first video data with a preset duration in original video data.
Illustratively, before this step, the method may further include: initializing a preset code rate br _ preset, estimating a valid range of the code rate, namely an estimated code rate range [ br _ estimate _ down, br _ estimate _ up ], and setting a dynamic code rate range which can be mapped, namely a mapping code rate range [ br _ map _ down, br _ map _ up ], wherein br is the shorthand of bitrate.
The original video data can be understood as data corresponding to a shared source video, and when it is detected that a code rate corresponding to the original video exceeds a preset code rate threshold or when it is detected that a resolution corresponding to the original video exceeds a preset resolution threshold and a hard-coded compression condition is met, it is determined that a video hard-coded compression event is triggered. After determining that the video hard coding compression event is triggered, judging whether the total duration of the original video is greater than a preset duration (T seconds) or not, if so, entering a code rate detection process, and estimating a reasonable coding code rate, namely an estimated code rate br _ estimate. If the total duration of the original video is judged to be less than or equal to the preset duration, the estimated code rate can be directly made to be equal to the preset code rate, namely br _ estimate is br _ preset.
Illustratively, the first step of the code rate detection process is to obtain first video data with a preset duration in the original video data. Optionally, the frame rate fps of the original video is obtained, and assuming that the detected duration (i.e., the preset duration) is T seconds, the frame number of the pre-encoded video frame is N-fps-T, that is, the first video data includes N frames of video frame data.
Step 202, configuring a local CQ mode of the device, starting a hard encoder, and compressing the first video data by using the hard encoder under the condition that the hard encoder is successfully started, so as to obtain a compressed video frame.
Illustratively, a CQ mode is configured through an interface provided by an operating system, and a hard encoder is started, if the start is successful, the CQ mode is indicated to be available, and N frames can be cyclically encoded, so as to obtain N frames of compressed video frames.
Optionally, if the hard encoder fails to start, an error code may be returned and the code rate detection process exits, and the original video data is directly compressed by using the VBR mode according to the preset code rate to obtain the target compressed video; and the first video data can also be sent to a corresponding server to instruct the server to compress the first video data by utilizing a CQ mode, determine the estimated code rate according to the compression result and return the estimated code rate.
And 203, determining the estimated code rate according to the quotient of the total bit size corresponding to the compressed video frame and the preset duration.
Illustratively, the bit size s (i) of the compressed video frame after each frame encoding compression is accumulated, where i is 0,1, …, N-1. Finally, the total Size of the encoded N frames is calculated, Size ═ S (0) + S (1) + … + S (N-1). The reasonable coding rate br _ estimate of the video is estimated by the following formula, then the hard encoder can be turned off and the estimated coding rate value, i.e. the estimated coding rate, is returned.
Step 204, judging whether the estimated code rate is the same as the preset code rate, if so, executing step 206; otherwise, step 205 is performed.
Step 205, based on the equivalence mapping principle, mapping the estimated code rate from the estimated code rate range to the set mapping code rate range with reference to the preset code rate to obtain the mapping code rate.
And the preset code rate is contained in the range of the estimated code rate and the range of the set mapping code rate. Recording the upper limit value of the estimated code rate range as a first code rate (br _ estimate _ up) and the lower limit value as a second code rate (br _ estimate _ down); recording the upper limit value of the set mapping code rate range as a third code rate (br _ map _ up) and the lower limit value as a fourth code rate (br _ map _ down); determining the mapping code rate by using the estimated code rate, the preset code rate, the estimated code rate range and the set mapping code rate range based on the equivalence mapping principle, wherein the determining comprises the following steps:
when the predicted code rate (br _ estimate) is less than the preset code rate (br _ preset), the mapped code rate (br _ map) is determined by the following equation 1:
(br _ estimate-br _ estimate _ down)/(br _ preset-br _ estimate _ down) ═ br _ map-br _ map _ down)/(br _ preset-br _ map _ down) formula 1
When the predicted code rate (br _ estimate) is greater than the preset code rate (br _ preset), the mapped code rate (br _ map) is determined by the following equation 2:
(br _ estimate-br _ preeset)/(br _ estimate _ up-br _ preeset) (br _ map-br _ preeset)/(br _ m ap _ up-br _ preeset) equation 2
For ease of understanding, the following is exemplified:
assuming that the preset code rate is 1Mbps, the estimated code rate range is 200 Kbps-2 Mbps, and the mapping code rate range is set to be 400 Kbs-1.6 Mbps. The method comprises the steps of pre-coding a video for 1 second (namely, the preset duration is 1 second) by adopting a CQ mode to obtain an estimated code rate, and limiting the estimated code rate within the range of 200K-2M.
1) The obtained estimated code rate is assumed to be 1 Mbps. The mapping code rate does not need to be calculated, namely the mapping code rate is directly equal to 1 Mbps.
2) The estimated code rate is assumed to be 600 Kbps. Since 600K is smaller than 1M, the estimated 600K is mapped into the [400K,1M ] interval according to formula 1, i.e. the mapping code rate is equal to (600 + 200)/(1000 + 200) × (1000 + 400) +400, i.e. 700 Kbps.
3) The obtained estimated code rate is assumed to be 1.2 Mbps. Since 1.2M is greater than 1M, the estimated 1.2M is mapped into the [1M,1.6M ] interval according to equation 2, i.e. the mapping code rate is equal to (1200-1000)/(2000-1000) × (1600-1000) +1000, i.e. 1120 Kbs.
Step 206, configure the VBR mode local to the device and restart the hard encoder.
And step 207, compressing the original video data by using a hard encoder according to the mapping code rate to obtain a target compressed video.
The video compression method provided by the embodiment of the invention aims at the problem that the current mobile equipment can only compress videos according to a fixed code rate when compressing the videos in a hard coding mode and cannot balance the video quality and the code rate on the premise of pursuing quick compression, and provides a dynamic code rate hard coding compression scheme combining a CQ mode and a VBR mode.
Fig. 3 is a block diagram of a video compression apparatus according to an embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in a mobile device, and may perform a video compression process by executing a video compression method. As shown in fig. 3, the apparatus includes:
the data extraction module 301 is configured to obtain first video data of a preset duration in original video data when a video hard coding compression event is triggered;
an estimated code rate determining module 302, configured to perform compression processing on the first video data in a constant quality CQ mode, and determine an estimated code rate according to a compression result;
and the video compression module 303 is configured to compress the original video data in a preset mode according to the estimated code rate to obtain a target compressed video, where the preset mode is different from the CQ mode.
The video compression device provided by the embodiment of the invention obtains the first video data with the preset duration in the original video data when the video needs to be subjected to hard coding compression, compresses the first video data by utilizing a CQ mode, determines the estimated code rate according to the compression result, and compresses the original video data by adopting the preset mode except the CQ mode according to the estimated code rate to obtain the target compressed video. By adopting the technical scheme, the code rate adopted during hard coding compression can be reasonably determined, the video compression quality and the compression efficiency are considered, and the video compression effect is effectively improved.
In some embodiments, the compressing the first video data by using the CQ mode and determining the estimated bitrate according to the compression result includes:
compressing the video frames contained in the first video data by utilizing a CQ mode to obtain compressed video frames;
and determining the estimated code rate according to the bit size corresponding to the compressed video frame.
In some embodiments, the determining an estimated bitrate according to a bit size corresponding to the compressed video frame includes:
and determining the estimated code rate according to the quotient of the total bit size corresponding to the compressed video frame and the preset duration.
In some embodiments, the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video includes:
and under the condition that the estimated code rate is the same as the preset code rate, compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video.
In some embodiments, the video compression module is further to:
under the condition that the estimated code rate is different from the preset code rate, mapping the estimated code rate from an estimated code rate range to a set mapping code rate range by referring to the preset code rate based on an equivalent mapping principle to obtain a mapping code rate, wherein the preset code rate is contained in the estimated code rate range and the set mapping code rate range;
and compressing the original video data by adopting a preset mode according to the mapping code rate to obtain a target compressed video.
In some embodiments, the upper limit value of the estimated code rate range is recorded as a first code rate, and the lower limit value is recorded as a second code rate; recording the upper limit value of the range of the set mapping code rate as a third code rate and recording the lower limit value as a fourth code rate; determining the mapping code rate by using the estimated code rate, the preset code rate, the estimated code rate range and the set mapping code rate range based on the equivalence mapping principle, wherein the determining comprises the following steps:
when the estimated code rate is smaller than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-second code rate)/(preset code rate-second code rate) ═ mapping code rate-fourth code rate)/(estimated code rate-fourth code rate);
when the estimated code rate is greater than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-preset code rate)/(first code rate-preset code rate) ═ mapping code rate-preset code rate)/(third code rate-preset code rate).
In some embodiments, when the estimated code rate is less than or equal to the second code rate, determining a mapping code rate as the second code rate; and when the estimated code rate is greater than or equal to the first code rate, determining a mapping code rate as the first code rate.
In some embodiments, the compressing the first video data using CQ mode includes:
configuring a CQ mode local to the equipment and starting a hard encoder;
and in the case that the hard encoder is successfully started, performing compression processing on the first video data by using the hard encoder.
In some embodiments, the video compression module is further to:
and under the condition that the hard encoder fails to start, sending the first video data to a corresponding server to instruct the server to compress the first video data by utilizing a CQ mode, determining an estimated code rate according to a compression result, and returning the estimated code rate.
In some embodiments, the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video includes:
configuring a local preset mode of the equipment and restarting a hard encoder;
and compressing the original video data by using the hard encoder according to the estimated code rate to obtain a target compressed video.
In some embodiments, the preset mode comprises a variable rate, VBR, mode and/or a constant rate, CBR, mode.
In some embodiments, the video hard-coded compression event is triggered, including:
and when detecting that the code rate corresponding to the original video exceeds a preset code rate threshold or detecting that the resolution corresponding to the original video exceeds a preset resolution threshold and meeting a hard-coding compression condition, determining that a video hard-coding compression event is triggered.
The embodiment of the invention provides mobile equipment, and the video compression device provided by the embodiment of the invention can be integrated in the mobile equipment. Fig. 4 is a block diagram of a mobile device according to an embodiment of the present invention. The mobile device 400 comprises a memory 401, a processor 402 and a computer program stored on the memory 401 and executable on the processor 402, which when executed by the processor 402 implements the video compression method provided by an embodiment of the invention.
Embodiments of the present invention also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the video compression method provided by the embodiments of the present invention.
Storage medium-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk, or tape devices; computer system memory or random access memory such as DRAM, DDRRAM, SRAM, EDORAM, Lanbas (Rambus) RAM, etc.; non-volatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a different second computer system connected to the first computer system through a network (such as the internet). The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations, such as in different computer systems that are connected by a network. The storage medium may store program instructions (e.g., embodied as a computer program) that are executable by one or more processors.
The video compression device, the video compression equipment and the storage medium provided in the above embodiments can execute the video compression method provided in any embodiment of the present invention, and have corresponding functional modules and beneficial effects for executing the method. For technical details that are not described in detail in the above embodiments, reference may be made to a video compression method provided in any embodiment of the present invention.
Note that the above is only a preferred embodiment of the present invention. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in more detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the claims.

Claims (15)

1. A method of video compression, comprising:
when a video hard coding compression event is triggered, acquiring first video data with preset duration in original video data;
compressing the first video data by using a constant quality CQ mode, and determining an estimated code rate according to a compression result;
and compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video, wherein the preset mode is different from the CQ mode.
2. The method of claim 1, wherein the compressing the first video data by using the CQ mode and determining the estimated bitrate according to the compression result comprises:
compressing the video frames contained in the first video data by utilizing a CQ mode to obtain compressed video frames;
and determining the estimated code rate according to the bit size corresponding to the compressed video frame.
3. The method of claim 2, wherein determining the estimated bitrate according to the bit size corresponding to the compressed video frame comprises:
and determining the estimated code rate according to the quotient of the total bit size corresponding to the compressed video frame and the preset duration.
4. The method of claim 1, wherein the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video comprises:
and under the condition that the estimated code rate is the same as the preset code rate, compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video.
5. The method of claim 4, further comprising:
under the condition that the estimated code rate is different from the preset code rate, mapping the estimated code rate from an estimated code rate range to a set mapping code rate range by referring to the preset code rate based on an equivalent mapping principle to obtain a mapping code rate, wherein the preset code rate is contained in the estimated code rate range and the set mapping code rate range;
and compressing the original video data by adopting a preset mode according to the mapping code rate to obtain a target compressed video.
6. The method of claim 5, wherein an upper limit of the estimated code rate range is recorded as a first code rate, and a lower limit thereof is recorded as a second code rate; recording the upper limit value of the range of the set mapping code rate as a third code rate and recording the lower limit value as a fourth code rate; determining the mapping code rate by using the estimated code rate, the preset code rate, the estimated code rate range and the set mapping code rate range based on the equivalence mapping principle, wherein the determining comprises the following steps:
when the estimated code rate is smaller than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-second code rate)/(preset code rate-second code rate) ═ mapping code rate-fourth code rate)/(estimated code rate-fourth code rate);
when the estimated code rate is greater than the preset code rate, the mapping code rate is determined by the following formula:
(estimated code rate-preset code rate)/(first code rate-preset code rate) ═ mapping code rate-preset code rate)/(third code rate-preset code rate).
7. The method of claim 6, wherein when the estimated code rate is less than or equal to the second code rate, determining a mapping code rate as the second code rate; and when the estimated code rate is greater than or equal to the first code rate, determining a mapping code rate as the first code rate.
8. The method of claim 1, wherein the compressing the first video data using the CQ mode comprises:
configuring a CQ mode local to the equipment and starting a hard encoder;
and in the case that the hard encoder is successfully started, performing compression processing on the first video data by using the hard encoder.
9. The method of claim 8, further comprising:
and under the condition that the hard encoder fails to start, sending the first video data to a corresponding server to instruct the server to compress the first video data by utilizing a CQ mode, determining an estimated code rate according to a compression result, and returning the estimated code rate.
10. The method of claim 8, wherein the compressing the original video data in a preset mode according to the estimated bitrate to obtain a target compressed video comprises:
configuring a local preset mode of the equipment and restarting a hard encoder;
and compressing the original video data by using the hard encoder according to the estimated code rate to obtain a target compressed video.
11. The method according to claims 1-10, wherein the preset mode comprises a variable bitrate VBR mode and/or a constant bitrate CBR mode.
12. The method of claim 11, wherein the video hard-coded compression event is triggered, comprising:
and when detecting that the code rate corresponding to the original video exceeds a preset code rate threshold or detecting that the resolution corresponding to the original video exceeds a preset resolution threshold and meeting a hard-coding compression condition, determining that a video hard-coding compression event is triggered.
13. A video compression apparatus, comprising:
the data extraction module is used for acquiring first video data with preset duration in original video data when a video hard coding compression event is triggered;
the estimated code rate determining module is used for compressing the first video data by utilizing a constant quality CQ mode and determining an estimated code rate according to a compression result;
and the video compression module is used for compressing the original video data by adopting a preset mode according to the estimated code rate to obtain a target compressed video, wherein the preset mode is different from the CQ mode.
14. A mobile device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-12 when executing the computer program.
15. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-12.
CN202010084333.2A 2020-02-10 2020-02-10 Video compression method, device, equipment and storage medium Active CN111263162B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010084333.2A CN111263162B (en) 2020-02-10 2020-02-10 Video compression method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010084333.2A CN111263162B (en) 2020-02-10 2020-02-10 Video compression method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111263162A true CN111263162A (en) 2020-06-09
CN111263162B CN111263162B (en) 2022-02-18

Family

ID=70951068

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010084333.2A Active CN111263162B (en) 2020-02-10 2020-02-10 Video compression method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111263162B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112165620A (en) * 2020-09-24 2021-01-01 北京金山云网络技术有限公司 Video encoding method and device, storage medium and electronic equipment
CN113542761A (en) * 2021-06-23 2021-10-22 惠州Tcl云创科技有限公司 Multi-form video compression processing method and device based on mobile terminal and terminal

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170195672A1 (en) * 2015-12-31 2017-07-06 Facebook, Inc. Dynamic codec adaptation
CN109640094A (en) * 2018-11-27 2019-04-16 Oppo广东移动通信有限公司 Video encoding/decoding method, device and electronic equipment
CN109743639A (en) * 2018-12-25 2019-05-10 深圳市麦谷科技有限公司 A kind of method for controlling self-adaption code rate, system, computer equipment and storage medium
CN110225340A (en) * 2019-05-31 2019-09-10 北京猿力未来科技有限公司 A kind of control method and device of Video coding calculate equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170195672A1 (en) * 2015-12-31 2017-07-06 Facebook, Inc. Dynamic codec adaptation
CN109640094A (en) * 2018-11-27 2019-04-16 Oppo广东移动通信有限公司 Video encoding/decoding method, device and electronic equipment
CN109743639A (en) * 2018-12-25 2019-05-10 深圳市麦谷科技有限公司 A kind of method for controlling self-adaption code rate, system, computer equipment and storage medium
CN110225340A (en) * 2019-05-31 2019-09-10 北京猿力未来科技有限公司 A kind of control method and device of Video coding calculate equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112165620A (en) * 2020-09-24 2021-01-01 北京金山云网络技术有限公司 Video encoding method and device, storage medium and electronic equipment
CN113542761A (en) * 2021-06-23 2021-10-22 惠州Tcl云创科技有限公司 Multi-form video compression processing method and device based on mobile terminal and terminal
WO2022267609A1 (en) * 2021-06-23 2022-12-29 惠州Tcl云创科技有限公司 Mobile terminal-based multi-mode video compression processing method and apparatus, and terminal
CN113542761B (en) * 2021-06-23 2024-04-09 惠州Tcl云创科技有限公司 Multi-form video compression processing method and device based on mobile terminal, terminal and storage medium

Also Published As

Publication number Publication date
CN111263162B (en) 2022-02-18

Similar Documents

Publication Publication Date Title
CN110430441B (en) Cloud mobile phone video acquisition method, system, device and storage medium
CN110381316B (en) Video transmission control method, device, equipment and storage medium
CN111263162B (en) Video compression method, device, equipment and storage medium
CN109600610B (en) Data encoding method, terminal and computer readable storage medium
US10931953B2 (en) Video coding processing method, device and application with video coding function
US20150229960A1 (en) Information processing device, method, and terminal device
JP5164866B2 (en) Method and apparatus for adapting temporal frequency of video image sequences
WO2016049987A1 (en) Data processing method and apparatus, and related servers
CN102685472B (en) Method, device and system of data transmission
CN110392284B (en) Video encoding method, video data processing method, video encoding apparatus, video data processing apparatus, computer device, and storage medium
RU2624641C2 (en) Method and device for video quality control based on network environment
CN111669577A (en) Hardware decoding detection method and device, electronic equipment and storage medium
CN111263153B (en) Video encoding method, device, equipment and storage medium
CN110784718A (en) Video data encoding method, apparatus, device and storage medium
CN109729353B (en) Video coding method, device, system and medium
WO2021057697A1 (en) Video encoding and decoding methods and apparatuses, storage medium, and electronic device
CN112422963A (en) Cloud computer system, encoding method, device, equipment and storage medium
US20120236927A1 (en) Transmission apparatus, transmission method, and recording medium
US8681860B2 (en) Moving picture compression apparatus and method of controlling operation of same
CN115633191A (en) Video playing method, device, system, electronic equipment and readable storage medium
CN111193926B (en) Encoded data processing method, apparatus, computer device and storage medium
WO2021057478A1 (en) Video encoding and decoding method and related apparatus
CN114501017A (en) Video coding adaptation method, device, equipment and storage medium
CN111405293A (en) Video transmission method and device
CN114143596B (en) Screen projection control method and device, terminal equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20221206

Address after: 31a, 15 / F, building 30, maple mall, bangrang Road, Brazil, Singapore

Patentee after: Baiguoyuan Technology (Singapore) Co.,Ltd.

Address before: 5-13 / F, West Tower, building C, 274 Xingtai Road, Shiqiao street, Panyu District, Guangzhou, Guangdong 510000

Patentee before: GUANGZHOU BAIGUOYUAN INFORMATION TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right