Efficient video compression and real-time transmission method and system
Through the sliding window algorithm, the network speed is monitored and compression is segmented according to the video content, and the video compression rate is dynamically adjusted, which solves the problem of difficulty in ensuring smoothness and quality in video transmission in the prior art, and achieves more efficient video compression and transmission.
Patent Information
- Application Number
- CN202411853565.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-28
AI Technical Summary
Existing video compression technology is difficult to ensure smoothness and quality in high-definition video transmission, especially when network conditions are unstable or bandwidth is limited, and the fixed compression rate strategy fails to optimize the dynamic changes in video content and real-time fluctuations in network conditions, affecting the user experience.
The average network transmission speed of the video playback terminal is monitored through the sliding window algorithm, and the compression rate of the foreground characters and background is determined based on the average network transmission speed, and the video is segmented through the deep learning model and compressed separately. At the same time, the video compression scheme is adjusted according to the user's viewing process and the remaining playback time.
It realizes dynamic adjustment of video compression rate based on network conditions and video content, ensures the clarity and video quality of prospective characters, and improves the smoothness and user experience of video.
Smart Images

Figure CN119728992A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video compression, and in particular to a high-efficiency video compression and real-time transmission method and system. Background Art
[0002] Both online viewing of film and television videos and live broadcasts on the Internet need to rely on efficient and stable video transmission technology. However, in practical applications, the transmission of video data faces many challenges. On the one hand, the amount of high-definition video data is large, and the bandwidth requirements of the network are high. Especially when the network conditions are unstable or the bandwidth is limited, the video fluency and quality are often difficult to guarantee. On the other hand, users' viewing habits and network environments are changeable. How to achieve fast loading and smooth playback of video content under different conditions has become an urgent problem to be solved. Although traditional video compression technology has reduced the size of video files to a certain extent, it often adopts a fixed compression rate and fails to fully consider the dynamic changes of video content and the real-time fluctuations of network conditions. In addition, the fixed compression rate strategy fails to optimize the characteristics of the video content, and the same compression rate is used for the foreground characters and the background, which greatly damages the clarity of important information and seriously affects the user experience. Therefore, it is necessary to provide an efficient video compression and real-time transmission method and system to solve or alleviate the above problems. Summary of the invention
[0003] In view of the deficiencies in the prior art, the purpose of the present invention is to provide a method and system for efficient video compression and real-time transmission to solve the problems existing in the above-mentioned background technology.
[0004] The present invention is implemented as follows: a high-efficiency video compression and real-time transmission method, the method comprising the following steps:
[0005] Monitor the average network transmission speed and the maximum network transmission speed of the video playback terminal based on the sliding window algorithm;
[0006] Determine a foreground character compression rate and a background compression rate according to the average network transmission speed, and determine a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate;
[0007] The video is segmented into foreground characters and backgrounds through a deep learning model, and the segmented foreground characters and backgrounds are compressed separately according to a video compression scheme;
[0008] Transmit the compressed video file to the video playback terminal via TCP or UDP protocol;
[0009] Determine the remaining playback time of the transmitted video file based on the user's viewing progress, and adjust the video compression scheme based on the remaining playback time and the average network transmission speed.
[0010] As a further solution of the present invention: the step of monitoring the average network transmission speed of the video playback terminal based on the sliding window algorithm specifically includes:
[0011] The sliding window size is retrieved and the network transmission speed at time t is monitored to be Vt;
[0012] The average network transmission speed Vavg is calculated. N represents the sliding window size.
[0013] As a further solution of the present invention: determining the foreground character compression rate and the background compression rate according to the average network transmission speed, and determining the video compression scheme according to the foreground character compression rate and the background compression rate, specifically includes:
[0014] Determine the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed;
[0015] According to the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters;
[0016] Determine the video compression scheme based on the foreground character compression rate and background compression rate, and adjust the video parameters.
[0017] As a further solution of the present invention: the step of determining the video compression scheme according to the foreground character compression rate and the background compression rate specifically includes:
[0018] Determining encoding settings of an H.265 compression algorithm according to a compression rate of a foreground character, wherein the encoding settings include a bit rate, a resolution, a frame rate, an encoding block size, and motion compensation;
[0019] Determining a compression configuration of a VP9 compression algorithm according to the background compression rate, the compression configuration including a bit rate, encoding parameters, and an encoding mode;
[0020] Get the video compression solution based on the configured H.265 compression algorithm and VP9 compression algorithm.
[0021] As a further solution of the present invention: the step of segmenting the foreground person and the background of the video by the deep learning model, and compressing the segmented foreground person and the background respectively according to the video compression scheme, specifically includes:
[0022] Read the video file through OpenCV's VideoCapture class, iterate each frame in the video, and convert each frame into the input format accepted by the YOLO model;
[0023] Run the YOLO model on each frame of the image to perform target detection. Based on the target detection, use the segmentation function of the YOLO model to extract the foreground person;
[0024] The foreground person is separated from the background using the mask information to obtain the foreground person and the background, and the segmented foreground person and the background are compressed separately according to the video compression scheme;
[0025] Resynthesize the compressed foreground characters and background to generate new video frames, and use OpenCV's VideoWriter class to write the synthesized video frames into a new video file.
[0026] As a further solution of the present invention: the step of adjusting the video compression scheme according to the remaining playback time and the average network transmission speed specifically includes:
[0027] The compression rate C of the foreground character is calculated based on the remaining playback time T. fg and background compression rate C bg Update, the updated foreground character compression rate C fg ' and background compression rate C bg 'Respectively:
[0028] According to the updated foreground character compression rate C fg ' and background compression rate C bg 'Reset the video compression scheme.
[0029] Another object of the present invention is to provide a high-efficiency video compression and real-time transmission system, the system comprising:
[0030] The network transmission speed monitoring module is used to monitor the average network transmission speed of the video playback terminal and the maximum value of the network transmission speed based on the sliding window algorithm;
[0031] A video compression scheme module is used to determine a foreground character compression rate and a background compression rate according to the average network transmission speed, and determine a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate;
[0032] The character and background segmentation module is used to segment the foreground character and background of the video through a deep learning model, and compress the segmented foreground character and background separately according to the video compression scheme;
[0033] The video file transmission module is used to transmit the compressed video file to the video playback terminal through the TCP or UDP protocol;
[0034] The compression scheme adjustment module is used to determine the remaining playback time of the transmitted video file according to the user's viewing progress, and adjust the video compression scheme according to the remaining playback time and the average network transmission speed.
[0035] As a further solution of the present invention: the network transmission speed monitoring module includes:
[0036] The network transmission speed monitoring unit is used to retrieve the sliding window size and monitor the network transmission speed Vt at time t;
[0037] The average speed calculation unit is used to calculate the average network transmission speed Vavg. N represents the sliding window size.
[0038] As a further solution of the present invention: the video compression solution module includes:
[0039] A foreground character compression rate unit is used to determine the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed;
[0040] The background compression rate unit is used to calculate the background compression rate according to the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters;
[0041] The compression scheme determining unit is used to determine the video compression scheme according to the foreground character compression rate and the background compression rate, and adjust the video parameters.
[0042] As a further solution of the present invention: the character background segmentation module includes:
[0043] The video frame processing unit is used to read the video file through the OpenCV VideoCapture class, iteratively process each frame in the video, and convert each frame into the input format accepted by the YOLO model;
[0044] The target detection unit is used to run the YOLO model on each frame of the image to perform target detection. Based on the target detection, the segmentation function of the YOLO model is used to extract the foreground person;
[0045] A person-background separation unit is used to separate a foreground person from a background using mask information to obtain a foreground person and a background, and to compress the separated foreground person and background respectively according to a video compression scheme;
[0046] The new video frame generation unit is used to re-synthesize the compressed foreground characters and background to generate new video frames, and use the VideoWriter class of OpenCV to write the synthesized video frames into a new video file.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] The present invention determines the compression rate of the foreground character and the background compression rate according to the average network transmission speed, fully considering the dynamic changes of network resources, and the compression rate of the foreground character is lower than the compression rate of the background. In this way, the foreground character and the background can be effectively distinguished, and the foreground character is relatively clear, and the important content can be optimized in a targeted manner, and the overall quality of the video is guaranteed as much as possible. In addition, the remaining playback time of the transmitted video file can be determined according to the viewing process of the user, and the video compression scheme is adjusted according to the remaining playback time and the average network transmission speed. When the remaining playback time is long, the compression rate is appropriately reduced, the video quality is enhanced, and the user's viewing experience is further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 The present invention is a flowchart of an efficient video compression and real-time transmission method.
[0050] Figure 2 The present invention is a flow chart for monitoring the average network transmission speed in a highly efficient video compression and real-time transmission method.
[0051] Figure 3 The present invention is a flow chart for determining the compression rate of foreground characters and background in a high-efficiency video compression and real-time transmission method.
[0052] Figure 4 The present invention is a flowchart for determining a video compression scheme in an efficient video compression and real-time transmission method.
[0053] Figure 5 The present invention is a flowchart for segmenting foreground characters and background in a highly efficient video compression and real-time transmission method.
[0054] Figure 6 The present invention is a flow chart of adjusting a video compression scheme in a method for efficient video compression and real-time transmission.
[0055] Figure 7 It is a structural diagram of a highly efficient video compression and real-time transmission system. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. 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.
[0057] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.
[0058] like Figure 1 As shown, an embodiment of the present invention provides a method for efficient video compression and real-time transmission, the method comprising the following steps:
[0059] S100, monitoring the average network transmission speed and the maximum value of the network transmission speed of the video playback terminal based on the sliding window algorithm;
[0060] S200, determining a foreground character compression rate and a background compression rate according to the average network transmission speed, and determining a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate;
[0061] S300, segmenting the foreground person and the background of the video using a deep learning model, and compressing the segmented foreground person and the background respectively according to a video compression scheme;
[0062] S400, transmitting the compressed video file to the video playback terminal via TCP or UDP protocol;
[0063] S500, determining the remaining playback time of the transmitted video file according to the user's viewing progress, and adjusting the video compression scheme according to the remaining playback time and the average network transmission speed.
[0064] It should be noted that, although the traditional video compression technology reduces the size of the video file to a certain extent, it often adopts a fixed compression rate and fails to fully consider the dynamic changes of the video content and the real-time fluctuations of the network conditions. In addition, the fixed compression rate strategy fails to optimize the characteristics of the video content, and the same compression rate is used for the foreground characters and the background, which greatly damages the clarity of important information. The embodiments of the present invention are intended to solve or alleviate the above problems.
[0065] In the embodiment of the present invention, the average network transmission speed and the maximum value of the network transmission speed of the video playback terminal are first monitored by a sliding window algorithm. The maximum value of the network transmission speed refers to the maximum value of the network speed in the monitoring time period. Then the foreground character compression rate and the background compression rate are determined according to the average network transmission speed. In this way, the dynamic changes of network resources are fully considered, and the amount of data can be effectively reduced when the network condition is poor, so as to avoid video playback jamming or interruption; then the video compression scheme is determined according to the foreground character compression rate and the background compression rate. The foreground character compression rate is lower than the background compression rate. In this way, the foreground character and the background can be effectively distinguished, and the foreground character is relatively clear. The foreground character is generally important information, and the important content can be optimized in a targeted manner, so as to ensure the overall quality of the video as much as possible. Then, the video is segmented from the foreground character and the background through a deep learning model, and the segmented foreground character and the background are compressed respectively according to the video compression scheme, and then the compressed video file is transmitted to the video playback terminal through the TCP or UDP protocol. In addition, the embodiment of the present invention also determines the remaining playback time of the transmitted video file based on the user's viewing progress. It is easy to understand that when playing a video, in order to ensure smooth playback, a portion of the video data is usually cached in the video playback terminal, and then the video compression scheme is adjusted according to the remaining playback time and the average network transmission speed. When the remaining playback time is long, the compression rate is appropriately reduced to enhance the video quality and improve the user's viewing experience.
[0066] like Figure 2 As shown, as a preferred embodiment of the present invention, the step of monitoring the average network transmission speed of the video playback terminal based on the sliding window algorithm specifically includes:
[0067] S101, retrieve the sliding window size, and monitor the network transmission speed Vt at time t;
[0068] S102, calculate and obtain the average network transmission speed Vavg, N represents the sliding window size.
[0069] In the embodiment of the present invention, in order to determine the average network transmission speed within time t, the t value is set. First, a sliding window size N needs to be set, and the network transmission speed at each moment within time t is monitored. Then, the sliding window algorithm can be used to calculate the average network transmission speed Vavg, and Vi is the network transmission speed at moment i.
[0070] like Figure 3 As shown, as a preferred embodiment of the present invention, the steps of determining the foreground character compression rate and the background compression rate according to the average network transmission speed, and determining the video compression scheme according to the foreground character compression rate and the background compression rate specifically include:
[0071] S201, determining the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed;
[0072] S202, based on the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters;
[0073] S203, determining a video compression scheme according to the foreground character compression rate and the background compression rate, and adjusting video parameters.
[0074] In the embodiment of the present invention, after the average network transmission speed Vavg and the maximum value Vmax of the network transmission speed are determined, the foreground character compression rate C can be calculated. fg and background compression rate C bg Among them, Among them, α and β are fixed parameters, which are fixed values set in advance, C bg =δ×C fg +σ, where δ and σ are fixed parameters, which are also fixed values set in advance. δ and σ can ensure that the background compression rate is greater than the foreground character compression rate. Finally, the video compression scheme is determined according to the foreground character compression rate and the background compression rate, and the video parameters are adjusted. The video parameters include bit rate, resolution and frame rate.
[0075] like Figure 4 As shown, as a preferred embodiment of the present invention, the step of determining the video compression scheme according to the foreground character compression rate and the background compression rate specifically includes:
[0076] S2031, determining encoding settings of the H.265 compression algorithm according to the compression rate of the foreground character, wherein the encoding settings include bit rate, resolution, frame rate, encoding block size, and motion compensation;
[0077] S2032, determining a compression configuration of a VP9 compression algorithm according to the background compression rate, where the compression configuration includes a bit rate, encoding parameters, and an encoding mode;
[0078] S2033: Obtain a video compression solution according to the configured H.265 compression algorithm and VP9 compression algorithm.
[0079] In the embodiment of the present invention, the compression algorithm for the foreground characters is H.265. H.265 uses more advanced technologies, such as larger block size, more sophisticated motion compensation and improved entropy coding, and can achieve a good compression ratio at a higher video quality; the compression algorithm for the background is VP9. VP9 has certain advantages over H.265 in compression rate, and VP9 supports up to 10 different bit rate configurations, which is convenient for configuration. When in use, the encoding settings of the H.265 compression algorithm will be determined according to the compression rate of the foreground characters. The encoding settings include bit rate, resolution, frame rate, encoding block size and motion compensation. Here, it is necessary to determine the specific parameter values of the corresponding encoding settings for the compression rate of each range in advance; then, the compression configuration of the VP9 compression algorithm is determined according to the background compression rate. The compression configuration includes bit rate, encoding parameters and encoding mode. Here, it is also necessary to determine the specific parameter values of the corresponding compression configuration for the compression rate of each range in advance. Finally, according to the configured H.265 compression algorithm and VP9 compression algorithm, a video compression scheme will be obtained.
[0080] like Figure 5 As shown, as a preferred embodiment of the present invention, the step of segmenting the foreground person and the background of the video by a deep learning model, and compressing the segmented foreground person and the background respectively according to the video compression scheme, specifically includes:
[0081] S301, reading the video file through the VideoCapture class of OpenCV, iteratively processing each frame in the video, and converting each frame into an input format accepted by the YOLO model;
[0082] S302, running the YOLO model on each frame of the image to perform target detection, and based on the target detection, using the segmentation function of the YOLO model to extract the foreground person;
[0083] S303, using the mask information to separate the foreground person from the background to obtain the foreground person and the background, and compressing the separated foreground person and the background respectively according to a video compression scheme;
[0084] S304, resynthesizing the compressed foreground person and background to generate a new video frame.
[0085] In an embodiment of the present invention, video frames are read and processed by OpenCV, and the Ultralytics YOLO library is installed, which includes the implementation of the YOLO model and related tools. When used specifically, the video file is first read through the VideoCapture class of OpenCV, each frame in the video is iteratively processed, and each frame is converted into an input format accepted by the YOLO model, such as RGB format; then the YOLO model is run on each frame of the image to perform target detection, and on the basis of target detection, the foreground character is extracted using the segmentation function of the YOLO model; according to the prediction results of the YOLO model, the bounding box and mask of the foreground character are extracted, and the foreground character is separated from the background using the mask information to obtain the foreground character and the background, and then the segmented foreground character and background are compressed separately according to the video compression scheme. Finally, the compressed foreground character and background are resynthesized to generate a new video frame, and the synthesized video frame is written into a new video file using the VideoWriter class of OpenCV.
[0086] like Figure 6 As shown, as a preferred embodiment of the present invention, the step of adjusting the video compression scheme according to the remaining playback time and the average network transmission speed specifically includes:
[0087] S501: Compress the foreground character according to the remaining playback time T. fg and background compression rate C bg Make updates;
[0088] S502, based on the updated foreground character compression rate C fg ' and background compression rate C bg 'Reset the video compression scheme.
[0089] In the embodiment of the present invention, the remaining playback time T is monitored and the foreground character compression rate C is adjusted according to the remaining playback time T. fg and background compression rate C bg Update, the updated foreground character compression rate C fg ' and background compression rate C bg 'Respectively: Tmax is a fixed value set in advance. Tmax refers to the maximum video duration pre-cached in the video playback terminal. Finally, according to the updated foreground character compression rate C fg ' and background compression rate C bg 'Reset the video compression scheme.
[0090] like Figure 7 As shown, the embodiment of the present invention also provides a high-efficiency video compression and real-time transmission system, the system comprising:
[0091] The network transmission speed monitoring module 100 is used to monitor the average network transmission speed of the video playback terminal and the maximum value of the network transmission speed based on the sliding window algorithm;
[0092] A video compression scheme module 200 is used to determine a foreground character compression rate and a background compression rate according to the average network transmission speed, and determine a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate;
[0093] The character and background segmentation module 300 is used to segment the foreground character and the background of the video through a deep learning model, and compress the segmented foreground character and the background respectively according to a video compression scheme;
[0094] The video file transmission module 400 is used to transmit the compressed video file to the video playback terminal via TCP or UDP protocol;
[0095] The compression scheme adjustment module 500 is used to determine the remaining playback time of the transmitted video file according to the user's viewing progress, and adjust the video compression scheme according to the remaining playback time and the average network transmission speed.
[0096] In the embodiment of the present invention, the network transmission speed monitoring module 100 includes:
[0097] The network transmission speed monitoring unit is used to retrieve the sliding window size and monitor the network transmission speed Vt at time t;
[0098] The average speed calculation unit is used to calculate the average network transmission speed Vavg. N represents the sliding window size.
[0099] In the embodiment of the present invention, the video compression scheme module 200 includes:
[0100] A foreground character compression rate unit is used to determine the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed;
[0101] The background compression rate unit is used to calculate the background compression rate according to the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters;
[0102] The compression scheme determining unit is used to determine the video compression scheme according to the foreground character compression rate and the background compression rate, and adjust the video parameters.
[0103] In the embodiment of the present invention, the character background segmentation module 300 includes:
[0104] The video frame processing unit is used to read the video file through the OpenCV VideoCapture class, iteratively process each frame in the video, and convert each frame into the input format accepted by the YOLO model;
[0105] The target detection unit is used to run the YOLO model on each frame of the image to perform target detection. Based on the target detection, the segmentation function of the YOLO model is used to extract the foreground person;
[0106] A person-background separation unit is used to separate a foreground person from a background using mask information to obtain a foreground person and a background, and to compress the separated foreground person and background respectively according to a video compression scheme;
[0107] The new video frame generation unit is used to re-synthesize the compressed foreground characters and background to generate new video frames, and use the VideoWriter class of OpenCV to write the synthesized video frames into a new video file.
[0108] The above only describes in detail the preferred embodiments of the present invention, which is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0109] It should be understood that, although each step in the flow chart of each embodiment of the present invention is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0110] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0111] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the disclosure in the specification and examples. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A high-efficiency video compression and real-time transmission method, characterized in that: The method comprises the following steps: Monitor the average network transmission speed and the maximum network transmission speed of the video playback terminal based on the sliding window algorithm; Determine a foreground character compression rate and a background compression rate according to the average network transmission speed, and determine a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate; The video is segmented into foreground characters and backgrounds through a deep learning model, and the segmented foreground characters and backgrounds are compressed separately according to a video compression scheme; Transmit the compressed video file to the video playback terminal via TCP or UDP protocol; Determine the remaining playback time of the transmitted video file based on the user's viewing progress, and adjust the video compression scheme based on the remaining playback time and the average network transmission speed.
2. The high-efficiency video compression and real-time transmission method according to claim 1, characterized in that: The step of monitoring the average network transmission speed of the video playback terminal based on the sliding window algorithm specifically includes: The sliding window size is retrieved and the network transmission speed at time t is monitored to be Vt; The average network transmission speed Vavg is calculated. N represents the sliding window size.
3. The high-efficiency video compression and real-time transmission method according to claim 1, characterized in that: The steps of determining a foreground character compression rate and a background compression rate according to the average network transmission speed, and determining a video compression scheme according to the foreground character compression rate and the background compression rate specifically include: Determine the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed; According to the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters; Determine the video compression scheme based on the foreground character compression rate and background compression rate, and adjust the video parameters.
4. The high-efficiency video compression and real-time transmission method according to claim 3, characterized in that: The step of determining the video compression scheme according to the foreground character compression rate and the background compression rate specifically includes: Determining encoding settings of an H.265 compression algorithm according to a compression rate of a foreground character, wherein the encoding settings include a bit rate, a resolution, a frame rate, an encoding block size, and motion compensation; Determining a compression configuration of a VP9 compression algorithm according to the background compression rate, the compression configuration including a bit rate, encoding parameters, and an encoding mode; Get the video compression solution based on the configured H.265 compression algorithm and VP9 compression algorithm.
5. The high-efficiency video compression and real-time transmission method according to claim 1, characterized in that: The step of segmenting the foreground person and the background of the video by using a deep learning model, and compressing the segmented foreground person and the background respectively according to a video compression scheme specifically includes: Read the video file through OpenCV's VideoCapture class, iterate each frame in the video, and convert each frame into the input format accepted by the YOLO model; Run the YOLO model on each frame of the image to perform target detection. Based on the target detection, use the segmentation function of the YOLO model to extract the foreground person; The foreground person is separated from the background using the mask information to obtain the foreground person and the background, and the segmented foreground person and the background are compressed separately according to the video compression scheme; Resynthesize the compressed foreground characters and background to generate new video frames, and use OpenCV's VideoWriter class to write the synthesized video frames into a new video file.
6. The high-efficiency video compression and real-time transmission method according to claim 1, characterized in that: The step of adjusting the video compression scheme according to the remaining playback time and the average network transmission speed specifically includes: The compression rate C of the foreground character is calculated based on the remaining playback time T. fg and background compression rate C bg Update, the updated foreground character compression rate C fg ' and background compression rate C bg 'Respectively: According to the updated foreground character compression rate C fg ' and background compression rate C bg 'Reset the video compression scheme.
7. An efficient video compression and real-time transmission system, characterized in that: The system comprises: The network transmission speed monitoring module is used to monitor the average network transmission speed of the video playback terminal and the maximum value of the network transmission speed based on the sliding window algorithm; A video compression scheme module is used to determine a foreground character compression rate and a background compression rate according to the average network transmission speed, and determine a video compression scheme according to the foreground character compression rate and the background compression rate, wherein the foreground character compression rate is lower than the background compression rate; The character and background segmentation module is used to segment the foreground character and background of the video through a deep learning model, and compress the segmented foreground character and background separately according to the video compression scheme; The video file transmission module is used to transmit the compressed video file to the video playback terminal through the TCP or UDP protocol; The compression scheme adjustment module is used to determine the remaining playback time of the transmitted video file according to the user's viewing progress, and adjust the video compression scheme according to the remaining playback time and the average network transmission speed.
8. The high-efficiency video compression and real-time transmission system according to claim 7, characterized in that: The network transmission speed monitoring module includes: The network transmission speed monitoring unit is used to retrieve the sliding window size and monitor the network transmission speed Vt at time t; The average speed calculation unit is used to calculate the average network transmission speed Vavg. N represents the sliding window size.
9. The high-efficiency video compression and real-time transmission system according to claim 7, characterized in that: The video compression scheme module includes: A foreground character compression rate unit is used to determine the foreground character compression rate C according to the average network transmission speed Vavg fg , Among them, α and β are fixed parameters, and Vmax is the maximum value of network transmission speed; The background compression rate unit is used to calculate the background compression rate according to the average network transmission speed Vavg and the foreground character compression rate C fg Determine the background compression ratio C bg , C bg =δ×C fg +σ, where δ and σ are fixed parameters; The compression scheme determining unit is used to determine the video compression scheme according to the foreground character compression rate and the background compression rate, and adjust the video parameters.
10. The high-efficiency video compression and real-time transmission system according to claim 7, characterized in that: The character background segmentation module comprises: The video frame processing unit is used to read the video file through the OpenCV VideoCapture class, iteratively process each frame in the video, and convert each frame into the input format accepted by the YOLO model; The target detection unit is used to run the YOLO model on each frame of the image to perform target detection. Based on the target detection, the segmentation function of the YOLO model is used to extract the foreground person; A person-background separation unit is used to separate a foreground person from a background using mask information to obtain a foreground person and a background, and to compress the separated foreground person and background respectively according to a video compression scheme; The new video frame generation unit is used to re-synthesize the compressed foreground characters and background to generate new video frames, and use the VideoWriter class of OpenCV to write the synthesized video frames into a new video file.