Detailed Description
In order to make the objects, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present application, it is noted that, unless explicitly stated or limited otherwise, "including" and "having" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art. Further, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
In the related art, regarding the scheme of transparent video, the video content is composed of two areas, namely a color area and a transparent area, and for the compression scheme of transparent video, one is to implement transparent area compression by performing specific video coding on the video in MPEG-2 format; the other method is to compress the size of the transparent area in equal proportion when generating the video, and restore the transparent area by interpolation when playing the video.
Obviously, the compression of the transparent video is realized by adopting the two modes, which are loss compression modes, the loss is larger along with the larger compression ratio, and when the compression ratio is larger, the transparency restored during playing is distributed in a step shape/block shape, so that details are lost, and the video distortion is caused.
For convenience of understanding, terms referred to in the embodiments of the present application are explained.
First color information: and the R value, the G value and the B value are used for representing all pixel points in each initial frame image.
First transparency information: which is used to represent the transparency values (i.e., alpha channel values, denoted by a) of all the pixels in each initial frame image. For example, the RGBA values of a pixel are: when R is 255, G is 0, B is 0, and a is 151, the first color information includes R is 255, G is 0, B is 0, and the first transparency information includes a is 151.
Second color information: and the second R value, the second G value and the second B value are obtained after the transparency values of all the pixel points in each initial frame image are compressed.
The present application will be described in detail with reference to specific examples.
In the following method embodiments, for convenience of description, only the main execution body of each step is described as a terminal.
Fig. 1 is a schematic flow chart of a transparent video compression method according to an embodiment of the present disclosure. As shown in fig. 1, the method of the embodiment of the present application may include the steps of:
s101, size information, first color information and first transparency information of an initial frame image in an initial video are obtained, wherein the first transparency information comprises first transparencies of all pixel points in the initial frame image.
The original video refers to a video with a transparency channel, that is, the original video has information of an alpha channel in addition to RGB three-color information. The alpha channel is typically used as the opacity parameter. If a pixel has an alpha channel value of 0%, it is completely transparent (i.e., invisible), whereas a value of 100% means a completely opaque pixel (a conventional digital image), and values between 0% and 100% allow the pixel to be displayed through the background. Alpha channel values may be expressed in percentage, integer, or real numbers from 0 to 1 as with RGB parameters.
The size information refers to a width value and a height value of each initial frame image in the initial video, and represents the number of pixels of the initial frame image in the horizontal direction and the vertical direction respectively.
Specifically, each initial frame image of the initial video may be derived by the video tool according to the video frame rate, and at the same time, size information, first color information, and first transparency information of each initial frame image may also be obtained.
S102, generating a blank frame image corresponding to the initial frame image, wherein the blank frame image comprises a color area and a transparent area, and the size information of the color area and the size information of the transparent area are the same as the size information of the initial frame image.
The blank frame image refers to an image with a size twice that of the initial frame image, where the size twice is understood to be, on one hand, that the width value of the blank frame image is twice that of the initial frame image, and the height value of the blank frame image is equal to that of the initial frame image; on the other hand, it can be understood that the width value of the blank frame image is equal to the width value of the initial frame image, and the height value of the blank frame image is equal to twice the height value of the initial frame image.
The color area may be understood as an area for storing R values, G values, and B values of all pixel points in the initial frame image, and the position of each pixel point in the color area is the same as the position of each pixel point in the initial frame image. The transparent area may be understood as an area for storing a second R value, a second G value, and a second B value of all pixel points in the initial frame image, where the second R value is not equal to the R value in the color area, the second G value is not equal to the G value in the color area, the second B value is not equal to the B value in the color area, and the assignment process of the second R value, the second G value, and the second B value may be referred to in S103. The position of each pixel point in the transparent area is the same as the position of each pixel point in the initial frame image. Since the width and height values of the color region, the width and height values of the transparent region, and the width and height values of the initial frame image are the same, and the positions of the respective pixel points in the initial frame image are fixed, the positions of the respective pixel points can also be fixed in the color region and the transparent region.
According to some embodiments, as can be seen from the schematic diagram shown in fig. 2, 201 is an initial frame image, and in one aspect, 2021 and 2022 constitute a blank frame image, and 2021 and 2022 are both the same size as 201, and 2021 may be a color region and 2021 may be a transparent region, or 2021 may be a transparent region and 2022 may be a color region. On the other hand, 2031 and 2032 constitute blank frame images, 2031 and 2032 are each the same size as 201, 2031 may be a color area and 2031 may be a transparent area, or 2031 may be a transparent area and 2032 may be a color area.
And S103, writing the first color information into the color area, and writing the second color information obtained after the compression processing is performed on each first transparency into the transparent area to obtain a target frame image corresponding to the initial frame image.
The first color information refers to R values, G values, and B values of all pixel points in the initial frame image, and the second color information refers to second R values, second G values, and second B values obtained by compressing transparency values (first transparency, that is, a values) of all pixel points in the initial frame image.
Specifically, the process of obtaining the second R value, the second G value, and the second B value after performing compression processing on the first transparency of each pixel point can be understood as adopting three formulas, and substituting the a value into the three formulas to obtain the second R value, the second G value, and the second B value. The main function of these three equations is to convert the larger A value into the smaller second R value, second G value and second B value, i.e., the second R value, second G value and second B value are all less than or equal to the A value. Optionally, the second R value may be equal to the second G value, or the second G value may be equal to the second B value, or the second R value may be equal to the second B value. Further, the color area is filled with the R value, the G value, and the B value of each pixel, and the transparent area is filled with the second R value, the second G value, and the second B value of each pixel, so that the blank frame image filled with the color component values becomes the target frame image because the color area and the transparent area are initially blank frame images.
Generally, if the individual color component values in the three color components of the R value, the G value, and the B value of a pixel point are smaller and the difference between the individual color component values is smaller (the difference between the individual color components is closer to 0), the volume increment of the compressed transparent video is smaller. It is based on this principle that the embodiments of the present application compress the first transparency into smaller color component values.
And S104, generating a target video based on the target frame image corresponding to each initial frame image.
The target video is a video obtained by compressing the initial video, that is, the target video is a compressed transparent video. Specifically, the process of generating the target video from each target frame image may be understood as a process of generating the target video by performing compression coding on each target frame image. Generally, the digital video compression coding method is hybrid coding, i.e. three ways of transform coding, motion estimation and motion compensation, and entropy coding are combined to perform compression coding.
Transform coding functions to transform an image signal described in a spatial domain into a frequency domain and then perform coding processing on the transformed coefficients. Generally, images have strong correlation in space, and transformation to the frequency domain can achieve decorrelation and energy concentration. Common orthogonal transforms are discrete fourier transforms, discrete cosine transforms, and the like. The application of the digital video compression process is widely discrete cosine transform.
Entropy coding is known because the average code length after coding is close to the source entropy value. Entropy Coding is implemented by Variable Length Coding (VLC). The basic principle is that a short code is given to a symbol with high occurrence probability in a source, and a long code is given to a symbol with low occurrence probability, so that a short average code length is obtained statistically. Variable word length coding is typically huffman coding, arithmetic coding, run-length coding, and the like. The run-length coding is a very simple compression method, the compression efficiency is not high, but the coding and decoding speed is high, the run-length coding is still widely applied, and particularly, the run-length coding has a good effect when used after the transform coding.
Motion Estimation (Motion Estimation) and Motion Compensation (Motion Compensation) are effective means for removing temporal direction correlation of image sequences. The methods of DCT transformation, quantization and entropy coding are performed on the basis of a frame of image, and spatial correlation between pixels inside the image can be eliminated by these methods. In practice, the image signal has temporal correlation in addition to spatial correlation. For example, for a digital video with a small motion of the main frame, such as a news simulcast, the difference between each frame is small, and the correlation between frames is large. For this case we do not need to encode each frame image separately, but can encode only the changed part of the neighboring video frames, thereby further reducing the amount of data, which is achieved by motion estimation and motion compensation.
In practice, the several encoding methods are not separate and are usually combined to achieve the best compression.
When the scheme of the embodiment of the application is executed, size information, first color information and first transparency information of an initial frame image in an initial video are obtained, the first transparency information includes first transparency of each pixel point in the initial frame image, a blank frame image corresponding to the initial frame image is generated, the blank frame image includes a color area and a transparent area, the size information of the color area and the size information of the transparent area are the same as the size information of the initial frame image, the first color information is written into the color area, second color information obtained after compression processing is performed on each first transparency is written into the transparent area, a target frame image corresponding to the initial frame image is obtained, and a target video is generated based on the target frame image corresponding to each initial frame image. According to the method and the device, the color information obtained after the transparency of all the pixel points in the initial frame image is compressed is written into the transparent area, and then the compressed initial video is generated based on each target frame image formed by the transparent area and the color area, so that the transparency of all the pixel points in the initial video is kept, and the problem of distortion of the compressed transparent video can be avoided.
In the following method embodiments, for convenience of description, only the main execution body of each step is described as a terminal.
Please refer to fig. 3, which is a flowchart illustrating a transparent video compression method according to an embodiment of the present disclosure. As shown in fig. 3, the method of the embodiment of the present application may include the steps of:
s301, size information, first color information and first transparency information of an initial frame image in an initial video are obtained, wherein the first transparency information comprises first transparency of each pixel point in the initial frame image.
S302, generating a blank frame image corresponding to the initial frame image, wherein the blank frame image comprises a color area and a transparent area, and the size information of the color area and the size information of the transparent area are the same as the size information of the initial frame image.
S303, writing the first color information into the color area.
Specifically, S301 to S303 can refer to S101 to S103 in fig. 1, and are not described herein again.
S304, determining the target transparency with the highest proportion in the first transparency information.
Specifically, since the first transparency information refers to the first transparencies of all the pixel points in each initial frame image, and the target transparency with the highest ratio is determined, it can be understood that the first transparency with the highest occurrence frequency is selected from the first transparencies, and the first transparency with the highest occurrence frequency is used as the target transparency. Thus, for each initial frame image in the initial video, there will be a target transparency for each initial frame image.
For example, in an initial frame image, there are 959 by 959 pixels, the first transparency of the pixels may be 100, 125, 130, 134, 135, 136, and so on, where the transparency ranges from 0 to 255, and the value with the highest frequency of occurrence in the first transparency is 134, so that the target transparency may be 134 for the initial frame image.
S305, acquiring corresponding relations between different compression magnifications under the target transparency and different compression volumes of the target video, selecting the compression magnification with the minimum compression volume from the different compression magnifications, and taking the compression magnification with the minimum compression volume as the compression magnification corresponding to the target transparency.
Here, the compression ratio refers to a compression value for compressing the first transparency, and how to compress the first transparency using the compression ratio can be seen in the following description of S307.
Specifically, for the target transparency, a plurality of different compression ratios may be preset, and after the target transparency is compressed by the plurality of compression ratios, the second color information of each pixel point in the initial frame image may be obtained, further, the target frame image corresponding to the initial frame image may be obtained, and after the target frame image is compressed and encoded, the compressed transparent video, that is, the target video may be obtained. The volume of the target video at this time may be referred to as a compressed volume, and it can be understood that, for the same target transparency, compressed volumes obtained by different compression ratios are also different, so that the compression ratio with the smallest compressed volume may be selected, and the compression ratio with the smallest compressed volume may be used as the target compression ratio. Because, the purpose of compressing transparent video is also to achieve the effect of smaller compressed volume.
For example, if the target transparency is 134, the preset compression ratio is 15 integers in the range of 1-15, and of the compression volumes corresponding to the 15 compression ratios, the compression volume corresponding to the integer 13 is the smallest, and then 13 can be used as the target compression ratio of the target transparency 134.
And S306, taking the compression magnification corresponding to the target transparency as the target compression magnification corresponding to the initial frame image.
Specifically, as can be seen from S304-S305, if the target transparency is the selected transparency for each initial frame image, the compression magnification corresponding to the target transparency may be used as the target compression magnification of the initial frame image. That is, the first transparencies of all the pixels in the initial frame image may be compressed according to the target compression magnification, which may be specifically referred to as S307, and are not described herein again.
S307, compressing each first transparency according to the target compression magnification to obtain second color information of each pixel point in the color area, and writing the second color information into the transparent area to obtain a target frame image corresponding to the initial frame image.
Specifically, each of the first transparencies is compressed according to the target compression ratios, and it can be understood that a preset formula is adopted, the preset formula is related to the target compression ratios, different target compression ratios can correspond to different formulas, the first transparencies of the respective pixels can be respectively substituted into the formulas to obtain a second R value, a second G value and a second B value of the respective pixels, and the second R value, the second G value and the second B value of each pixel are respectively written into the position of each pixel in the transparent area, and further, the transparent area filled with the second color information and the color area filled with the first color information can form a target frame image.
For example, ratio is used to represent a target compression magnification, R1 is used to represent a second R value, G1 is used to represent a second G value, B1 is used to represent a second B value, and a is used to represent a first transparency of each pixel, and according to different target compression magnifications, a preset formula may be:
(1)ratio=1,R1=A,G1=0,B1=0;
(2)ratio=2,
G1=R1,B1=A-R1*2;
(3)ratio≥3,
G1=R1,B1=A-R1*(ratio-1)。
for example, referring to the schematic diagram of generating the target frame image shown in fig. 4, 401 represents an initial frame image, 4021 represents a color region in a blank frame image, 4022 represents a transparent region in the blank frame image, and RGBA values of a certain pixel in 401 are: r is 255, G is 0, B is 0, a is 156; when the target transparency of the initial frame image shown in 401 is 255 and the target compression magnification corresponding to 255 is 10, the value a of the pixel point may be substituted into the above equation (3), and R1, G1, and B1 may be obtained as 15, and 21, respectively. Therefore, R255, G0, and B0 may be filled in the position of the pixel point in the color region 4021, R1 15, G1 15, and B1 21 may be filled in the position of the pixel point in the transparent region 4022.
And S308, generating a target video based on the target frame image corresponding to each initial frame image.
Specifically, see S104 in fig. 1, which is not described herein again.
S309, writing the target compression magnification, the size information of the color area and the size information of the transparent area into the target video.
The size information of the color area may include an area range occupied by the color area in the blank frame image, in addition to the width value and the height value of the color area. Similarly, the size information of the transparent area may include an area range occupied by the transparent area in the blank frame image, in addition to the width value and the height value of the transparent area. For example, referring to the schematic diagram of the blank frame image shown in fig. 2, if 201 represents the initial frame image, 2021 represents the color region, 2022 represents the transparent region, 201 has a size of 100 × 100, and 2021 and 2022 have a size of 100 × 100, but the size of the blank frame image or the target frame image composed of 2021 and 2022 may be 200 × 100, then the region range occupied by 2021 in the blank frame image may be the pixel region having a width value of 0-100 and a height value of 100, and the region range occupied by 2022 in the blank frame image may be the pixel region having a width value of 100-.
Specifically, after the target video is obtained after the initial video is compressed, the target compression magnification, the size information of the color area, and the size information of the transparent area may be written into a header file of the target video. It can be understood that the frame rate and the frame number of the initial video can also be written into the header file of the target video, so as to facilitate the subsequent decoding and decompression of the target video.
S310, when the target video is played, reading the target compression magnification, the size information of the color area and the size information of the transparent area in the target video.
Specifically, when playing a target video, a target compression magnification of the target video, size information of a color region in a target frame image, and size information of a transparent region in the target frame image need to be acquired first. And acquiring the target compression magnification of the target video and the size information of the transparent area in the target frame image, so as to restore the first transparency of each pixel point in each initial frame image according to the second color information and the target compression magnification filled in the transparent area. The size information of the color region is obtained to obtain the R value, G value and B value of each pixel point in each initial frame image.
S311, determining a first transparency of each pixel point of the color area in the initial frame image according to the target compression magnification and the second color information corresponding to the transparent area.
Specifically, since it has been described in S307, when the second color information of the transparent region is calculated, a preset formula may be adopted, and the target compression ratio and the first transparency of each pixel point are calculated. Therefore, when the first transparency of each pixel point is restored, the reverse operation can be performed according to a formula, and the first transparency of each pixel point can be obtained.
For example, following the example in S307, when the first transparency is restored in the embodiment of the present application, the adopted calculation formula may be:
(1)ratio=1,A=R1;
(2)ratio=2,A=R1+G1+B1;
(3)ratio≥3,A=R1*(ratio-2)+G1+B1。
s312, obtaining the initial frame image based on the first transparency, the first color information corresponding to the color region, the size information of the color region, and the size information of the transparent region, and playing the initial video including all the initial frame images.
Specifically, since the first transparency of each pixel point in the initial frame image is obtained through the above calculation process, when the initial frame image is restored, the first color information in the color region in the target frame image, that is, the R value, the G value, and the B value of each pixel point, needs to be obtained. When the first color information of the color area is read, the reading can be performed according to the position of each pixel point in the color area. When reading each first transparency corresponding to the second color area in the transparent area, reading can also be performed according to the position of each pixel point in the transparent area. Because the positions of the pixel points in the color region and the transparent region are the same as the positions of the pixel points in the initial frame image. Therefore, the RGBA value of each pixel point in the initial frame image can be obtained in sequence according to the position of each pixel point. Further, the process of obtaining the initial video through the RGBA values of the pixels is well known to those skilled in the art, and is not described herein again.
In the embodiment of the application, the obtained first color information of the initial frame image is written into a color area in the blank frame image, the highest target transparency is determined in the first transparency information corresponding to each initial frame image, and then the target compression magnification corresponding to each target transparency is determined, that is, each initial frame image compresses the first transparency of each pixel point in each initial frame image by using the respective compression magnification to obtain the second color information of each pixel, and then the second color is written into a transparent area in the blank frame image, so that the target frame image can be obtained, and then the target video is obtained from each target frame image. Therefore, when the initial video is restored through the target video, the first transparency of each pixel point can be restored according to the compression magnification and the second color information. The transparency of each pixel point is reserved, so that lossless compression of the transparent video is realized, and the problem that the compressed transparent video is distorted during restoration can be avoided. In addition, the process of compressing each first transparency of the present application is different from the related art, each color component in the transparent region may be directly equal to the transparency, but the value of each color component in the transparent region may be smaller, and the difference value between each color component may be smaller, so that the increment volume of the transparent video after compression may be reduced.
Alternatively, on the basis of fig. 3, as shown in fig. 5, S304 and S306 may be replaced with S504 and S506.
And S504, determining the target transparency with the highest ratio in the second transparency information.
The second transparency information refers to first transparencies of all pixel points of all initial frame images of the initial video. That is, the second transparency information includes the first transparency of all the pixels in the original video.
Specifically, the target transparency with the highest ratio is determined in the second transparency information, and it can be understood that the first transparency with the highest occurrence frequency is selected from the first transparencies corresponding to all the pixel points, and the first transparency with the highest occurrence frequency is used as the target transparency. Therefore, for each initial frame image in the initial video, each initial frame image corresponds to the same target transparency.
For example, in an initial video, the first transparency of the pixels may be 0, 30, 35, 40, 50, 100, 125, 135, 136, 199, 234, etc., where the transparency has a value ranging from 0 to 255, and the value with the highest frequency of occurrence in the first transparency is 100, then the target transparency may be 100 for the initial video.
S506, taking the compression magnification corresponding to the target transparency as the target compression magnification corresponding to the initial frame image.
Specifically, as can be seen from S504, if the target transparency is the transparency selected for the initial video, the compression magnification corresponding to the target transparency of the initial video may be used as the target compression magnification of all the initial frame images. That is, the first transparencies of all the pixel points in all the initial frame images can be compressed according to the same target compression magnification.
In the embodiment of the application, when the target transparency is selected, the transparency value of each pixel point in all initial frame images in the initial video is determined, so that when the transparency value of each pixel point is compressed, only one target compression magnification is selected for compression, and then the transparency value of each pixel point is restored only by adopting the target compression magnification. By selecting a target transparency and acquiring a target compression ratio, the distortion problem during the restoration of the compressed transparent video can be avoided, and the calculation process can be simplified.
Fig. 6 is a schematic structural diagram of a transparent video compression apparatus according to an embodiment of the present application. The transparent video compression apparatus 600 may be implemented by software, hardware, or a combination of both as all or a part of a terminal. The apparatus 600 comprises:
an information obtaining module 610, configured to obtain size information, first color information, and first transparency information of an initial frame image in an initial video, where the first transparency information includes a first transparency of each pixel point in the initial frame image;
an image frame generating module 620, configured to generate a blank frame image corresponding to the initial frame image, where the blank frame image includes a color region and a transparent region, and size information of the color region and size information of the transparent region are the same as size information of the initial frame image;
an image frame processing module 630, configured to write the first color information into the color region, and write second color information obtained after compressing each of the first transparencies into the transparent region, so as to obtain a target frame image corresponding to the initial frame image;
and a video generating module 640, configured to generate a target video based on a target frame image corresponding to each of the initial frame images.
Optionally, the image frame processing module 630 includes:
a first obtaining unit, configured to obtain a target compression magnification corresponding to the initial frame image;
and the second compression unit is used for respectively compressing each first transparency according to the target compression multiplying power to obtain second color information of each pixel point in the color area, and writing the second color information into the transparent area.
Optionally, the first obtaining unit includes:
the first obtaining subunit is configured to determine, in the first transparency information, a target transparency with a highest proportion, and determine a compression magnification corresponding to the target transparency;
and the second acquisition subunit is configured to use the compression magnification corresponding to the target transparency as the target compression magnification corresponding to the initial frame image.
Optionally, the first obtaining unit includes:
a third obtaining subunit, configured to determine a target transparency with a highest ratio in second transparency information, and determine a compression magnification corresponding to the target transparency, where the second transparency information includes first transparencies of all pixel points of all initial frame images of the initial video;
and the fourth acquisition subunit is configured to use the compression magnification corresponding to the target transparency as the target compression magnification corresponding to the initial frame image.
Optionally, the first obtaining subunit or the third obtaining subunit includes:
a fifth obtaining subunit, configured to obtain a correspondence between different compression magnifications under the target transparency and different compression volumes of the target video;
and the sixth acquiring subunit is configured to select, from the different compression ratios, a compression ratio with a smallest compression volume, and use the compression ratio with the smallest compression volume as the compression ratio corresponding to the target transparency.
Optionally, the apparatus 600 further includes:
and the information writing module is used for writing the target compression magnification, the size information of the color area and the size information of the transparent area into the target video.
The first playing module is used for reading the target compression multiplying power, the size information of the color area and the size information of the transparent area in the target video when the target video is played;
the second playing module is used for determining the first transparency of each pixel point of the color area in the initial frame image according to the target compression multiplying power and the second color information corresponding to the transparent area;
a third playing module, configured to obtain the initial frame image based on each of the first transparency levels, the first color information corresponding to the color region, the size information of the color region, and the size information of the transparent region, and play the initial video including all the initial frame images.
Optionally, the apparatus 600 further includes:
a first calculation module, when ratio is 1, R1 is a, G1 is 0, and B1 is 0;
a second calculation module, when the ratio is 2,
G1=R1,B1=A-R1*2;
a third calculation module, when the ratio is more than or equal to 3,
G1=R1,B1=A-R1*(ratio-1);
wherein, the ratio is the target compression magnification, the a is the first transparency of each pixel in the initial frame image, and the R1, the G1, and the B1 are the values of each color channel in the second color information, respectively.
When the scheme of the embodiment of the application is executed, size information, first color information and first transparency information of an initial frame image in an initial video are obtained, the first transparency information includes first transparency of each pixel point in the initial frame image, a blank frame image corresponding to the initial frame image is generated, the blank frame image includes a color area and a transparent area, the size information of the color area and the size information of the transparent area are the same as the size information of the initial frame image, the first color information is written into the color area, second color information obtained after compression processing is performed on each first transparency is written into the transparent area, a target frame image corresponding to the initial frame image is obtained, and a target video is generated based on the target frame image corresponding to each initial frame image. According to the method and the device, the color information obtained after the transparency of all the pixel points in the initial frame image is compressed is written into the transparent area, and then the compressed initial video is generated based on each target frame image formed by the transparent area and the color area, so that the transparency of all the pixel points in the initial video is kept, and the problem of distortion of the compressed transparent video can be avoided.
Referring to fig. 7, a block diagram of a terminal 700 according to an exemplary embodiment of the present application is shown. The terminal 700 in the present application may include one or more of the following components: a display component 701, a memory 702, and a processor 703. The display device 701 is electrically connected to the processor 703, and the processor 703 is electrically connected to the memory 702.
The display component 701 is used for playing the original video of the target video after decompression processing.
The Memory 702 may include a Random Access Memory (RAM) or a Read-Only Memory (ROM). Optionally, the memory 702 includes a non-transitory computer-readable medium. The memory 702 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, and the like), instructions for implementing the above method embodiments, and the like, and the operating system may be an Android (Android) system (including a system based on Android system depth development), an IOS system developed by apple inc (including a system based on IOS system depth development), or other systems. The storage data area may also store data created by the terminal 700 during use (e.g., phone book, audio-video data, chat log data), etc.
The processor 703 may include one or more processing cores. The processor 703 connects various parts within the overall terminal 700 using various interfaces and lines, and performs various functions of the terminal 700 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 702 and calling data stored in the memory 702. Alternatively, the processor 703 may be implemented in at least one hardware form of a DSP, a Field-Programmable gate Array (FPGA), and a Programmable Logic Array (PLA). The processor 703 may integrate one or a combination of a CPU, a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing contents required to be displayed by the touch display screen; the modem is used to handle wireless communications. It is to be understood that the modem may not be integrated into the processor 703, but may be implemented by a communication chip. In this embodiment, the processor 703 may obtain size information of an initial frame image in an initial video, first color information, and first transparency information, where the first transparency information includes first transparency of each pixel point in the initial frame image, generate a blank frame image corresponding to the initial frame image, where the blank frame image includes a color region and a transparent region, the size information of the color region and the size information of the transparent region are the same as the size information of the initial frame image, write the first color information into the color region, write second color information obtained by compressing each of the first transparencies into the transparent region, obtain a target frame image corresponding to the initial frame image, and generate a target video based on the target frame image corresponding to each of the initial frame images. Therefore, the color information obtained by compressing the transparency of all the pixel points in the initial frame image is written into the transparent area, and the compressed initial video is generated based on each target frame image consisting of the transparent area and the color area, so that the transparency of all the pixel points in the initial video is kept, and the problem of distortion of the compressed transparent video during restoration can be avoided.
Optionally, the display component 701 in the terminal 700 may further include a touch display screen, which may be a capacitive touch display screen, and the capacitive touch display screen is configured to receive a touch operation of a user on or near the touch display screen by using any suitable object such as a finger, a touch pen, and the like, and display a user interface of each application program. The touch display screen is generally disposed on a front panel of the terminal 700. The touch display screen can be designed as a full-screen, a curved screen or a profiled screen. The touch display screen can be designed to be a combination of a full screen and a curved screen, and a combination of a special-shaped screen and a curved screen, which are not limited in the embodiment of the present application.
Optionally, the terminal 700 may further include at least one of speaker assemblies, the processor 703 is electrically connected to the speaker assembly, and the processor 703 is configured to control the speaker assembly to play the audio of the initial video obtained by decompressing the target video through the driver.
In addition, those skilled in the art will appreciate that the configuration of terminal 700 depicted in the above-described figures is not meant to be limiting with respect to terminal 700, and that terminal may include more or less components than those shown, or some components may be combined, or a different arrangement of components. For example, the terminal 700 further includes a radio frequency circuit, an audio circuit, a wireless fidelity (WiFi) module, a power supply, a bluetooth module, and other components, which are not described herein again.
The embodiments of the present application further provide a computer-readable storage medium, which stores at least one instruction for execution by a processor to implement the transparent video compression method according to the above embodiments.
The embodiment of the present application further provides a computer program product, where at least one instruction is stored, and the at least one instruction is loaded and executed by the processor to implement the transparent video compression method according to the above embodiments.
Those skilled in the art will recognize that, in one or more of the examples described above, the functions described in the embodiments of the present application may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
The above description is only exemplary of the present application and should not be taken as limiting, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.