A method and system for video data compression

By performing instance segmentation and motion tracking on surveillance videos, target and background region models are constructed, enabling differentiated quantization parameter allocation for video content. This solves the problem of unreasonable bitrate allocation in existing technologies, achieving efficient video compression and reduced storage costs.

CN122120458APending Publication Date: 2026-05-29SHENZHEN FANGYUANBAO INFORMATION TECH SERVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN FANGYUANBAO INFORMATION TECH SERVICE CO LTD
Filing Date
2026-01-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing video compression technologies cannot identify and distinguish the semantic importance differences of video content, resulting in unreasonable bitrate allocation, wasted bits, and difficulty in balancing compression rate and fidelity of key information. They are unable to adapt to the business value and temporal redundancy characteristics of surveillance video scenarios.

Method used

By segmenting surveillance videos into instances, target foreground and background region models are constructed. Differentiated quantization parameters are allocated based on semantic importance level, static and dynamic attributes, and temporal redundancy identifiers. The pyramid optical flow algorithm is used for motion tracking, achieving high encoding quality for high-value target regions and deep compression for low-value background regions.

Benefits of technology

It achieves high-rate compression of surveillance videos, ensuring the availability of critical information and the reliability of AI secondary analysis, while reducing storage space and bandwidth pressure, thus solving the storage cost problem in the surveillance industry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122120458A_ABST
    Figure CN122120458A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of video data compression, and discloses a video data compression method and system, which comprises the following steps: decoding a to-be-compressed video file to obtain a YUV format frame sequence and metadata information; performing instance segmentation on the YUV format frame sequence to obtain a target foreground mask set and a background region mask, and constructing a target region model and a background region model; performing motion tracking on a target instance in the target region model to obtain a time domain redundancy degree identifier of the target instance and calculate a quantization parameter distribution diagram; performing re-encoding processing on the YUV format frame sequence based on the quantization parameter distribution diagram and keeping the metadata information consistent to obtain a compressed video file; and the application realizes high-multiplying compression of monitoring video, ensures the availability of key information for human eye backtracking and AI secondary analysis, effectively reduces storage space occupation and bandwidth transmission pressure, and solves the cost problem of long-term storage in the monitoring industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video data compression technology, and in particular to a video data compression method and system. Background Technology

[0002] With the widespread application of video surveillance systems and the advancement of high-definition construction, the amount of video data has exploded. The need for long-term retention of surveillance recordings has also increased from 30 days to 90 days or even 180 days, placing enormous storage pressure and operational cost burdens on data centers. Traditional video coding standards such as H.264 and H.265 use compression methods based on pixel-domain statistical features, applying a uniform or rate-controlled quantization parameter adjustment strategy to all regions of the video frame. This approach fails to identify and distinguish the semantic importance differences of video content.

[0003] In surveillance video scenarios, high-value target areas such as faces and license plates are treated the same as low-value background areas such as the sky and walls. This leads to an unreasonable bitrate allocation, wasting a large number of bits on encoding background areas that are not sensitive to human or machine vision, and making it difficult to strike a balance between compression rate and the fidelity of key information. Existing video compression technologies lack the ability to understand the semantic layer of video content and cannot adaptively optimize encoding based on the business value and temporal redundancy characteristics of the target. Summary of the Invention

[0004] This invention provides a video data compression method and system. This invention achieves high-ratio compression of surveillance videos, which not only ensures the availability of key information for human visual review and AI secondary analysis, but also effectively reduces storage space occupation and bandwidth transmission pressure, solving the long-standing cost problem of storage in the surveillance industry.

[0005] The first aspect of this invention provides a video data compression method, the video data compression method comprising: The video file to be compressed is decoded to obtain a YUV format frame sequence and metadata information; The YUV format frame sequence is segmented into instances to obtain a target foreground mask set and a background region mask. A target region model is constructed based on the target foreground mask set, and a background region model is constructed based on the background region mask. Motion tracking is performed on target instances in the target region model to obtain the temporal redundancy identifier of the target instances and calculate the quantization parameter distribution map; The YUV format frame sequence is re-encoded based on the quantization parameter distribution map while maintaining the consistency of the metadata information to obtain a compressed video file.

[0006] In conjunction with the first aspect, in a first implementation of the first aspect of the present invention, the step of decoding the video file to be compressed to obtain a YUV format frame sequence and metadata information includes: Read the encoding format identifier, resolution parameters, frame rate, GOP structure information and timestamp information from the container of the video file to be compressed, and store them as metadata information; The standard decoder is invoked to restore the compressed domain bitstream data of the video file to be compressed into pixel domain data, resulting in a YUV format frame sequence.

[0007] In conjunction with the first aspect, in a second implementation of the first aspect of the present invention, the step of segmenting the YUV format frame sequence to obtain a target foreground mask set and a background region mask, and constructing a target region model based on the target foreground mask set and a background region model based on the background region mask, includes: Extract a set of target candidate boxes containing human bodies, faces, vehicles, and license plates from the YUV format frame sequence; Each candidate box in the target candidate box set is classified and segmented at the pixel level to obtain a target foreground mask set, and non-target regions are masked to obtain a background region mask. Based on the target foreground mask set, the semantic importance level of the target is extracted and a target region model is constructed. Based on the background region mask, static and dynamic attribute identifiers are extracted and a background region model is constructed.

[0008] In conjunction with the first aspect, in a third implementation of the first aspect of the present invention, the step of extracting the semantic importance level of the target based on the target foreground mask set and constructing a target region model, and extracting static and dynamic attribute identifiers based on the background region mask and constructing a background region model, includes: Based on the target foreground mask set, the average brightness value, gradient magnitude and texture complexity of each target instance are extracted. According to the target category, faces and license plates are marked as first-level importance, human bodies and vehicles are marked as second-level importance, and other targets are marked as third-level importance, thus constructing a target region model that includes semantic importance levels. The frame difference between the current frame and the previous frame is calculated based on the background region mask, and a background region model is constructed based on the frame difference.

[0009] In conjunction with the first aspect, in a fourth implementation of the first aspect of the present invention, the step of calculating the frame difference of the background region between the current frame and the previous frame based on the background region mask, and constructing a background region model based on the frame difference, includes: Based on the background region mask, extract the frame difference of the background region in the current frame and the previous frame; The frame difference is compared with a preset threshold. Pixels with a frame difference less than the preset threshold are marked as static background pixels, and pixels with a frame difference greater than or equal to the preset threshold are marked as dynamic background pixels. Background modeling is performed on the background regions marked as static background pixels to obtain static background model parameters. Temporal change features are extracted from the background regions marked as dynamic background pixels to obtain dynamic background change features. A background region model containing static background model parameters, dynamic background change features, and static and dynamic attribute identifiers is constructed.

[0010] In conjunction with the first aspect, in a fifth implementation of the first aspect of the present invention, the step of performing motion tracking on the target instance in the target region model to obtain the temporal redundancy identifier of the target instance and calculate the quantization parameter distribution map includes: Extract each target instance from the target region model, and calculate the overall motion vector of the target instance layer by layer from coarse to fine; The motion amplitude of the target instance is calculated based on the overall motion vector, and the pixel similarity of the target instance in consecutive frames is calculated. When the motion amplitude is less than the motion threshold and the pixel similarity is greater than the similarity threshold, it is marked as high temporal redundancy, and the temporal redundancy identifier of the target instance is obtained. The quantization parameter distribution map is calculated based on the semantic importance level, the static and dynamic attribute identifiers, and the temporal redundancy identifier.

[0011] In conjunction with the first aspect, in the sixth implementation of the first aspect of the present invention, the step of extracting each target instance in the target region model and calculating the overall motion vector of the target instance layer by layer from coarse to fine includes: A multi-layer image pyramid is constructed based on the image region covered by the target instance, and pixel positions with corner response values ​​greater than corner thresholds are selected as feature points within the image region of the target instance. Starting from the coarsest level of the multi-layer image pyramid, the optical flow increment between the current frame and the next frame is calculated for each feature point, and the optical flow calculation results are propagated to the fine level layer by layer to obtain the optical flow vector of each feature point at the original resolution. The optical flow vectors of all feature points of the target instance are subjected to median filtering to obtain the overall motion vector of the target instance.

[0012] In conjunction with the first aspect, in the seventh implementation of the first aspect of the present invention, the step of calculating the quantization parameter distribution map of each frame of the image based on the semantic importance level, the static and dynamic attribute identifiers, and the temporal redundancy identifier includes: Obtain the baseline quantization parameters of the video file to be compressed, and assign a first quantization parameter equal to the baseline quantization parameter to the first-level importance target region according to the semantic importance level, assign a second quantization parameter equal to the baseline quantization parameter plus E to the second-level importance target region, and assign a third quantization parameter equal to the baseline quantization parameter plus G to the third-level importance target region; Based on the static and dynamic attribute identifiers and the texture complexity of the background region, a fourth quantization parameter of the baseline quantization parameter plus F is assigned to the low-texture region of the static background; a fifth quantization parameter of the baseline quantization parameter plus H is assigned to the high-texture region of the static background; and a sixth quantization parameter of the baseline quantization parameter plus M is assigned to the dynamic background region. Based on the temporal redundancy identifier, a P-frame predictive coding mode is set for high temporal redundancy target instances, and a B-frame bidirectional predictive coding mode is set for motion predictable target instances. The quantization parameters corresponding to each pixel position are organized into a quantization parameter distribution map.

[0013] In conjunction with the first aspect, in the eighth implementation of the first aspect of the present invention, the step of recoding the YUV format frame sequence based on the quantization parameter distribution map while maintaining the consistency of the metadata information to obtain a compressed video file includes: The standard encoder is invoked to dynamically set the quantization parameters for each macroblock according to the quantization parameter distribution map, and the YUV format frame sequence is encoded to obtain compressed domain bitstream data; The compressed domain bitstream data is encapsulated into a container format identical to the video file to be compressed, and the resolution parameters, frame rate, encoding format identifier, and timestamp information from the metadata information are written into the video file header. The audio bitstream is extracted from the video file to be compressed and written using a pass-through copy mode to obtain a compressed video file that maintains audio-video synchronization.

[0014] A second aspect of the present invention provides a video data compression system, the video data compression system comprising: The decoding module is used to decode the video file to be compressed, and obtain the YUV format frame sequence and metadata information; The construction module is used to perform instance segmentation on the YUV format frame sequence to obtain a target foreground mask set and a background region mask, and to construct a target region model based on the target foreground mask set and a background region model based on the background region mask. The motion tracking module is used to perform motion tracking on target instances in the target region model, obtain the temporal redundancy identifier of the target instance, and calculate the quantization parameter distribution map. The re-encoding module is used to re-encode the YUV format frame sequence based on the quantization parameter distribution map while maintaining the consistency of the metadata information, thereby obtaining a compressed video file.

[0015] Compared with existing technologies, this invention achieves deep analysis of video content from the pixel domain to the semantic layer, accurately identifying high-value target areas and low-value background areas in surveillance scenes, and automatically marking semantic importance levels according to target categories, providing a decision-making basis for differentiated coding. By employing the pyramid optical flow algorithm to track the motion of target instances, this invention quantifies the temporal redundancy characteristics and motion predictability of targets, and can identify highly redundant targets that are stationary or moving slowly, as well as predictable targets that are moving in uniform linear motion, providing accurate motion compensation information for the formulation of inter-frame predictive coding strategies. Based on semantic importance levels, static and dynamic attribute identifiers, and temporal redundancy identifiers, this invention establishes a mapping mechanism from the semantic layer to the coding layer, realizing pixel-level differentiated quantization parameter allocation, maintaining the original coding quality for key target areas such as faces and license plates, significantly increasing the quantization step size to achieve deep compression for low-texture static background areas, and using a P-frame predictive coding mode to reduce bit consumption for targets with high temporal redundancy, thereby intelligently reallocating bitrate resources to areas with high business value. This invention achieves high-ratio compression of surveillance videos while maintaining the standard H.264 or H.265 encoding format, resolution, frame rate, and metadata integrity. This ensures the availability of key information for human visual review and AI secondary analysis, while effectively reducing storage space occupation and bandwidth transmission pressure, thus solving the long-standing cost problem of storage in the surveillance industry. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] The structures, proportions, sizes, etc., shown in the accompanying drawings of this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed in the specification, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.

[0018] Figure 1 This is a flowchart illustrating the video data compression method provided in an embodiment of the present invention; Figure 2This is a comparison chart of the timing changes in bitrate of 24-hour monitoring video provided in this embodiment of the invention; Figure 3 This is a comparison chart of video compression ratios under different monitoring scenarios provided in this embodiment of the invention; Figure 4 This is a schematic diagram of a regional hierarchical decision tree for calculating differentiated quantification parameters provided in an embodiment of the present invention; Figure 5 This is a comparison diagram of the bitrate allocation between the conventional scheme and the scheme of the present invention provided in the embodiments of the present invention; Figure 6 This is a schematic diagram of feature point displacement calculation based on optical flow algorithm provided in an embodiment of the present invention; Figure 7 This is a schematic block diagram of the video data compression system provided in an embodiment of the present invention. Detailed Implementation

[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0022] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items, and all possible combinations, and includes such combinations. See also Figure 1 One embodiment of the video data compression method in this invention includes: Step 100: Decode the video file to be compressed to obtain the YUV format frame sequence and metadata information; Step 200: Perform instance segmentation on the YUV format frame sequence to obtain a target foreground mask set and a background region mask, and construct a target region model based on the target foreground mask set and a background region model based on the background region mask; Step 300: Perform motion tracking on the target instances in the target region model to obtain the temporal redundancy identifier of the target instances and calculate the quantization parameter distribution map; Step 400: Based on the quantization parameter distribution map, the YUV format frame sequence is re-encoded while maintaining the consistency of metadata information to obtain a compressed video file.

[0023] Figure 2 This is a time-series comparison chart of bitrate changes in 24-hour surveillance video, showing the bitrate variation patterns of traffic intersection surveillance cameras throughout the day. The horizontal axis represents the time axis (00:00-24:00), and the vertical axis represents the instantaneous bitrate (Kbps). The solid line represents the bitrate fluctuation curve of the original H.264 encoded video. In static scenes at night (00:00-06:00), the bitrate remains at a low level of 200-400 kbps. During the morning rush hour (07:00-10:00), the bitrate rises sharply to 1200-1500 kbps due to the surge in traffic and pedestrian flow. During the daytime (10:00-17:00), it fluctuates in the range of 1000-1300 kbps. It rises again during the evening rush hour (18:00-20:00) and gradually declines at night (20:00-24:00). The dashed line represents the bitrate curve after differential quantization compression based on optical flow motion tracking and target-background dual modeling according to the present invention. By intelligently identifying high-value targets (faces, license plates) and deeply compressing low-value background areas, the compressed bitrate runs stably in the range of 100-350 kbps, achieving an average compression ratio of 9.82 times throughout the day.

[0024] Figure 3 This chart compares the compression ratios of the present invention and traditional H.265 encoding in different monitoring scenarios. It includes the actual compression ratio of the present invention and the compression ratio of the traditional H.265 encoding scheme. The horizontal axis, from left to right, represents the following scenarios: nighttime static scene, daytime peak traffic scene, indoor corridor scene, outdoor plaza scene, highway scene, and parking lot scene. The vertical axis represents the compression ratio, ranging from 0 to 55 times. In the nighttime static scene, the present invention achieves a compression ratio of 51.5 times, while the traditional scheme only achieves 2.5 times. In the daytime peak traffic scene, the present invention achieves 5.1 times, while the traditional scheme achieves 2.8 times. In the indoor corridor scene, the present invention achieves 20.0 times, while the traditional scheme achieves 2.5 times. In the outdoor plaza scene, the present invention achieves 6.0 times, while the traditional scheme achieves 2.8 times. In the highway scene, the present invention achieves 7.8 times, while the traditional scheme achieves 2.8 times. In the parking lot scene, the present invention achieves 30.0 times, while the traditional scheme achieves 2.5 times.

[0025] In one specific embodiment, the video file to be compressed is decoded to obtain a YUV format frame sequence and metadata information, including: Read the encoding format identifier, resolution parameters, frame rate, GOP structure information and timestamp information from the container of the video file to be compressed, and store them as metadata information; The standard decoder is called to restore the compressed domain bitstream data of the video file to pixel domain data, resulting in a YUV format frame sequence.

[0026] Specifically, the original video file is parsed using FFmpeg, GStreamer, or other demultiplexers conforming to multimedia container standards such as ISO / IEC 14496-12. During parsing, the encoding format identifier corresponding to the video stream, such as H.264 or H.265, is extracted by reading the header information in the container. The width and height parameters contained in the video stream are read as resolution information, and the frames per second (frame rate) are parsed. The arrangement structure between I-frames, P-frames, and B-frames in the video is obtained to determine the GOP (Group of Pictures) structure information. Simultaneously, the presentation timestamp (PTS) and decoding timestamp (DTS) are extracted as the basic data for timeline control. All these parameters are uniformly written to the metadata buffer and formatted as structured metadata objects. Based on the identified encoding format, the corresponding standard video decoder module is called; for example, H.264 video streams call the x264 decoder, and H.265 streams call the x265 decoder, initiating the full-frame decoding process. During decoding, the compressed bitstream is unpacked into raw coding units (NALUs) in chronological order. Then, it enters the entropy decoding stage, where dequantization and inverse transform operations are performed at the macroblock or CU level to complete motion compensation and inter-frame prediction reconstruction. After loop filtering and other processing, the pixel data of the original image frame is reconstructed. Since the video coding standard uses the YUV420 color space, the decoded image frame consists of three parts: the Y luminance component, the U chrominance component, and the V chrominance component. The Y component size of each frame is consistent with the original image resolution, while the U and V components are half of it, forming the standard YUV420 frame format. The continuously decoded frame data is stored in the frame buffer in presentation order, and each frame is marked with a corresponding PTS and frame number. Line-major order and uncompressed format are used when storing YUV frame data.

[0027] In one specific embodiment, the YUV format frame sequence is segmented into instances to obtain a target foreground mask set and a background region mask. A target region model is constructed based on the target foreground mask set, and a background region model is constructed based on the background region mask, including: Extract a set of target candidate bounding boxes containing human bodies, faces, vehicles, and license plates from a YUV format frame sequence; Each candidate box in the target candidate box set is classified and segmented at the pixel level to obtain the target foreground mask set, and non-target regions are masked to obtain the background region mask. The target semantic importance level is extracted based on the target foreground mask set and a target region model is constructed. Static and dynamic attribute identifiers are extracted based on the background region mask and a background region model is constructed.

[0028] Specifically, the YUV format frame image is converted into an RGB format image suitable for deep learning model processing. The conversion formula from YUV420 to RGB is used for pixel-by-pixel transformation, where R=Y+1.402×(V-128), G=Y-0.344×(U-128)-0.714×(V-128), and B=Y+1.772×(U-128). The converted RGB image is used as the input data for the convolutional neural network model. A pre-trained instance segmentation model, such as a deep convolutional neural network based on the Mask R-CNN architecture, is loaded. Each frame of RGB image is sequentially input into the model for processing. A backbone feature extraction network extracts multi-scale spatial feature maps of the image, and a region proposal network generates multiple candidate bounding boxes. The RoIAlign module then performs spatial alignment and fixed-scale mapping on each candidate box. A classification branch identifies the target category, and a segmentation branch outputs the corresponding pixel-level mask. This generates a set of target candidate bounding boxes in each frame, including human bodies, faces, vehicles, and license plates. Each candidate box is accompanied by a classification label, confidence score, and a binary mask of the corresponding resolution. A target foreground mask set is directly constructed based on the mask set. The binary mask of each target is projected and its resolution restored to form a pixel-level segmented image of the same size as the original image. Pixels with a mask value of 1 are considered target foreground pixels, while pixels with a mask value of 0 belong to non-target regions. All target foreground masks are subjected to a pixel-level logical OR operation within the frame to obtain the target foreground mask map. Simultaneously, the background region mask map is obtained by taking the logical NOT of the target foreground masks. For each target instance, semantic type is extracted based on its classification label, and a semantic importance ranking model is constructed by combining image features of the masked area (including average brightness, texture complexity, boundary gradient, etc.). According to priority rules, faces and license plates are labeled as level 1 importance, human bodies and vehicles as level 2, and other detected secondary targets as level 3. A feature vector is generated for each target, containing parameters such as area, aspect ratio, texture entropy, and brightness standard deviation, thus constructing a target region model. Simultaneously, the background region is analyzed using the pixel set defined by the background region mask. The pixel difference between the current frame and the previous frame in the background mask region is calculated. If the pixel difference is less than a set threshold, it is marked as a static background pixel; otherwise, it is marked as a dynamic background pixel. A static / dynamic distribution map is then constructed in the entire frame image. Combined with local texture statistical features, such as local binary mode entropy, the texture complexity of the background region is determined, establishing a background region modeling structure that includes both static / dynamic attributes and texture intensity.

[0029] In one specific embodiment, the process of extracting the semantic importance level of the target based on the target foreground mask set and constructing a target region model, and extracting static and dynamic attribute identifiers based on the background region mask and constructing a background region model, includes: Based on the target foreground mask set, the average brightness value, gradient magnitude and texture complexity of each target instance are extracted. According to the target category, faces and license plates are marked as first-level importance, human bodies and vehicles are marked as second-level importance, and other targets are marked as third-level importance. A target region model containing semantic importance level is constructed. The frame difference between the current frame and the previous frame is calculated based on the background region mask, and a background region model is constructed based on the frame difference.

[0030] Specifically, based on the target foreground mask set output by Mask R-CNN or other pixel-level instance segmentation models in each frame, a set of pixel coordinates is extracted for the mask region of each target instance. The corresponding Y component pixel values ​​are extracted from the YUV format image, and their average brightness value is calculated as the target's brightness feature. The Sobel operator is used to calculate the image gradient within the mask region, and the horizontal gradient G is obtained. x and vertical gradient G y And from this, the gradient magnitude map G = √(G x 2 +G y 2 The average gradient magnitude of all pixels within the mask area is used as an indicator of the target's edge sharpness. A local binary pattern operator is applied to the brightness image within each mask area to extract the binary pattern between each pixel's 8-neighborhood and the center pixel, and its frequency distribution is statistically analyzed. The entropy value of this frequency distribution is calculated as an indicator of texture complexity; a higher entropy value indicates a more complex texture, while a lower entropy value indicates a flatter region. These three dimensions of feature data are combined with spatial parameters such as the target region's area and aspect ratio to form a target region feature vector containing attributes such as brightness, gradient, texture, and shape. Combined with semantic classification results, instances of faces and license plates are labeled as first-level importance, human bodies and vehicles as second-level importance, and other target types such as packages, bicycles, and pets as third-level importance, constructing a target region model with semantic importance levels. Simultaneously, the background region mask map of the current frame is obtained using the logical NOT result of the target foreground mask set, and the background pixel set P is determined using this mask map. b In the time series dimension, the background region of the current frame is compared with the corresponding background region of the previous frame using a pixel-by-pixel difference calculation, and the frame difference map ΔI(x,y)=|I t (x,y)-I t-1 (x,y)|, where I t (x,y) represents the grayscale value of the background pixel in the current frame, I t-1(x,y) represents the grayscale value at the corresponding position in the previous frame. A frame difference threshold is set, for example, to 10 pixels. If ΔI(x,y) < the frame difference threshold, it is determined to be a static background pixel; otherwise, it is a dynamic background pixel. The ratio of static to dynamic pixels in the entire background mask area is calculated. Combined with the standard deviation and frequency of local frame difference changes, the stability and disturbance intensity of the background region are described, and a background region modeling vector containing static and dynamic markers, change amplitude, and disturbance frequency is constructed.

[0031] In one specific embodiment, the frame difference of the background region between the current frame and the previous frame is calculated based on the background region mask, and a background region model is constructed based on the frame difference, including: Extract the frame difference between the background regions in the current frame and the previous frame based on the background region mask; The frame difference is compared with a preset threshold. Pixels with a frame difference less than the preset threshold are marked as static background pixels, and pixels with a frame difference greater than or equal to the preset threshold are marked as dynamic background pixels. Background modeling is performed on the background regions marked as static background pixels to obtain static background model parameters. Temporal change features are extracted from the background regions marked as dynamic background pixels to obtain dynamic background change features. A background region model containing static background model parameters, dynamic background change features, and static and dynamic attribute identifiers is constructed.

[0032] Specifically, a set of pixels representing the background region is obtained from two consecutive image frames. This set is used to form a background mask image by taking the logical NOT of the result of a logical OR operation on all target foreground masks in each frame. Pure background pixel regions that are not masked by any semantic target in the current frame and the previous frame are then selected. Within the extracted background pixel regions, the frame difference ΔI(x,y)=|Y_n / x_n / y ... t (x,y)-Y t-1 The (x,y)| difference map reflects the brightness change of background pixels over time. The frame difference of each pixel is compared pixel-by-pixel with a set threshold. If the frame difference is less than the threshold, the pixel is considered to be in a stable state over time and is marked as a static background pixel. If the frame difference is greater than or equal to the threshold, the pixel is considered to have significant changes in brightness or texture and is marked as a dynamic background pixel. A static background modeling mechanism is constructed for static background pixels, based on a Gaussian mixture model. For each static background pixel, a Gaussian distribution set containing K=5 components is established, where each Gaussian component has a mean μ. k Covariance Σ k and mixed weight ω kThe model uses a recursive EM algorithm to continuously update these parameters, allowing it to consistently fit the stable temporal distribution characteristics of pixels. The principal component parameter set for each pixel is used as the static background model parameters. For pixel regions identified as dynamic background, the amplitude and frequency of their changes are extracted from a time-series perspective. The amplitude is statistically analyzed using the maximum range and standard deviation of the frame difference, while the frequency is calculated by the number of times the frame difference exceeds a threshold per unit time. These features are used to construct a dynamic background change feature description vector, including indicators such as average amplitude, frequency, and inter-frame jitter. The static and dynamic identifiers of each pixel, along with its GMM model parameters for static backgrounds and its change feature values ​​for dynamic backgrounds, are combined to form a pixel-level background region model, enabling the modeling of the static and dynamic behavior of the entire frame's background region.

[0033] In one specific embodiment, motion tracking is performed on target instances in the target region model to obtain the temporal redundancy identifier of the target instances and calculate the quantization parameter distribution map, including: Extract each target instance from the target region model, and calculate the overall motion vector of the target instance layer by layer from coarse to fine; The motion amplitude of the target instance is calculated based on the overall motion vector. The pixel similarity of the target instance in consecutive frames is calculated. When the motion amplitude is less than the motion threshold and the pixel similarity is greater than the similarity threshold, it is marked as high temporal redundancy, and the temporal redundancy identifier of the target instance is obtained. The distribution map of quantization parameters is calculated based on semantic importance level, static and dynamic attribute identifiers, and temporal redundancy identifiers.

[0034] Specifically, the mask coordinates, category label, and spatial bounding box information of each target instance are obtained from the target region model. Using the target mask coverage area as a reference, optical flow tracing is performed in the current frame and the previous frame. To ensure the stability of optical flow estimation at different resolutions, the Lucas-Kanade pyramid optical flow algorithm is used. Starting from the coarsest level, the optical flow field estimation results are iteratively propagated to finer image levels. Pixels with high corner response values ​​within the target mask region are selected as tracking keypoints in each image layer. The optical flow displacement of these keypoints in adjacent frames is calculated. The objective function is optimized using the minimum squared error of a local window in each image layer to estimate the sub-pixel precision displacement vector of each keypoint. All optical flow vectors are aggregated in the original resolution image, and the median value is calculated as the overall motion vector of the target, thereby suppressing interference from individual outliers. Based on the overall motion vector, the motion amplitude of the target instance in the time dimension is calculated, defined as the magnitude M = √(u) of the two-dimensional optical flow vector. 2 +v 2A motion threshold is set, for example, 2 pixels. If the motion amplitude of the target between two consecutive frames is less than the motion threshold, it indicates that the target is in a stationary or slow-moving state. The image region covered by the target mask is extracted from the current frame and the previous frame, and the structural similarity index (SSIM) is calculated for this region. If the SSIM value is higher than the set similarity threshold, for example, 0.95, the target is considered to have high temporal redundancy and is therefore marked as a high temporal redundancy state. This state identifier is written into the target model as a reference for the encoding strategy. Targets that do not meet the redundancy condition are marked as non-redundant targets. Based on the semantic importance level (level 1, 2, or 3), the static and dynamic attribute identifiers of the background region (static or dynamic), and the temporal redundancy identifier (high redundancy or non-redundancy) of each target instance, a quantization parameter configuration logic for controlling encoding quality is established, and a full-frame pixel-level quantization parameter distribution map (QP) is constructed accordingly. map (x, y). For primary semantic targets such as faces and license plates, a medium QP value is assigned if the target is in a high-redundancy state to balance bitrate control and restoration effect; if the target is in a non-redundant state, the original base QP value is assigned to maintain accuracy. For secondary targets such as human bodies and vehicles, the quantization intensity is set to base QP value +3 or base QP value +5 depending on the redundancy state. For tertiary targets, higher quantization base QP values ​​of +6 to +8 are used. For background regions, the quantization intensity is differentiated according to static or dynamic states. In static backgrounds, regions with low texture complexity are directly set to base QP value +15, regions with high texture complexity use base QP value +10, and dynamic backgrounds are uniformly set to base QP value +8. All pixels are assigned corresponding quantization parameter values ​​from the above rules according to their mask classification, static / dynamic attributes, and temporal characteristics, and the QP values ​​are filled into a two-dimensional array with the same dimensions as the image to form a quantization parameter distribution map.

[0035] Before organizing the quantization parameters corresponding to each pixel position into a quantization parameter distribution map, the process also includes smoothing the quantization parameters that cross different region boundaries: detecting the difference in quantization parameters between adjacent pixel positions in the quantization parameter distribution map, marking the quantization parameter abrupt boundary when the difference in quantization parameters is greater than a smoothing threshold, and extracting the pixel positions within a preset width range on both sides of the abrupt boundary as transition regions; for each pixel position in the transition region, calculating a weight coefficient based on the distance from the pixel to the boundary contour of the target region, and using a Gaussian weighting function to perform a weighted average of the quantization parameters on both sides of the abrupt boundary to obtain the smoothed quantization parameter values ​​for each pixel position in the transition region; replacing the original quantization parameter values ​​in the transition region with the smoothed quantization parameter values ​​to obtain a smoothed quantization parameter distribution map that eliminates abrupt boundaries, thus avoiding block artifacts caused by quantization parameter abrupt changes at macroblock boundaries.

[0036] After calculating the distribution map of quantized parameters based on semantic importance level, static and dynamic attribute identifiers, and temporal redundancy identifiers, the process also includes dynamically adjusting the GOP structure based on scene change detection: calculating the inter-frame histogram correlation coefficient for a continuous frame sequence; when the histogram correlation coefficient is less than the scene switching threshold, it is determined to be a scene switching position, and an I-frame is forcibly inserted at the scene switching position as the starting frame of the new GOP; calculating the proportion of target instances marked as high temporal redundancy within the current GOP; when the proportion is greater than the redundancy proportion threshold, the current scene is determined to be a static scene, and the length of the current GOP is extended from the standard GOP length to the extended GOP length to reduce the I-frame insertion frequency; calculating the average motion amplitude of target instances within the current GOP; when the average motion amplitude is greater than the motion amplitude threshold, the current scene is determined to be a high-dynamic scene, and the length of the current GOP is shortened from the standard GOP length to the shortened GOP length to improve prediction accuracy, thus obtaining the adaptively adjusted GOP structure parameters.

[0037] Figure 4 A decision tree structure for calculating differential quantization parameters based on region type is used. The root node represents the input region type, and the first-level branches divide video frames into two main categories: target regions and background regions. Target regions are further subdivided into three levels of importance: Level 1 importance (faces / license plates), Level 2 importance (human bodies / vehicles), and Level 3 importance (other objects), each corresponding to different quantization parameter settings. Background regions are subdivided into three categories based on static / dynamic attributes and texture complexity: static low-texture (sky / walls), static high-texture (vegetation / ground), and dynamic background (moving areas), implementing an intelligent quantization strategy based on semantic importance.

[0038] Figure 5 By comparing the differences in bitrate allocation strategies between traditional encoding schemes and the scheme of this invention, we can see that traditional schemes use uniform quantization parameters, distributing the bitrate evenly across regions, with each sector accounting for 25%. The scheme of this invention, on the right, implements differentiated bitrate allocation based on semantic importance: 45% bitrate is allocated to Level 1 importance regions (faces, license plates) to ensure lossless access to key information; 25% is allocated to Level 2 importance regions; 15% to Level 3 importance regions; and only 15% to background regions. Through intelligent bitrate redistribution, the overall bitrate requirement is significantly reduced while maintaining high quality for important targets.

[0039] In one specific embodiment, each target instance in the target region model is extracted, and the overall motion vector of the target instance is calculated layer by layer from coarse to fine, including: A multi-layer image pyramid is constructed based on the image region covered by the target instance. Within the image region of the target instance, pixel locations with corner response values ​​greater than corner thresholds are selected as feature points. Starting from the coarsest level of the multi-layer image pyramid, the optical flow increment between the current frame and the next frame is calculated for each feature point, and the optical flow calculation results are propagated to the fine level layer by layer to obtain the optical flow vector of each feature point at the original resolution. Median filtering is applied to the optical flow vectors of all feature points of the target instance to obtain the overall motion vector of the target instance.

[0040] Specifically, spatial extraction is performed on the image region covered by the target mask, and the corresponding Y-channel brightness image of this region is cropped out as the basic input for pyramid construction. Multi-layer image pyramids are constructed using image downsampling operations, with each layer downsampling the previous layer's image by a scaling factor of 0.5, until the set coarsest level is reached, such as the Lth layer image having a resolution of 1 / 8 or 1 / 16 of the original. Image patches of the target region are retained in each pyramid layer for optical flow matching. In the original resolution image layer, i.e., the bottom layer of the pyramid, corner detection is performed within the target mask region based on the Shi-Tomasi corner detection algorithm. This is done by calculating the minimum eigenvalue of the autocorrelation matrix of each pixel within its local window, and filtering out pixel positions with corner response values ​​greater than a set corner threshold (e.g., 0.01) as the initial set of feature points for the target. In the optical flow calculation stage, the Lucas-Kanade pyramid algorithm is used for layer-by-layer estimation. Starting from the coarsest level of the pyramid, a fixed-size search window (e.g., 15×15 pixels) is established centered on each feature point within each target image region. The objective function that minimizes the brightness difference between the corresponding windows in the current frame and the next frame is calculated, and the optimal displacement vector is solved using a linearized Gauss-Newton iterative method to obtain the initial optical flow increment. The optical flow result is used as the initial estimate and propagated upwards to higher resolution image layers. In each layer, the displacement result is refined and corrected, and the matching accuracy is improved through optical flow compensation iteration. At the bottom layer of the pyramid, the original image resolution is restored, and the sub-pixel level optical flow vector of each feature point between two consecutive frames is obtained. After obtaining the optical flow vectors of all feature points, due to estimation errors caused by occlusion, blurring, or local texture discontinuities in real-world scenes, median filtering is performed on the optical flow vectors. This involves calculating the median value of the horizontal and vertical components to eliminate the influence of outliers. The obtained median optical flow vector is used as the overall motion vector of the target instance between the current frame and the next frame.

[0041] Figure 6This describes the displacement calculation process of feature points between consecutive frames in the Lucas-Kanade optical flow algorithm for the pyramids. The video frame at time t is labeled with a 15×15 pixel search window centered on the Shi-Tomasi corner within the target area. The video frame at time t+1 represents the search area. By calculating the grayscale changes and gradient information of the pixels within the window, the optical flow vector v=(u,v) is solved, representing the motion trajectory of the feature points from time t to time t+1. This trajectory is used to quantify the target's motion amplitude and temporal redundancy characteristics.

[0042] After obtaining the overall motion vector by median filtering of the optical flow vectors of all feature points of the target instance, the process also includes tracking and maintaining occluded targets: calculating the bounding box overlap between each target instance in the current frame and each target instance in the previous frame; when the overlap is greater than the overlap threshold, establishing a matching association between target instances in the previous and next frames and inheriting the instance identifier of the previous frame; when the overlap is less than or equal to the overlap threshold, marking it as a newly appearing target or a disappeared target; for instances marked as disappeared targets, calculating the spatial distance and scale ratio between the instance and other target instances in the current frame; when there is a foreground target with a distance less than the occlusion distance threshold and a scale ratio greater than the occlusion scale threshold, it is determined that occlusion has occurred, and the temporal redundancy identifier and motion vector information of the disappeared target are temporarily stored in the occlusion buffer queue; monitoring the reappearance of target instances in subsequent frames, predicting the possible appearance location of the occluded target based on the motion vectors in the occlusion buffer queue; when a target instance with a matching location and an appearance feature similarity greater than the appearance threshold is detected, restoring the identifier and temporal redundancy identifier of the instance, maintaining the continuity of target tracking and avoiding encoding mode switching caused by occlusion.

[0043] In one specific embodiment, the quantization parameter distribution map of each frame of the image is calculated based on semantic importance level, static and dynamic attribute identifiers, and temporal redundancy identifiers, including: Obtain the baseline quantization parameters of the video file to be compressed. Based on the semantic importance level, assign a first quantization parameter equal to the baseline quantization parameter to the first-level importance target region, assign a second quantization parameter equal to the baseline quantization parameter plus E to the second-level importance target region, and assign a third quantization parameter equal to the baseline quantization parameter plus G to the third-level importance target region. Based on the static and dynamic attribute identifiers and the texture complexity of the background region, a fourth quantization parameter of the baseline quantization parameter plus F is assigned to the low texture region of the static background; a fifth quantization parameter of the baseline quantization parameter plus H is assigned to the high texture region of the static background; and a sixth quantization parameter of the baseline quantization parameter plus M is assigned to the dynamic background region. Based on the temporal redundancy identifier, P-frame predictive coding mode is set for target instances with high temporal redundancy, and B-frame bidirectional predictive coding mode is set for target instances with predictable motion. The quantization parameters corresponding to each pixel position are organized into a quantization parameter distribution map.

[0044] Specifically, baseline quantization parameters are extracted from the metadata of the video file to be compressed. These parameters are determined by the QP value during the original video encoding process, ranging from 22 to 28, and represent the baseline of the overall video compression quality. Based on the semantic importance level of each target instance in the semantic segmentation and object detection results, different quantization parameters are assigned according to a unified rule: for regions identified as first-level importance, such as faces and license plates, the highest restoration accuracy is maintained, so a first quantization parameter with the same value as the baseline quantization parameter is assigned; for regions identified as second-level importance, such as human bodies and vehicles, the compression intensity is moderately increased, and a second quantization parameter is assigned, which is the baseline quantization parameter plus an adjustment coefficient E; and for third-level importance target regions, such as minor objects, the quantization intensity is further increased, and a third quantization parameter is assigned, which is the baseline quantization parameter plus a coefficient G, achieving semantically driven quality control grading. Simultaneously, the static and dynamic attribute identifiers and texture complexity features of the background region are comprehensively analyzed. Using the static or dynamic categories marked in the background mask and the texture entropy values ​​of each local block, the background region is further classified. In static backgrounds, regions with low texture complexity (texture entropy below a preset threshold) are considered insensitive to perceptual quality and assigned a fourth quantization parameter (baseline quantization parameter plus F) for efficient compression. Regions with high texture complexity in static backgrounds, such as ground and vegetation, require more detailed information and are therefore assigned a fifth quantization parameter (baseline quantization parameter plus H). For dynamic background regions with strong temporal variations, a sixth quantization parameter (baseline quantization parameter plus M) is used to prevent motion artifacts caused by compression. By integrating temporal redundancy analysis results, corresponding coding prediction modes are defined while assigning quantization parameters to each target region: if the motion amplitude of a target instance within consecutive frames is below a motion threshold and the pixel structure similarity is above a similarity threshold, it is marked as a high temporal redundancy target and assigned a P-frame predictive coding mode, encoding only the residual signal to reduce the bit rate; if the target has stable uniform motion characteristics, a B-frame bidirectional predictive coding mode is assigned, using previous and subsequent frames as references while performing motion compensation; for targets with unstable motion patterns, I-frame intra-frame coding is retained to avoid the propagation of prediction errors. Based on the classification labels of their respective target masks or background regions, all pixels are spatially assigned their corresponding quantization parameter values ​​according to the allocation rules. These values ​​are then organized into a two-dimensional matrix consistent with the image resolution to construct a quantization parameter distribution map (QP). map (x,y).

[0045] After obtaining the baseline quantization parameters of the video file to be compressed, the process also includes allocating the bitrate budget based on the target distribution density: This involves statistically analyzing the number of target instances and pixel area percentages at each semantic importance level in the current frame, calculating the total area percentages of first-level, second-level, and third-level important target regions; calculating the allocated bitrate for each region type according to the preset target bitrate budget, using a first proportional coefficient for allocating the total bitrate budget to first-level important target regions, a second proportional coefficient for allocating the total bitrate budget to second-level important target regions, a third proportional coefficient for allocating the total bitrate budget to third-level important target regions, and allocating the remaining bitrate budget to the background region; and calculating the average bitrate per pixel for each region type based on the allocated bitrate and the total area percentage of that region type. The bitrate-quantization parameter mapping relationship is then used to deduce the required quantization parameter offsets for each region type, and the baseline quantization parameters are globally adjusted to ensure that key target regions receive sufficient bitrate resources.

[0046] In one specific embodiment, a compressed video file is obtained by recoding a YUV format frame sequence based on a quantization parameter distribution map while maintaining consistent metadata information, including: The standard encoder is invoked to dynamically set the quantization parameters for each macroblock according to the quantization parameter distribution map, and the YUV format frame sequence is encoded to obtain compressed domain bitstream data; The compressed domain bitstream data is encapsulated into the same container format as the video file to be compressed, and the resolution parameters, frame rate, encoding format identifier and timestamp information in the metadata information are written into the video file header; The audio bitstream is extracted from the video file to be compressed and written using a pass-through copy mode to obtain a compressed video file that maintains audio-video synchronization.

[0047] Specifically, based on a video encoder conforming to the H.264 or H.265 standard, the generated YUV format frame sequence and the corresponding quantization parameter distribution map (QP) are loaded. map The quantization parameter distribution map (x, y) defines the quantization level to be used at each position with pixel-level precision. When the encoder performs macroblock-level encoding, it uses the QP corresponding to the macroblock center coordinates. mapThe QP value serves as the basic quantization parameter for the current macroblock. The quantization control module is dynamically configured to ensure that each macroblock adaptively adjusts its quantization intensity based on its semantic, motion, and texture features. During macroblock segmentation, the encoder segments each frame image using 16×16 pixels as the basic unit. For macroblocks spanning multiple region boundaries, a boundary smoothing strategy is employed, which involves a weighted average of the quantization parameters of all pixels within the macroblock. The weighting coefficient is inversely proportional to the distance from the pixel to the macroblock center, avoiding block artifacts or edge artifacts caused by abrupt changes in QP values. In the transform coding and entropy coding stages, for background macroblocks with high quantization values, a high-frequency component suppression strategy is enhanced. After the DCT transform, over 70% of the high-frequency coefficients are set to zero, retaining only the low-frequency components to save bit overhead. In the CABAC encoder, the probability state of the context model is dynamically adjusted based on the quantization characteristics and motion patterns of adjacent macroblocks, improving coding efficiency and compression ratio. The resulting compressed domain bitstream is the lossy reconstruction result of the original frame sequence under differentiated quantization control. This bitstream is then written into a standard video encapsulation format file via the encapsulation module. Based on a container matching the original video format, such as MP4, TS, or AVI, the system writes all video parameters initially parsed and stored in the metadata buffer into the header of the new file during the encapsulation process. This includes resolution parameters (such as width and height), frame rate (FPS), video encoding format identifier (such as H.264 or H.265), color space description, and presentation timestamp (PTS) and decoding timestamp (DTS) information. This ensures that the compressed video maintains the same temporal structure and frame order logic as the original file during playback. To maintain the audio-video synchronization of the final output video, the audio stream is extracted from the original video file and directly inserted into the new video container using a pass-through method. This ensures that the content and quality of the audio data remain unchanged, while avoiding synchronization errors or sound quality loss due to audio re-encoding. The encoding system maintains the consistency of the audio track timestamps and video track timestamps during the encapsulation process. By writing the respective time reference information of the audio and video tracks into the container header, synchronized playback of the audio and video tracks is achieved, providing users with a smooth and consistent audio-visual experience when playing the compressed video file. The output video file maintains the same container format and compatibility as the original video file.

[0048] When the standard encoder dynamically sets the quantization parameters for each macroblock based on the quantization parameter distribution map to encode the YUV format frame sequence, it also includes differential processing of the transform coefficients: A Discrete Cosine Transform (DCT) is performed on each macroblock of the YUV format frame sequence to obtain the DCT coefficient matrix. The region type and corresponding quantization parameter value of the current macroblock are queried based on the quantization parameter distribution map. For background region macroblocks with quantization parameter values ​​greater than the high quantization threshold, the energy percentage of each coefficient in the DCT coefficient matrix is ​​calculated. High-frequency coefficients with energy percentages less than the energy threshold are set to zero, and only low-frequency components are retained for subsequent quantization encoding, resulting in a truncated DCT coefficient matrix. For target region macroblocks with quantization parameter values ​​less than or equal to the high quantization threshold, all coefficients in the DCT coefficient matrix are retained for quantization encoding. Entropy encoding is then performed based on the truncated DCT coefficient matrix to obtain the differentially processed compressed bitstream data.

[0049] When calling the standard encoder to dynamically set quantization parameters for each macroblock based on the quantization parameter distribution map, the process also includes region-adaptive adjustment of the Lagrange multipliers in rate-distortion optimization: The quantization parameter value and region type identifier corresponding to the current macroblock's center pixel position in the quantization parameter distribution map are read. An initial Lagrange multiplier is calculated based on the quantization parameter value as the basic parameter for rate-distortion optimization. The semantic importance of the region to which the current macroblock belongs is determined based on the region type identifier. For macroblocks in primary importance target regions, the initial Lagrange multiplier is multiplied by a first adjustment factor to increase the distortion cost weight. For macroblocks in secondary and tertiary importance target regions, the initial Lagrange multiplier remains unchanged. For macroblocks in background regions, the initial Lagrange multiplier is multiplied by a second adjustment factor to reduce the distortion cost weight. The adjusted Lagrange multiplier is then substituted into the rate-distortion optimization function for macroblock mode selection and motion estimation. While prioritizing the coding quality of key target regions, background regions are allowed to use higher-distortion coding modes to save bit rate, resulting in a region-adaptive optimized coding decision.

[0050] The video data compression method in the embodiments of the present invention has been described above. The video data compression system in the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 7 One embodiment of the video data compression system in this invention includes: The decoding module is used to decode the video file to be compressed, and obtain the YUV format frame sequence and metadata information; The module is used to segment YUV format frame sequences into instances to obtain a target foreground mask set and a background region mask, and to construct a target region model based on the target foreground mask set and a background region model based on the background region mask. The motion tracking module is used to perform motion tracking on target instances in the target region model, obtain the temporal redundancy identifier of the target instances, and calculate the quantization parameter distribution map. The recoding module is used to recode YUV format frame sequences based on the quantization parameter distribution map while maintaining the consistency of metadata information, resulting in a compressed video file.

[0051] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0052] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0053] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A video data compression method, characterized in that, include: The video file to be compressed is decoded to obtain a YUV format frame sequence and metadata information; The YUV format frame sequence is segmented into instances to obtain a target foreground mask set and a background region mask. A target region model is constructed based on the target foreground mask set, and a background region model is constructed based on the background region mask. Motion tracking is performed on target instances in the target region model to obtain the temporal redundancy identifier of the target instances and calculate the quantization parameter distribution map; The YUV format frame sequence is re-encoded based on the quantization parameter distribution map while maintaining the consistency of the metadata information to obtain a compressed video file.

2. The video data compression method according to claim 1, characterized in that, The process of decoding the video file to be compressed to obtain a YUV format frame sequence and metadata information includes: Read the encoding format identifier, resolution parameters, frame rate, GOP structure information and timestamp information from the container of the video file to be compressed, and store them as metadata information; The standard decoder is invoked to restore the compressed domain bitstream data of the video file to be compressed into pixel domain data, resulting in a YUV format frame sequence.

3. The video data compression method according to claim 1, characterized in that, The step of segmenting the YUV format frame sequence into instances to obtain a target foreground mask set and a background region mask, and constructing a target region model based on the target foreground mask set and a background region model based on the background region mask, includes: Extract a set of target candidate boxes containing human bodies, faces, vehicles, and license plates from the YUV format frame sequence; Each candidate box in the target candidate box set is classified and segmented at the pixel level to obtain a target foreground mask set, and non-target regions are masked to obtain a background region mask. Based on the target foreground mask set, the semantic importance level of the target is extracted and a target region model is constructed. Based on the background region mask, static and dynamic attribute identifiers are extracted and a background region model is constructed.

4. The video data compression method according to claim 3, characterized in that, The step of extracting the semantic importance level of the target based on the target foreground mask set and constructing a target region model, and extracting static and dynamic attribute identifiers based on the background region mask and constructing a background region model, includes: Based on the target foreground mask set, the average brightness value, gradient magnitude and texture complexity of each target instance are extracted. According to the target category, faces and license plates are marked as first-level importance, human bodies and vehicles are marked as second-level importance, and other targets are marked as third-level importance, thus constructing a target region model that includes semantic importance levels. The frame difference between the current frame and the previous frame is calculated based on the background region mask, and a background region model is constructed based on the frame difference.

5. The video data compression method according to claim 4, characterized in that, The step of calculating the frame difference of the background region between the current frame and the previous frame based on the background region mask, and constructing a background region model based on the frame difference, includes: Based on the background region mask, extract the frame difference of the background region in the current frame and the previous frame; The frame difference is compared with a preset threshold. Pixels with a frame difference less than the preset threshold are marked as static background pixels, and pixels with a frame difference greater than or equal to the preset threshold are marked as dynamic background pixels. Background modeling is performed on the background regions marked as static background pixels to obtain static background model parameters. Temporal change features are extracted from the background regions marked as dynamic background pixels to obtain dynamic background change features. A background region model containing static background model parameters, dynamic background change features, and static and dynamic attribute identifiers is constructed.

6. The video data compression method according to claim 5, characterized in that, The step of motion tracking of target instances in the target region model to obtain the temporal redundancy identifier of the target instances and calculate the quantization parameter distribution map includes: Extract each target instance from the target region model, and calculate the overall motion vector of the target instance layer by layer from coarse to fine; The motion amplitude of the target instance is calculated based on the overall motion vector, and the pixel similarity of the target instance in consecutive frames is calculated. When the motion amplitude is less than the motion threshold and the pixel similarity is greater than the similarity threshold, it is marked as high temporal redundancy, and the temporal redundancy identifier of the target instance is obtained. The quantization parameter distribution map is calculated based on the semantic importance level, the static and dynamic attribute identifiers, and the temporal redundancy identifier.

7. The video data compression method according to claim 6, characterized in that, The step of extracting each target instance from the target region model and calculating the overall motion vector of the target instance layer by layer from coarse to fine includes: A multi-layer image pyramid is constructed based on the image region covered by the target instance, and pixel positions with corner response values ​​greater than corner thresholds are selected as feature points within the image region of the target instance. Starting from the coarsest level of the multi-layer image pyramid, the optical flow increment between the current frame and the next frame is calculated for each feature point, and the optical flow calculation results are propagated to the fine level layer by layer to obtain the optical flow vector of each feature point at the original resolution. The optical flow vectors of all feature points of the target instance are subjected to median filtering to obtain the overall motion vector of the target instance.

8. The video data compression method according to claim 6, characterized in that, The step of calculating the quantization parameter distribution map of each frame of image based on the semantic importance level, the static and dynamic attribute identifiers, and the temporal redundancy identifier includes: Obtain the baseline quantization parameters of the video file to be compressed, and assign a first quantization parameter equal to the baseline quantization parameter to the first-level importance target region according to the semantic importance level, assign a second quantization parameter equal to the baseline quantization parameter plus E to the second-level importance target region, and assign a third quantization parameter equal to the baseline quantization parameter plus G to the third-level importance target region; Based on the static and dynamic attribute identifiers and the texture complexity of the background region, a fourth quantization parameter of the baseline quantization parameter plus F is assigned to the low-texture region of the static background; a fifth quantization parameter of the baseline quantization parameter plus H is assigned to the high-texture region of the static background; and a sixth quantization parameter of the baseline quantization parameter plus M is assigned to the dynamic background region. Based on the temporal redundancy identifier, a P-frame predictive coding mode is set for high temporal redundancy target instances, and a B-frame bidirectional predictive coding mode is set for motion predictable target instances. The quantization parameters corresponding to each pixel position are organized into a quantization parameter distribution map.

9. The video data compression method according to claim 1, characterized in that, The process of recoding the YUV format frame sequence based on the quantization parameter distribution map while maintaining the consistency of the metadata information to obtain a compressed video file includes: The standard encoder is invoked to dynamically set the quantization parameters for each macroblock according to the quantization parameter distribution map, and the YUV format frame sequence is encoded to obtain compressed domain bitstream data; The compressed domain bitstream data is encapsulated into a container format identical to the video file to be compressed, and the resolution parameters, frame rate, encoding format identifier, and timestamp information from the metadata information are written into the video file header. The audio bitstream is extracted from the video file to be compressed and written using a pass-through copy mode to obtain a compressed video file that maintains audio-video synchronization.

10. A video data compression system, characterized in that, A method for performing video data compression as described in any one of claims 1-9, comprising: The decoding module is used to decode the video file to be compressed, and obtain the YUV format frame sequence and metadata information; The construction module is used to perform instance segmentation on the YUV format frame sequence to obtain a target foreground mask set and a background region mask, and to construct a target region model based on the target foreground mask set and a background region model based on the background region mask. The motion tracking module is used to perform motion tracking on target instances in the target region model, obtain the temporal redundancy identifier of the target instance, and calculate the quantization parameter distribution map. The re-encoding module is used to re-encode the YUV format frame sequence based on the quantization parameter distribution map while maintaining the consistency of the metadata information, thereby obtaining a compressed video file.