Video compression and decompression method, device, equipment and storage medium
By dividing the video frame pictures into odd and even sets and performing complementary cutout encoding, the problem of low compression ratio of existing videos is solved, and more efficient video compression and storage transmission is achieved.
Patent Information
- Application Number
- CN202110854062.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-27
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-07-27
AI Technical Summary
Existing video compression standards such as H.264 and H.265 have low compression ratios for videos, resulting in insufficient improvements in storage and transmission.
Compressed videos are generated by dividing video frame images into odd and even image collections, and complementary cutouts and encodings. The specific steps include detecting video compression instructions, splitting video frame pictures, setting picture numbers, dividing odd and even picture collections, performing complementary cutouts and encodings, and obtaining compressed videos.
It significantly improves the compression ratio of video, reduces the amount of information, and improves storage and transmission efficiency.
Smart Images

Figure CN113596453B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a video compression and decompression method, device, equipment and storage medium. Background Art
[0002] Videos generally contain a huge amount of information, which is difficult to store and transmit. Therefore, videos need to be compressed to facilitate storage and transmission. At present, the main video compression standards are H.264 and H.265. By using H.264 and H.265 to compress the video as a whole, the amount of information in the video can be reduced to a certain extent, making it easier to store and transmit the video. However, if the video is compressed as a whole only in this way, the compression ratio of the video is low, and the compressed video is still very large, and the improvement effect on storage and transmission is not obvious enough.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a video compression and decompression method, device, equipment and storage medium, aiming to solve the technical problem of low video compression ratio in the prior art.
[0005] To achieve the above object, the present invention provides a video compression method, which comprises the following steps:
[0006] When a video compression instruction is detected, a corresponding video to be compressed is determined according to the video compression instruction, and the video to be compressed is split into a plurality of video frame images;
[0007] Setting picture numbers for the video frame pictures, and dividing the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers;
[0008] Performing complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set, wherein the complementary cutouts are the cutout regions corresponding to the odd picture set and the cutout regions corresponding to the even picture set complement each other;
[0009] The odd-numbered cutout set and the even-numbered cutout set are encoded to obtain a compressed video.
[0010] Optionally, the step of performing complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set includes:
[0011] Obtain a standard video frame image, and divide the standard video frame image into regions according to a preset cutout interval to obtain a plurality of image sub-regions;
[0012] Selecting odd-numbered cutout regions from the image sub-regions according to a preset region selection rule, and using the remaining image sub-regions as even-numbered cutout regions;
[0013] The video frame pictures in the odd picture set are cut out according to the odd cutout area to obtain an odd cutout set, and the video frame pictures in the even picture set are cut out according to the even cutout area to obtain an even cutout set.
[0014] Optionally, the step of obtaining a preset encoding type, encoding the odd-numbered cutout set and the even-numbered cutout set based on the preset encoding type, and obtaining a compressed video includes:
[0015] Get the preset encoding type;
[0016] When the preset encoding type is simultaneous encoding, combining the odd cutout set and the even cutout set according to the picture numbers corresponding to the video frame pictures in the odd cutout set and the even cutout set to obtain a video cutout set;
[0017] The video cutout set is encoded according to a preset encoding method to obtain a compressed video.
[0018] Optionally, after the step of obtaining the preset encoding type, the method further includes:
[0019] When the preset encoding type is odd-even dual encoding, the video to be compressed is shot-split to obtain multiple screen shots;
[0020] Determine the odd-numbered shots and the even-numbered shots corresponding to each picture shot according to the odd-numbered cutout set and the even-numbered cutout set;
[0021] Encapsulate the odd-numbered lenses and even-numbered lenses corresponding to each picture lens into the same lens file to obtain the lens file corresponding to each picture lens;
[0022] Combine the lens files corresponding to each screen lens to obtain a compressed video.
[0023] In addition, to achieve the above object, the present invention also proposes a video decompression method, which comprises the following steps:
[0024] When a video decompression instruction is detected, obtaining a compressed video to be decompressed corresponding to the video decompression instruction;
[0025] Decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set;
[0026] Obtaining picture numbers corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set;
[0027] The odd-numbered cutout set and the even-numbered cutout set are combined according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
[0028] Optionally, before the step of decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set, the step further includes:
[0029] Obtaining the encoding type corresponding to the compressed video to be decompressed;
[0030] If the encoding type is odd-even dual encoding, obtaining multiple screen shots corresponding to the compressed video to be decompressed;
[0031] The step of combining the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed comprises:
[0032] Get the lens file corresponding to each screen lens;
[0033] Decoding the lens file to obtain odd-numbered lenses and even-numbered lenses corresponding to each picture lens;
[0034] An odd-numbered cutout set and an even-numbered cutout set are determined according to the odd-numbered shots and the even-numbered shots corresponding to each picture lens.
[0035] In addition, to achieve the above object, the present invention also provides a video compression device, which includes the following modules:
[0036] An instruction receiving module is used to determine the corresponding video to be compressed according to the video compression instruction when a video compression instruction is detected, and split the video to be compressed into multiple video frame pictures;
[0037] A picture splitting module, used to set picture numbers for the video frame pictures, and divide the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers;
[0038] A complementary cutout module is used to perform complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set, wherein the complementary cutouts are the cutout regions corresponding to the odd picture set and the cutout regions corresponding to the even picture set complement each other;
[0039] The picture encoding module is used to encode the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video.
[0040] In addition, to achieve the above object, the present invention also provides a video decompression device, which includes the following modules:
[0041] An instruction receiving module, used for acquiring the compressed video to be decompressed corresponding to the video decompression instruction when a video decompression instruction is detected;
[0042] A video decoding module, used for decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set;
[0043] A number acquisition module, used to obtain the picture number corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set;
[0044] The picture combination module is used to combine the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
[0045] In addition, to achieve the above-mentioned purpose, the present invention also proposes a terminal device, which includes: a processor, a memory, and a video compression program or a video decompression program stored in the memory and run on the processor, wherein the video compression program implements the steps of the video compression method described above when executed by the processor, and the video decompression program implements the steps of the video decompression method described above when executed by the processor.
[0046] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer-readable storage medium, on which a video compression program or a video decompression program is stored. When the video compression program is executed, the steps of the video compression method described above are implemented, and when the video decompression program is executed, the steps of the video decompression method described above are implemented.
[0047] When the video compression instruction is detected, the present invention determines the corresponding video to be compressed according to the video compression instruction, and splits the video to be compressed into multiple video frame pictures; sets picture numbers for the video frame pictures, and divides the video frame pictures into an odd picture set and an even picture set according to the picture numbers; performs complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set; and encodes the odd cutout set and the even cutout set to obtain a compressed video. Since the video frame pictures in the odd picture set and the even picture set obtained by splitting the video to be compressed are complementary cutouts, a large amount of information can be reduced, and therefore, the compression ratio of the video can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;
[0049] Figure 2 It is a flowchart of a first embodiment of a video compression method of the present invention;
[0050] Figure 3 A schematic diagram of image group splitting in one embodiment of the present invention;
[0051] Figure 4 Schematic diagram of odd-numbered cutout area division in one embodiment of the present invention;
[0052] Figure 5 Schematic diagram of the division of even-numbered cutout regions in one embodiment of the present invention;
[0053] Figure 6 It is a flow chart of the second embodiment of the video compression method of the present invention;
[0054] Figure 7 It is a flowchart of a first embodiment of a video decompression method of the present invention;
[0055] Figure 8 It is a flow chart of a second embodiment of a video decompression method of the present invention;
[0056] Fig. 9 is a structural block diagram of a first embodiment of a video compression device of the present invention;
[0057] Fig.10 It is a structural block diagram of the first embodiment of the video decompression device of the present invention.
[0058] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0060] Reference Figure 1 , Figure 1 A schematic diagram of the terminal device structure of the hardware operating environment involved in the embodiment of the present invention.
[0061] like Figure 1As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0062] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0063] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a video compression program or a video decompression program.
[0064] exist Figure 1 In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in a terminal device, and the electronic device calls the video compression program or the video decompression program stored in the memory 1005 through the processor 1001, and executes the video compression method or the video decompression method provided in an embodiment of the present invention.
[0065] The embodiment of the present invention provides a video compression method, referring to Figure 2 , Figure 2 FIG. 4 is a flow chart of a first embodiment of a video compression method according to the present invention.
[0066] In this embodiment, the video compression method includes the following steps:
[0067] Step S10: when a video compression instruction is detected, a corresponding video to be compressed is determined according to the video compression instruction, and the video to be compressed is split into a plurality of video frame images.
[0068] It should be noted that the executor of this embodiment can be the terminal device, and the terminal device can be an electronic device such as a mobile phone, a tablet computer, a personal computer, a server, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the video compression method or video decompression method of the present invention is described by taking the terminal device as an example.
[0069] It should be noted that the video compression instruction can be an instruction generated by the user operating the terminal device when video compression is required, or an instruction sent by the user to the terminal device through other devices. The video to be compressed can be a video that needs to be compressed that is pre-transmitted by the user to the terminal device.
[0070] It can be understood that a video is composed of multiple video frame images. Therefore, a video can be split into multiple video frame images. For example, assuming that the frame rate of video A is 50 Hz and the video length is 5 seconds, video A can be split into 50*5=250 video frame images.
[0071] In actual use, the video to be compressed may be a compressed video. In this case, the video to be compressed is composed of multiple image groups (Group of Picture, GOP), and GOP is composed of key frames (I frames), bidirectional prediction frames (B frames) and forward prediction frames (P frames). Then, splitting the video to be compressed into multiple video frame pictures can be splitting it into multiple image groups according to the key frames in the video to be compressed, and taking each image group as a video frame picture.
[0072] For ease of understanding, refer to Figure 3 This is for illustration, but not for limitation. Figure 3 This is a schematic diagram of the image group splitting in this embodiment, wherein the box labeled I represents I frame positioning, the box labeled B represents B frame positioning, the box labeled P represents P frame positioning, GOP#1 represents the GOP with picture number 1, and GOP#1 represents the GOP with picture number 2.
[0073] Step S20: setting picture numbers for the video frame pictures, and dividing the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers.
[0074] It should be noted that the picture numbering for the video frame pictures can be set according to the video playback order, and the starting number of the picture numbering can be 1. Dividing the video frame pictures into an odd picture set and an even picture set according to the picture numbering can be by first creating two blank sets A and B, adding the video frame pictures with odd picture numbers to set A, and adding the video frame pictures with even picture numbers to set B. After all the video frame pictures have been added, set A is used as an odd picture set, and set B is used as an even picture set.
[0075] Step S30: Complementarily cut out the video frame pictures in the odd picture set and the even picture set to obtain an odd cut out set and an even cut out set, wherein the complementary cut out is that the cut out area corresponding to the odd picture set is complementary to the cut out area corresponding to the even picture set.
[0076] It should be noted that the complementary cutout of the video frame images in the odd picture set and the even picture set can be achieved by setting complementary odd cutout areas and even cutout areas, and then cutting out the video frame images in the odd picture set according to the odd cutout areas to obtain the odd cutout set, and cutting out the video frame images in the even picture set according to the even cutout areas to obtain the even cutout set.
[0077] In actual use, if the video frame picture is a GOP, only the I frame in the GOP is cut out when the video frame picture is cut out.
[0078] Furthermore, in order to reasonably set the odd-numbered cutout areas and the even-numbered cutout areas, step S30 in this embodiment may include:
[0079] Obtain a standard video frame image, and divide the standard video frame image into regions according to a preset cutout interval to obtain a plurality of image sub-regions;
[0080] Selecting odd-numbered cutout regions from the image sub-regions according to a preset region selection rule, and using the remaining image sub-regions as even-numbered cutout regions;
[0081] The video frame pictures in the odd picture set are cut out according to the odd cutout area to obtain an odd cutout set, and the video frame pictures in the even picture set are cut out according to the even cutout area to obtain an even cutout set.
[0082] It should be noted that the standard video frame image can be determined according to the video display format of the video to be compressed. For example, if the video display format of the video to be compressed is 1080P, that is, the resolution of the video to be compressed is 1920*1080, then the resolution of the standard video frame image can also be 1920*1080. The preset cutout interval can be set by the administrator of the terminal device according to actual needs, and the unit can be pixels. For example, the preset cutout interval is set to 16 pixels or 1 pixel. The preset area selection rule can be pre-set by the administrator of the terminal device according to actual needs, and this embodiment does not limit this.
[0083] In actual use, obtaining a standard video frame image can be to search for a corresponding annotated video frame image in a standard image library according to the video display format of the video to be compressed. The standard image library can include standard video frame images of various resolutions, wherein the standard image library can be pre-set by the administrator of the terminal device. Dividing the standard video frame image into regions according to the preset cutout interval, obtaining multiple image sub-regions can be to divide the standard video frame image into multiple rows using the preset cutout interval as the row height, and each row as a picture sub-region, thereby obtaining multiple picture sub-regions; it can also be to divide the standard video frame image into multiple columns using the preset cutout interval as the column width, and each column as a picture sub-region, thereby obtaining multiple picture sub-regions; it can also be to divide the standard video frame image into multiple square regions using the preset cutout interval as the side length, and each square region as a picture sub-region, thereby obtaining multiple picture sub-regions.
[0084] It should be noted that the video frame images in the odd-numbered image set are cut out according to the odd-numbered cutout area to obtain the odd-numbered cutout set, which can be obtained by obtaining each video frame image in the odd-numbered image set, clearing the pixels in the odd-numbered cutout area of each video frame image, obtaining the cutout image, and then combining the obtained cutout images to obtain the odd-numbered cutout set. Similarly, the video frame images in the even-numbered image set are cut out according to the even-numbered cutout area to obtain the even-numbered cutout set, which is similar and will not be repeated here.
[0085] It should be noted that, after many tests, it can be determined that the smaller the preset cutout interval is, the better the compression effect on the video is, and the higher the corresponding video compression ratio is.
[0086] For ease of understanding, refer to Figure 4 and Figure 5 This is for illustration, but not for limitation. Figure 4 This is a schematic diagram of the division of odd-numbered cutout areas in this embodiment. Figure 5This is a schematic diagram of the division of the even cutout area in this embodiment, wherein the area filled with oblique lines is the cutout area, and the standard video frame image is divided into multiple square areas with a preset cutout interval as the side length, and each square area is used as a picture sub-area, thereby obtaining multiple picture sub-areas, and each picture sub-area is divided into odd cutout areas and even cutout areas, and the odd cutout areas are complementary to the even cutout areas.
[0087] Step S40: Encode the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video.
[0088] It should be noted that encoding the odd cutout set and the even cutout set to obtain a compressed video may be to obtain a preset encoding type, select a corresponding encoding method according to the preset encoding type to encode the odd cutout set and the even cutout set, thereby obtaining a compressed video. The preset encoding type may include simultaneous encoding and odd-even dual encoding, and the preset encoding type may be pre-set by an administrator of the terminal device.
[0089] This embodiment determines the corresponding video to be compressed according to the video compression instruction when a video compression instruction is detected, and splits the video to be compressed into multiple video frame pictures; sets picture numbers for the video frame pictures, and divides the video frame pictures into an odd picture set and an even picture set according to the picture numbers; performs complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set; and encodes the odd cutout set and the even cutout set to obtain a compressed video. Since the video frame pictures in the odd picture set and the even picture set obtained by splitting the video to be compressed are complementary cutouts, a large amount of information can be reduced, and therefore the compression ratio of the video can be further improved.
[0090] refer to Figure 6 , Figure 6 FIG. 4 is a flow chart of a second embodiment of a video compression method according to the present invention.
[0091] Based on the above first embodiment, a second embodiment of the video compression method of the present invention is proposed.
[0092] It should be noted that the preset coding types are divided into simultaneous coding and odd-even dual coding, and different preset coding types correspond to different coding methods. Therefore, the preset coding type can be obtained, and different coding methods can be selected according to the preset coding type to encode the odd cutout set and the even cutout set.
[0093] When the preset encoding type is simultaneous encoding, step S40 of the video compression method of this embodiment includes:
[0094] Step S401: combining the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers corresponding to the video frame pictures in the odd-numbered cutout set and the even-numbered cutout set to obtain a video cutout set.
[0095] It should be noted that if the preset encoding type is simultaneous encoding, it means that the manager only wants to perform complementary cutouts on the video frame images in the video, and no additional operations are performed during encoding. Therefore, when the preset encoding type is simultaneous encoding, the picture number corresponding to each video frame image in the odd cutout set and the even cutout set can be obtained, and then the video frame images in the odd cutout set and the even cutout set are added to an ordered set in order of the picture numbers, thereby obtaining a video cutout set.
[0096] Step S402: Encode the video cutout set according to a preset encoding method to obtain a compressed video.
[0097] It should be noted that the preset encoding method can be an encoding method such as H.264, H.265 or AVS (Audio Video Coding Standard), or other similar encoding methods, which are not limited in this embodiment. The preset encoding method can be pre-set by the administrator of the terminal device.
[0098] It should be noted that when the preset encoding method is simultaneous encoding, no additional operations are performed during encoding. Therefore, the compressed video can be directly decoded in a conventional manner to obtain a video frame picture set, and then the video is played according to the video frame picture set. However, since each video frame picture is cut out before compression, each video frame picture lacks some pixels, and the color of the picture will be much lighter when the video is played, which is manifested as a change in the brightness of the picture when viewed with the naked eye. In order to overcome the above defects, after obtaining the video cutout set, the video cutout set can also be converted into a video for playback, and the playback parameters are gradually adjusted. When the playback parameters are adjusted to make the playback effect of the converted video basically consistent with the playback effect of the video to be decompressed, the current playback parameters are used as the target playback parameters, and the target playback parameters are embedded in the video information of the compressed video. Then, when the subsequent decompression playback is performed, it can be played according to the recorded target playback parameters, which can avoid the phenomenon of lighter color of the picture. Among them, the playback parameters can include brightness, contrast, saturation and softness.
[0099] When the preset encoding type is odd-even dual encoding, step S40 of the video compression method of this embodiment includes:
[0100] Step S401 ′: split the video to be compressed into shots to obtain multiple shots.
[0101] It should be noted that if the preset encoding type is odd-even dual encoding, it means that the administrator hopes to use a special processing method during encoding to further improve the video compression rate. Therefore, at this time, the video to be compressed can be split into multiple screen shots.
[0102] In actual use, the shot splitting of the video to be compressed may be performed by detecting shot edge frames in the video to be compressed, and then splitting the compressed video into multiple screen shots according to the shot edge frames.
[0103] Step S402': determining the odd-numbered shots and the even-numbered shots corresponding to each picture shot according to the odd-numbered cutout set and the even-numbered cutout set.
[0104] It should be noted that a picture shot corresponds to a certain section of content in the video to be compressed, and has a starting time and an ending time. Therefore, the video frame image corresponding to each picture shot can be determined according to the starting time and ending time of each picture shot, and then the picture number of each video frame image can be obtained. According to the picture number, the odd-numbered cutout image corresponding to each picture shot can be found in the odd-numbered cutout set to obtain the odd-numbered shot. Similarly, according to the picture number, the even-numbered cutout image corresponding to each picture shot can be found in the even-numbered cutout set to obtain the even-numbered shot.
[0105] Step S403': encapsulate the odd-numbered shots and even-numbered shots corresponding to each picture shot into the same shot file, and obtain the shot file corresponding to each picture shot.
[0106] It should be noted that, since the cutout areas of the odd-numbered cutout pictures and the even-numbered cutout pictures are complementary, when encoding the pictures, if the odd-numbered cutout pictures and the even-numbered cutout pictures are encoded together, the compression ratio of the encoding compression is the lowest, which is equivalent to no compression. If the odd-numbered cutout pictures and the odd-numbered cutout pictures are encoded together or the even-numbered cutout pictures and the even-numbered cutout pictures are encoded together, since the effective areas of the images are consistent, there is a possibility of inter-frame compression, which can improve the compression ratio. Therefore, encapsulating the odd-numbered shots and the even-numbered shots corresponding to each screen lens into the same lens file can be to encode the odd-numbered shots corresponding to each screen lens respectively to obtain the odd-numbered lens file, then encode the corresponding even-numbered shots to obtain the even-numbered lens file, and then encapsulate the odd-numbered lens file and the even-numbered lens file into the same lens file, thereby obtaining the lens file corresponding to each screen lens. Among them, the encoding method for the odd-numbered shots or the even-numbered shots can be H.264, or it can be an encoding method such as H.265 or AVS, and this embodiment does not limit this.
[0107] It should be noted that, since the numbers of each video frame image can only be consecutive numbers during encoding, and the image numbers of each video frame image in odd-numbered shots or even-numbered shots are not consecutive, therefore, an odd-numbered coding number can be set starting from 1 for each video frame image in the odd-numbered cutout set, and an even-numbered coding number can be set starting from 1 for each video frame image in the even-numbered cutout set. When encoding the odd-numbered shots, encoding is performed according to the reset odd-numbered coding number, and when encoding the even-numbered shots, encoding is performed according to the reset even-numbered coding number.
[0108] Step S404': Combine the lens files corresponding to each frame lens to obtain a compressed video.
[0109] It is understandable that combining the lens files corresponding to the various screen shots to obtain the compressed video can be performed by splicing the corresponding lens files according to the playback sequence of the various screen shots to obtain the compressed video.
[0110] It should be noted that since it is impossible to determine whether the picture number of the first video frame image of each shot is odd or even after the shot is split, in order to facilitate the subsequent playback of compressed videos encoded in odd-even dual encoding methods, the picture numbers corresponding to each video frame image also need to be retained. The picture numbers corresponding to each video frame image can be encapsulated into the video information of the compressed video, or mounted on the compressed video in the form of a plug-in.
[0111] This embodiment obtains the preset encoding type set by the administrator of the terminal device, selects different methods to encode the odd-numbered cutout set and the even-numbered cutout set according to the preset encoding type, and obtains compressed video, which can meet the different compression requirements of the administrator and improve the versatility of the video compression method.
[0112] The embodiment of the present invention provides a video decompression method, referring to Figure 7 , Figure 7 The figure is a flow chart of a first embodiment of a video decompression method according to the present invention.
[0113] In this embodiment, the video decompression method includes the following steps:
[0114] Step S110: when a video decompression instruction is detected, obtaining a compressed video to be decompressed corresponding to the video decompression instruction.
[0115] It should be noted that the video decompression instruction can be an instruction generated by a user operating a terminal device when video decompression is required, or can be an instruction sent by a user to a terminal device through other devices. The video to be decompressed can be a video that needs to be decompressed and is transmitted to the terminal device in advance by a user, and the video to be decompressed can be a video compressed using the video compression method of the present invention.
[0116] Step S120: Decode the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set.
[0117] It should be noted that the compressed video to be decompressed is encoded according to the odd cutout set and the even cutout set. Therefore, the odd cutout set and the even cutout set can be obtained by decoding the compressed video to be decompressed in a reverse manner.
[0118] Step S130: Obtain the picture number corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set.
[0119] It is understandable that if the encoding type corresponding to the compressed video to be decompressed is simultaneous encoding, then the encoding is performed according to the picture number when encoding the odd-numbered cutout set and the even-numbered cutout set, and the picture number of each video frame picture can be directly obtained. If the encoding type corresponding to the compressed video to be decompressed is odd-even dual encoding, the picture number of each video frame picture may be encapsulated in the video information of the compressed video to be decompressed or mounted on the compressed video to be decompressed in an external manner, and can also be obtained in a corresponding manner.
[0120] Step S140: combining the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
[0121] It should be noted that, combining the odd-numbered cutout set and the even-numbered cutout set according to the picture number to obtain the video frame picture set corresponding to the compressed video to be decompressed can be accomplished by adding the video frame pictures in the technical cutout set and the even-numbered cutout set to a blank set in ascending order according to the corresponding picture numbers, thereby obtaining the video frame picture set corresponding to the compressed video to be decompressed.
[0122] It is understandable that after obtaining the video frame picture set corresponding to the compressed video to be decompressed, the video can be played according to the video frame picture set. Among them, if the video frame picture is a GOP, when playing the video according to the video frame picture set, if a B frame or P frame in the GOP is played, the part of the I frame in the GOP that is cut out will be subtracted in real time, and then presented after the subtraction is completed.
[0123] In actual use, if the encoding type corresponding to the compressed video to be decompressed is simultaneous encoding, after obtaining the video frame picture set corresponding to the compressed video to be decompressed, the target playback parameters can also be obtained from the video information of the compressed video to be decompressed. The video can be played according to the target playback parameters and the video frame picture set to avoid the phenomenon of lighter picture colors.
[0124] In actual use, if the encoding type corresponding to the compressed video to be decompressed is odd-even dual encoding, the video frames with odd and even image numbers can be played alternately, using the user's visual residual to allow the user to form a complete image by their own imagination. The higher the frame rate of the video, the easier it is for the user to complete the image based on the visual residual, and the higher the resolution of the video, the less likely the user will see the grainy points. Therefore, the higher the frame rate of the compressed video to be decompressed, the better the playback effect in this way.
[0125] It is understandable that when the encoding type corresponding to the compressed video to be decompressed is odd-even dual encoding, if the compressed video to be decompressed is large and inconvenient to load completely, then when playing the video, only one screen shot can be loaded at a time, and then the lens file of the screen shot is decoded to obtain the corresponding odd shots and even shots, and then the picture numbers corresponding to the video frame pictures in the odd shots and even shots are obtained, and the video frame pictures in the odd shots and even shots are played alternately according to the order of the picture numbers.
[0126] This embodiment obtains the compressed video to be decompressed corresponding to the video decompression instruction when a video decompression instruction is detected; decodes the compressed video to be decompressed to obtain an odd cutout set and an even cutout set; obtains the picture number corresponding to each video frame picture in the odd cutout set and the even cutout set; combines the odd cutout set and the even cutout set according to the picture number to obtain the video frame picture set corresponding to the compressed video to be decompressed. Since the odd cutout set and the even cutout set are combined according to the picture number at last to obtain the video frame picture set corresponding to the compressed video to be decompressed, the correct order is ensured when the video is subsequently played according to the video frame picture set, and the compressed video to be decompressed can be played normally.
[0127] refer to Figure 8 , Figure 8 The figure is a flow chart of a second embodiment of a video decompression method according to the present invention.
[0128] Based on the first embodiment, step S120 of the video decompression method of this embodiment includes:
[0129] Step S1201: Acquire multiple screen shots corresponding to the compressed video to be decompressed.
[0130] It should be noted that when compressing the video, the encoding types preset by the administrator are different, and the encoding methods for the odd-numbered cutout sets and the even-numbered cutout sets are also different. Therefore, when decompressing the compressed video to be decompressed, you can first obtain the encoding type set when compressing the compressed video to be decompressed, and select different decoding methods for decoding according to the encoding type.
[0131] It should be noted that if the encoding type corresponding to the compressed video to be decompressed is simultaneous encoding, the encoding method is a conventional encoding method, and the conventional decoding method can be used to directly decode the compressed video to be decompressed, thereby obtaining an odd-numbered cutout set and an even-numbered cutout set. However, if the encoding type corresponding to the compressed video to be decompressed is odd-even dual encoding, the encoding method is not a conventional encoding method, and the use of a conventional decoding method cannot guarantee successful decoding. A unique method must be used for decoding. At this time, multiple screen shots corresponding to the compressed video to be decompressed can be obtained first.
[0132] Step S1202: Obtaining the lens file corresponding to each screen lens;
[0133] It should be noted that if the encoding type of the compressed video to be decompressed is odd-even double encoding, the compressed video to be decompressed is obtained by combining the lens files corresponding to each picture lens. Therefore, the compressed video to be decompressed can also be split to obtain the lens files corresponding to each picture lens.
[0134] Step S1203: Decode the lens file to obtain odd-numbered lenses and even-numbered lenses corresponding to each picture lens;
[0135] It should be noted that the lens file corresponding to each picture lens encapsulates the odd-numbered lenses and even-numbered lenses corresponding to the picture lens, and the odd-numbered lenses and even-numbered lenses corresponding to each picture lens can be obtained by parsing the lens file.
[0136] Step S1204: determining an odd-numbered cutout set and an even-numbered cutout set according to the odd-numbered shots and the even-numbered shots corresponding to each picture shot.
[0137] In actual use, determining the odd cutout set and the even cutout set according to the odd and even shots corresponding to each picture shot can be by combining the video frame images in the odd shots corresponding to each picture shot to obtain the odd cutout set, and combining the video frame images in the even shots corresponding to each picture shot to obtain the even cutout set.
[0138] This embodiment also obtains the encoding type corresponding to the compressed video to be decompressed before decoding the compressed video to be decompressed, and decodes the compressed video to be decompressed in different ways according to the encoding type, thereby ensuring that the odd cutout set and the even cutout set can be obtained normally.
[0139] In addition, an embodiment of the present invention also proposes a storage medium, on which a video compression or video decompression program is stored. When the video compression program is executed by a processor, the steps of the video compression method described above are implemented; when the video decompression program is executed by a processor, the steps of the video decompression method described above are implemented.
[0140] Reference Fig. 9, Fig. 9 This is a structural block diagram of the first embodiment of the video compression device of the present invention.
[0141] like Fig. 9 As shown, the video compression device proposed in the embodiment of the present invention includes:
[0142] The instruction receiving module 10 is used to determine the corresponding video to be compressed according to the video compression instruction when a video compression instruction is detected, and split the video to be compressed into multiple video frame pictures;
[0143] A picture splitting module 20, configured to set picture numbers for the video frame pictures, and divide the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers;
[0144] A complementary cutout module 30 is used to perform complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set, wherein the complementary cutouts are the cutout regions corresponding to the odd picture set and the cutout regions corresponding to the even picture set complement each other;
[0145] The picture encoding module 40 is used to encode the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video.
[0146] This embodiment determines the corresponding video to be compressed according to the video compression instruction when a video compression instruction is detected, and splits the video to be compressed into multiple video frame pictures; sets picture numbers for the video frame pictures, and divides the video frame pictures into an odd picture set and an even picture set according to the picture numbers; performs complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set; and encodes the odd cutout set and the even cutout set to obtain a compressed video. Since the video frame pictures in the odd picture set and the even picture set obtained by splitting the video to be compressed are complementary cutouts, a large amount of information can be reduced, and therefore the compression ratio of the video can be further improved.
[0147] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0148] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0149] In addition, for technical details that are not described in detail in this embodiment, reference can be made to the video compression method provided in any embodiment of the present invention, and will not be repeated here.
[0150] Reference Fig.10 , Fig.10 It is a structural block diagram of the first embodiment of the video decompression device of the present invention.
[0151] like Fig.10 As shown, the video decompression device proposed in the embodiment of the present invention includes:
[0152] The instruction receiving module 100 is used to obtain the compressed video to be decompressed corresponding to the video decompression instruction when a video decompression instruction is detected;
[0153] The video decoding module 200 is used to decode the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set;
[0154] A number acquisition module 300 is used to acquire a picture number corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set;
[0155] The picture combination module 400 is used to combine the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
[0156] This embodiment obtains the compressed video to be decompressed corresponding to the video decompression instruction when the video decompression instruction is detected; decodes the compressed video to be decompressed to obtain an odd cutout set and an even cutout set; obtains the picture number corresponding to each video frame picture in the odd cutout set and the even cutout set; combines the odd cutout set and the even cutout set according to the picture number to obtain the video frame picture set corresponding to the compressed video to be decompressed. Since the odd cutout set and the even cutout set are combined according to the picture number at last to obtain the video frame picture set corresponding to the compressed video to be decompressed, the correct order is ensured when the video is subsequently played according to the video frame picture set, and the compressed video to be decompressed can be played normally. Moreover, before decoding the compressed video to be decompressed, the encoding type corresponding to the compressed video to be decompressed is also obtained, and different methods are used to decode the compressed video to be decompressed according to the encoding type, so as to ensure that the odd cutout set and the even cutout set can be obtained normally.
[0157] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0158] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0159] In addition, for technical details not fully described in this embodiment, reference can be made to the video decompression method provided in any embodiment of the present invention, and will not be repeated here.
[0160] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0161] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0163] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A video compression method, It is characterized in that The video compression method comprises the following steps: When a video compression instruction is detected, a corresponding video to be compressed is determined according to the video compression instruction, and the video to be compressed is split into a plurality of video frame images; Setting picture numbers for the video frame pictures, and dividing the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers; Complementarily matting the video frame pictures in the odd picture set and the even picture set to obtain an odd matting set and an even matting set, wherein the complementary matting is that the matting area corresponding to the odd picture set is complementary to the matting area corresponding to the even picture set, and pixels in the matting area are cleared during the matting process; The odd-numbered cutout set and the even-numbered cutout set are encoded to obtain a compressed video.
2. The video compression method according to claim 1, It is characterized in that The step of performing complementary cutouts on the video frame pictures in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set comprises: Obtain a standard video frame image, and divide the standard video frame image into regions according to a preset cutout interval to obtain a plurality of image sub-regions; Selecting odd-numbered cutout regions from the image sub-regions according to a preset region selection rule, and using the remaining image sub-regions as even-numbered cutout regions; The video frame pictures in the odd picture set are cut out according to the odd cutout area to obtain an odd cutout set, and the video frame pictures in the even picture set are cut out according to the even cutout area to obtain an even cutout set.
3. The video compression method according to any one of claims 1 to 2, It is characterized in that The step of encoding the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video comprises: Combining the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers corresponding to the video frame pictures in the odd-numbered cutout set and the even-numbered cutout set to obtain a video cutout set; The video cutout set is encoded to obtain a compressed video.
4. The video compression method according to any one of claims 1 to 2, It is characterized in that The step of encoding the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video comprises: Splitting the video to be compressed into shots to obtain multiple shots; Determine the odd-numbered shots and the even-numbered shots corresponding to each picture shot according to the odd-numbered cutout set and the even-numbered cutout set; Encapsulate the odd-numbered lenses and even-numbered lenses corresponding to each picture lens into the same lens file to obtain the lens file corresponding to each picture lens; Combine the lens files corresponding to each screen lens to obtain a compressed video.
5. A video decompression method, It is characterized in that The video decompression method comprises the following steps: When a video decompression instruction is detected, obtaining a compressed video to be decompressed corresponding to the video decompression instruction; Decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set, wherein the odd-numbered cutout set and the even-numbered cutout set are generated by performing complementary cutouts on video frame pictures, the cutout regions corresponding to the odd-numbered cutout set and the even-numbered cutout set are complementary, and pixels in the cutout regions are cleared during the cutout process; Obtaining picture numbers corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set; The odd-numbered cutout set and the even-numbered cutout set are combined according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
6. The video decompression method according to claim 5, It is characterized in that The step of decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set comprises: Acquire multiple screen shots corresponding to the compressed video to be decompressed; Get the lens file corresponding to each screen lens; Decoding the lens file to obtain odd-numbered lenses and even-numbered lenses corresponding to each picture lens; An odd-numbered cutout set and an even-numbered cutout set are determined according to the odd-numbered shots and the even-numbered shots corresponding to each picture lens.
7. A video compression device, It is characterized in that The video compression device comprises the following modules: An instruction receiving module is used to determine the corresponding video to be compressed according to the video compression instruction when a video compression instruction is detected, and split the video to be compressed into multiple video frame pictures; A picture splitting module, used to set picture numbers for the video frame pictures, and divide the video frame pictures into an odd-numbered picture set and an even-numbered picture set according to the picture numbers; A complementary cutout module is used to perform complementary cutouts on the video frame images in the odd picture set and the even picture set to obtain an odd cutout set and an even cutout set, wherein the complementary cutouts are the cutout regions corresponding to the odd picture set and the cutout regions corresponding to the even picture set complement each other, and pixels in the cutout regions are cleared during the cutout process; The picture encoding module is used to encode the odd-numbered cutout set and the even-numbered cutout set to obtain a compressed video.
8. A video decompression device, It is characterized in that The video decompression device comprises the following modules: An instruction receiving module, used for acquiring the compressed video to be decompressed corresponding to the video decompression instruction when a video decompression instruction is detected; A video decoding module, used for decoding the compressed video to be decompressed to obtain an odd-numbered cutout set and an even-numbered cutout set, wherein the odd-numbered cutout set and the even-numbered cutout set are generated by performing complementary cutouts on video frame pictures, the cutout regions corresponding to the odd-numbered cutout set and the even-numbered cutout set are complementary, and pixels in the cutout regions are cleared during the cutout process; A number acquisition module, used to obtain the picture number corresponding to each video frame picture in the odd-numbered cutout set and the even-numbered cutout set; The picture combination module is used to combine the odd-numbered cutout set and the even-numbered cutout set according to the picture numbers to obtain a video frame picture set corresponding to the compressed video to be decompressed.
9. A terminal device, It is characterized in that The terminal device includes: a processor, a memory, and a video compression program or a video decompression program stored in the memory and runnable on the processor. When the video compression program is executed by the processor, the steps of the video compression method according to any one of claims 1 to 4 are implemented. When the video decompression program is executed by the processor, the steps of the video decompression method according to claim 5 or 6 are implemented.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a video compression program or a video decompression program. When the video compression program is executed, the steps of the video compression method according to any one of claims 1 to 4 are implemented. When the video decompression program is executed, the steps of the video decompression method according to claim 5 or 6 are implemented.
