Method, apparatus, equipment and media for scene switching detection using x264 encoder for vertical short drama videos

By introducing a gradient weighting strategy and weighted cost calculation of chroma SATD values ​​into the x264 encoder, scene switching detection for vertical short drama videos was optimized, solving the problems of false positives and false negatives, and improving detection accuracy and encoding efficiency.

CN122137970APending Publication Date: 2026-06-02MALANSHAN AUDIO & VIDEO LABORATORY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
MALANSHAN AUDIO & VIDEO LABORATORY
Filing Date
2026-03-10
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

The existing x264 encoder has a problem with low scene transition detection accuracy in vertical short drama videos, especially when dynamic subtitles or scrolling bullet comments appear at the bottom of the screen, which can easily misjudge the scene transition, resulting in a surge in bitrate and visual mismatch.

Method used

A preset gradient weighting strategy is used to divide video frames into different regions and assign weight coefficients to macroblocks in each region. By combining the SATD values ​​of luminance and chrominance components, a scene transition score is determined through weighted cost calculation, thereby optimizing scene transition detection.

Benefits of technology

It improves the accuracy of scene transition detection in vertical short drama videos, reduces the false positive rate, reduces unnecessary I-frame insertion, and improves video encoding quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122137970A_ABST
    Figure CN122137970A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and medium for scene switching detection using an x264 encoder for vertical short-form video, relating to the field of video coding technology. The method includes: dividing the vertical screen of a target video frame into target gradient regions using a preset gradient weighting strategy, and assigning weight coefficients to macroblocks in each target gradient region; downsampling the target video frame and calculating the SATD value of each macroblock based on the processed frame data; the SATD value includes the luminance component and chrominance component SATD values; determining the weighted cost value of each macroblock according to a preset weighted cost calculation formula and using the SATD value and weight coefficients to determine the full-frame cost of the target video frame; including a first full-frame cost when the target video frame is a P-frame and a second full-frame cost when it is an I-frame; determining the scene switching score of the target video frame through the full-frame cost, and determining whether the target video frame meets the preset scene switching conditions based on the scene switching score.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video encoding technology, and in particular to a method, apparatus, device, and medium for scene switching detection using an x264 encoder for vertical short drama videos. Background Technology

[0002] x264 (a video coding library) is currently the most widely used H.264 (a digital video codec standard) encoder. Its native scene cut detection mechanism primarily determines the scene by calculating the absolute error (SATD) cost of inter-frame pixel blocks at half resolution. Existing general algorithms are based on a full-image uniform weighting and brightness-driven design, which presents the following challenges in vertical short-form video scenarios: Misjudgment of bottom interference: Many short-form videos and live streams have large, high-frequency dynamically changing subtitles, scrolling comments, or exchange buttons superimposed in the bottom 15%-25% area of ​​the screen. This high-contrast dynamic content causes drastic fluctuations in the SATD value. Traditional algorithms are highly susceptible to this interference, mistakenly interpreting scene transitions as changes and leading to the incorrect insertion of IDR (Instantaneous Decoding Refresh) frames: disrupting the GOP (Group of Pictures) structure and causing a surge in bitrate; breathing effect: unnecessary I-frames (Intra-coded Frames) reset the reference relationship, causing periodic sharpness jumps in the background. Chromaticity change detection is missed: defaults to brightness-based judgment, while short dramas often use high-saturation filters or abrupt color changes to switch shots, such as color-to-black-and-white transitions or warm / cool color transitions. These transitions have high similarity in brightness structure, only with significant chromaticity differences, making it easy for existing x264 algorithms to miss these changes, resulting in transition color block artifacts. Visual saliency mismatch: in vertical videos, the main tasks and actions are concentrated in the upper center of the screen. Traditional algorithms give equal weight to the edges and center of the screen, which does not align with the human eye's focus characteristics on vertical short dramas.

[0003] In conclusion, optimizing the scene transition detection method of the x264 encoder to improve the accuracy of scene transition detection in vertical short drama videos is an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for scene transition detection using an x264 encoder for vertical short-form video, which can optimize the x264 encoder scene transition detection method to improve the accuracy of scene transition detection for vertical short-form video. The specific solution is as follows: Firstly, this application provides a method for scene transition detection using an x264 encoder for vertical short video dramas, including: Using a preset gradient weighting strategy, the vertical screen of the target video frame is divided into target gradient regions, and corresponding weight coefficients are assigned to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video. The target video frame is downsampled to obtain corresponding processed frame data, and the SATD value of each macroblock is calculated based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value. According to the preset weighted cost calculation formula and using the SATD value and the weight coefficient, the weighted cost value of each macroblock is determined, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame. The scene switching score of the target video frame is determined by the full frame cost, and the scene switching score is used to determine whether the target video frame meets the preset scene switching conditions.

[0005] Optionally, the step of dividing the vertical screen of the target video frame into target gradient regions using a preset gradient weight strategy includes: Determine the screen height of the vertical screen of the target video frame, and take the upper left corner of the vertical screen as the origin of the coordinate system. Within the screen height, divide the vertical screen into a first target gradient region, a second target gradient region, and a third target gradient region according to the corresponding vertical coordinate values. Wherein, any vertical coordinate value of the first target gradient region is less than any vertical coordinate value of the second target gradient region, and any vertical coordinate value of the second target gradient region is less than any vertical coordinate value of the third target gradient region.

[0006] Optionally, assigning corresponding weight coefficients to macroblocks in each of the target gradient regions includes: A first weight coefficient is assigned to macroblocks in the first target gradient region, and a second weight coefficient is assigned to macroblocks in the third target gradient region; the second weight coefficient is lower than the first weight coefficient. Based on the vertical coordinate values, corresponding weight coefficients are assigned to macroblocks in the second target gradient region; the vertical coordinate values ​​of each macroblock in the second target gradient region are negatively correlated with the weight coefficients; the weight coefficients of each macroblock in the second target gradient region are all within the target weight coefficient range; the target weight coefficient range is composed of the first weight coefficient and the second weight coefficient.

[0007] Optionally, the process of determining the weighted cost value includes: Determine the target weight coefficient, target luminance component SATD value, and target chrominance component SATD value of the target macroblock, and determine the first sum value among the target chrominance component SATD values; Determine the product between the first sum and the preset chromaticity sensitivity coefficient, and determine the second sum between the product and the target luminance component SATD value; The product of the second sum and the target weight coefficient is determined as the weighted cost of the target macroblock.

[0008] Optionally, any of the SATD values ​​includes a first SATD value and a second SATD value; the first SATD value is the SATD value when the target video frame is a P-frame; the second SATD value is the SATD value when the target video frame is an I-frame. Accordingly, determining the weighted cost value of each macroblock according to the preset weighted cost calculation formula and using the SATD value and the weight coefficient includes: The first weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the first SATD value and the weight coefficient. The second weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the second SATD value and the weight coefficient. Wherein, the first weighted cost value is the weighted cost value when the target video frame is a P-frame; the second weighted cost value is the weighted cost value when the target video frame is an I-frame.

[0009] Optionally, determining the full-frame cost of the target video frame based on the weighted cost value includes: The third sum between the first weighted cost values ​​is determined as the first full-frame cost of the target video frame; The fourth sum between the second weighted cost values ​​is determined as the second full-frame cost of the target video frame.

[0010] Optionally, determining the scene switching score of the target video frame using the full-frame cost, and determining whether the target video frame meets the preset scene switching conditions based on the scene switching score, includes: Determine the ratio between the first full-frame cost and the second full-frame cost, and determine the difference between the first and the second full-frame cost as the scene switching score of the target video frame; The scene switching score is compared with a preset score threshold to obtain the corresponding comparison result; If the comparison result indicates that the scene switching score is less than the preset score threshold, then the target video frame is determined to meet the preset scene switching conditions. If the comparison result indicates that the scene switching score is not less than the preset score threshold, then the target video frame is determined not to meet the preset scene switching conditions.

[0011] Secondly, this application provides an x264 encoder scene switching detection device for vertical short drama videos, comprising: The coefficient allocation module is used to divide the vertical screen of the target video frame into target gradient regions using a preset gradient weight strategy, and to assign corresponding weight coefficients to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video. The value calculation module is used to downsample the target video frame to obtain the corresponding processed frame data, and calculate the SATD value of each macroblock based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value. The cost value determination module is used to determine the weighted cost value of each macroblock according to a preset weighted cost calculation formula and using the SATD value and the weight coefficient, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame. The condition determination module is used to determine the scene switching score of the target video frame through the full frame cost, and to determine whether the target video frame meets the preset scene switching conditions based on the scene switching score.

[0012] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute the computer program to implement the aforementioned x264 encoder scene switching detection method for vertical short drama videos.

[0013] Fourthly, this application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned x264 encoder scene switching detection method for vertical short drama videos.

[0014] In this application, a preset gradient weighting strategy is used to divide the vertical screen of a target video frame into target gradient regions, and a corresponding weight coefficient is assigned to macroblocks in each target gradient region. The target video frame is any video frame in a target vertical short drama video. The target video frame is downsampled to obtain corresponding processed frame data, and the SATD value of each macroblock is calculated based on the processed frame data. The SATD value includes the luminance component SATD value and the chrominance component SATD value. According to a preset weighted cost calculation formula and using the SATD value and the weight coefficient, the weighted cost value of each macroblock is determined, and the full frame cost of the target video frame is determined based on the weighted cost value. The full frame cost includes the first full frame cost when the target video frame is a P-frame and the second full frame cost when it is an I-frame. The scene switching score of the target video frame is determined by the full frame cost, and the scene switching score is used to determine whether the target video frame meets the preset scene switching conditions. As can be seen from the above, this application, for any target video frame in a target vertical short drama video, first divides the vertical screen into target gradient regions using a preset gradient weight strategy and assigns weight coefficients to macroblocks in each target gradient region. Then, after downsampling the target video frame, it calculates the luminance and chrominance component SATD values ​​of the macroblocks. Combining a preset weighted cost formula with the weight coefficients, it calculates the weighted cost value of each macroblock, thereby obtaining the target video frame as two types of full-frame costs: P-frame and I-frame. Based on the full-frame costs, it calculates the scene switching score of the target video frame to determine whether the frame meets the scene switching conditions. In this way, through the above process of this application, by adapting gradient weights to vertical screen features and combining multi-dimensional cost calculation including chrominance component SATD values, it accurately identifies scene switching, improves the accuracy and adaptability of scene switching determination in vertical short drama encoding, and optimizes the x264 encoder scene switching detection method to improve the scene switching detection accuracy of vertical short drama videos. Attached Figure Description

[0015] 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 embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0016] Figure 1 This application discloses a flowchart of a scene switching detection method using an x264 encoder for vertical short drama videos. Figure 2 This is a schematic diagram of the x264 encoder scene switching detection device for vertical short drama videos disclosed in this application; Figure 3 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0017] 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 embodiments of the present invention, and not all embodiments. 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.

[0018] Existing general algorithms, based on uniform weighting across the entire image and brightness-dominated design, suffer from the following pain points in vertical short-form video scenarios: Misjudgment of bottom interference: Many short-form videos and live streams have large, high-frequency dynamically changing subtitles, scrolling comments, or exchange buttons superimposed in the bottom 15%-25% area of ​​the screen. This high-contrast dynamic content causes drastic fluctuations in the SATD value. Traditional algorithms are highly susceptible to this interference, mistakenly identifying scene transitions and leading to incorrect insertion of IDR frames: disrupting the GOP structure and causing a surge in bitrate; Breathing effect: Unnecessary I-frames reset the reference relationship, causing periodic sharpness jumps in the background image; Missed detection of chroma changes: The default is based on brightness, while short-form videos often use high-saturation filters or abrupt color changes to switch shots, such as color-to-black-and-white transitions or warm / cool color transitions. These transitions have a high degree of similarity in brightness structure, with only significant differences in chroma. Existing algorithms in x264 are prone to missing these changes, resulting in transition color block artifacts. Visual salience mismatch: The main subjects of vertical videos, such as tasks and actions, are concentrated in the upper middle part of the screen. Traditional algorithms give equal weight to the edges and center of the screen, which does not conform to the human visual focus characteristics of vertical short dramas.

[0019] To overcome the aforementioned technical problems, this application provides an x264 encoder scene switching detection method for vertical short drama videos, which can optimize the x264 encoder scene switching detection method to improve the scene switching detection accuracy of vertical short drama videos.

[0020] See Figure 1 As shown, this embodiment of the invention discloses a scene switching detection method for x264 encoders in vertical short drama videos, including: Step S11: Using a preset gradient weight strategy, the vertical screen of the target video frame is divided into target gradient regions, and corresponding weight coefficients are assigned to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video.

[0021] In this embodiment, for any target video frame in the target vertical short drama video, a preset gradient weight strategy is used to divide the vertical screen of the video frame into target gradient regions, and a corresponding weight coefficient is assigned to the macroblocks in each target gradient region.

[0022] Understandably, x264's native scene switching detection mechanism primarily determines the scene by calculating the absolute error and cost of inter-frame pixel blocks at half resolution. The logic is as follows: downsample the input frame; calculate the cost (Cost_P) of the current frame as a P-frame (Predictive Frame) and the cost (Cost_I) as an I-frame; if 1 - (Cost_P / Cost_I) < threshold, it is determined to be a scene switch, and an I-frame / IDR frame is inserted. Existing general algorithms are based on uniform weighting of the entire image and brightness-dominated design, which suffers from pain points such as misjudgment of bottom interference, missed detection of chroma changes, and visual saliency mismatch in vertical short drama scenes. Therefore, this application proposes a scene switching detection method for x264 encoders for vertical short drama videos. In the slicetype (frame type) decision stage of x264 (Lookahead module), a region-weighted mask and chroma joint decision mechanism are introduced, specifically including spatial weighting of static regions and dynamic subtitle areas: reducing the weight of the bottom subtitle area and increasing the weight of the upper middle main body area. Introducing Chromaticity SATD Cost: When calculating inter-frame differences, the variation of U / V (chroma) components is taken into account. It should be noted that the scene transition detection method for vertical short drama videos in this application mainly involves the optimization of scene transition detection algorithms based on the H.264 / AVC (Advanced Video Coding) standard (x264 implementation), especially the encoding optimization for vertical short dramas and micro-dramas, to solve the problems of misjudgment and missed judgment in scene transition detection in vertical short drama videos with dynamic subtitles, product cards, or interactive components superimposed at the bottom of the screen.

[0023] It should be noted that the process of dividing the vertical screen of the target video frame into target gradient regions using a preset gradient weight strategy is as follows: The screen height of the vertical screen of the target video frame is determined, and the top left corner of the vertical screen is taken as the origin. Within the screen height, the vertical screen is divided into a first target gradient region, a second target gradient region, and a third target gradient region according to the corresponding vertical coordinate values. Wherein, any vertical coordinate value of the first target gradient region is less than any vertical coordinate value of the second target gradient region, and any vertical coordinate value of the second target gradient region is less than any vertical coordinate value of the third target gradient region. That is, in order to balance anti-subtitle interference and natural screen transition, this embodiment uses a preset gradient weight strategy to construct a vertical screen saliency weight mask before downsampling and calculating SATD in x264: Using the top left corner of the vertical screen as the origin, the target video frame is divided from top to bottom into a first target gradient region, a second target gradient region where any vertical coordinate value is greater than that of the first target gradient region, and a third target gradient region where any vertical coordinate value is greater than that of the second target gradient region, based on the screen height and the corresponding vertical coordinate values. Specifically, let the height of the input video be H and the vertical coordinate be y. In this embodiment, the image is divided into three regions and assigned different weight coefficients. Among them, the first target gradient region, namely the main body region ( ), its range is from 0% to 60% at the top ( This region is the core area of ​​human vision; the second target gradient region is the attenuation over-gradient region. ), its range is 60% to 80% ( The third target gradient region, i.e., the anti-interference region ( ), its range is the bottom 20%.

[0024] It should be further noted that the process of assigning corresponding weight coefficients to macroblocks in each of the target gradient regions is as follows: A first weight coefficient is assigned to macroblocks in the first target gradient region, and a second weight coefficient is assigned to macroblocks in the third target gradient region; the second weight coefficient is lower than the first weight coefficient; based on the vertical coordinate values, corresponding weight coefficients are assigned to macroblocks in the second target gradient region; the vertical coordinate values ​​of each macroblock in the second target gradient region are negatively correlated with the weight coefficients; the weight coefficients of each macroblock in the second target gradient region are all within the target weight coefficient range; the target weight coefficient range is composed of the first weight coefficient and the second weight coefficient. That is, weight coefficients are assigned differently to macroblocks in the three target gradient regions divided in the vertical screen image, with a higher first weight coefficient assigned to macroblocks in the first target gradient region. (e.g., 1.2), serving as the core region of human vision; assigning a lower second weight coefficient to macroblocks in the third target gradient region. (e.g., 0.3) If there are subtitles, the weight of this area can effectively shield subtitle interference; if there are no subtitles, this weight can guide the encoder to ignore drastic changes in the lower vertical screen area, which is not of primary human visual interest. Macroblocks in the second target gradient region are assigned weights based on their vertical coordinate values, with higher vertical coordinate values ​​resulting in lower weight coefficients. Their weights are all within the range formed by the first and second weight coefficients, i.e., the weights... from linearly decreasing to To prevent judgment jitter caused by objects crossing area boundaries, the specific formula for calculating the weight coefficients of different areas in a portrait-oriented scene is as follows: ; in, The weighting coefficients that characterize macroblocks with vertical coordinate y; Characterizes the first weighting coefficient; Characterizes the second weighting coefficient; The weight coefficients of macroblocks in the second target gradient region are represented. In this way, before x264 performs downsampling to calculate SATD, this embodiment uses a gradient weighting strategy to reduce the SATD weight of the bottom subtitle area. This prevents the encoder from incorrectly inserting I-frames due to subtitle jumps and eliminates the background "breathing" effect caused by incorrect GOP division. It balances anti-subtitle interference with natural screen transitions, highlighting the importance of key areas in vertical screen images, aligning with the visual attention characteristics of vertical screen images, accurately distinguishing the importance of macroblocks in different regions, and providing a weight basis that fits actual visual perception for cost calculation of subsequent video frames. Optimized for the physical characteristics of vertical 9:16 screens, it is more suitable for vertical short dramas than the general x264 algorithm.

[0025] Step S12: Downsample the target video frame to obtain the corresponding processed frame data, and calculate the SATD value of each macroblock based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value.

[0026] In this embodiment, the target video frame is downsampled to obtain processed frame data, and the SATD value of each macroblock containing luminance and chrominance components is calculated accordingly.

[0027] It should be noted that any of the SATD values ​​includes a first SATD value and a second SATD value; the first SATD value is the SATD value when the target video frame is a P-frame; the second SATD value is the SATD value when the target video frame is an I-frame. That is, the native scene transition detection mechanism of x264 is based on the cost of the current frame being a P-frame and the cost of it being an I-frame. Therefore, it is necessary to calculate the first SATD value of each macroblock when the target video frame is a P-frame and the second SATD value of each macroblock when the target video frame is an I-frame. In this way, this embodiment incorporates the change in chroma components when calculating inter-frame differences, improving the quality of scenes with sudden color changes and enhancing the accuracy of subsequent scene transition determination.

[0028] Step S13: Determine the weighted cost value of each macroblock according to the preset weighted cost calculation formula and using the SATD value and the weight coefficient, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame.

[0029] In this embodiment, the weighted cost of each macroblock is calculated using the SATD value and the weighting coefficient through a preset weighted cost formula, thereby obtaining the first full-frame cost and the second full-frame cost when the target video frame is a P-frame and an I-frame.

[0030] It should be noted that the process for determining the weighted cost value is as follows: The target weight coefficient, target luminance component SATD value, and target chrominance component SATD value of the target macroblock are determined, and a first sum among the target chrominance component SATD values ​​is determined; the product of the first sum and a preset chrominance sensitivity coefficient is determined, and a second sum among the product and the target luminance component SATD value is determined; the product of the second sum and the target weight coefficient is determined as the weighted cost value of the target macroblock. That is, while the original x264 only calculates the luminance component SATD value, this embodiment modifies the original weighted cost calculation formula by introducing the chrominance component SATD value. Based on the target weight coefficient, target luminance component SATD value, and target chrominance component SATD value of the target macroblock, the first sum of the target chrominance component SATD values ​​is calculated, and the product of this sum and the preset chrominance sensitivity coefficient is added to the target luminance component SATD value. Finally, the product is multiplied by the target weight coefficient to obtain the weighted cost value of the target macroblock. The specific preset weighted cost calculation formula is as follows: ; in, For macroblock indexes, Let be the vertical coordinates of the target macroblock. The weighted cost of the target macroblock; For the preset color sensitivity coefficient, considering the high saturation characteristics of short dramas, it is recommended to... The value range is from 0.5 to 0.8, with a default value of 0.5; It is the sum of absolute differences of the Hadamard transform of the luminance plane after downsampling, which is also the SATD value of the target luminance component; It is the sum of absolute differences of the chromaticity plane Hadamard transform after downsampling, which is also the target chromaticity component SATD value.

[0031] It should be noted that the process of determining the weighted cost value of each macroblock according to the preset weighted cost calculation formula and using the SATD value and the weight coefficient is as follows: The first weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the first SATD value and the weight coefficient; the second weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the second SATD value and the weight coefficient; wherein, the first weighted cost value is the weighted cost value when the target video frame is a P-frame; the second weighted cost value is the weighted cost value when the target video frame is an I-frame. That is, the first weighted cost value and the second weighted cost value of each macroblock under the conditions of the target video frame being a P-frame and an I-frame are calculated according to the preset weighted cost formula using the first SATD value, the second SATD value, and the corresponding weight coefficient, respectively.

[0032] It should be further noted that the processing flow for determining the full-frame cost of the target video frame based on the weighted cost values ​​is as follows: the third sum of the first weighted cost values ​​is determined as the first full-frame cost of the target video frame; the fourth sum of the second weighted cost values ​​is determined as the second full-frame cost of the target video frame. That is, the first weighted cost values ​​of all macroblocks are summed to obtain the first full-frame cost of the target video frame as a P-frame. The target video frame is obtained by summing the second weighted cost and using it as the second full-frame cost corresponding to the I-frame. The specific formula for calculating the full-frame cost is as follows: ; in, The full-frame cost is represented by ∑; summation is represented by ∑. The target video frame is represented. In this way, this embodiment introduces chroma SATD cost, which solves the problem of missed keyframes caused by rapid filter switching in short dramas, eliminates color block blurring during transitions, improves the quality of color abrupt scene changes and the accuracy of cost assessment, and achieves cost aggregation from macroblocks to entire frames, providing a stable frame-level quantization index for scene switching determination.

[0033] Step S14: Determine the scene switching score of the target video frame through the full frame cost, and determine whether the target video frame meets the preset scene switching conditions based on the scene switching score.

[0034] In this embodiment, the standard decision logic of x264 is maintained. The scene switching score of the target video frame is calculated based on the full frame cost, which includes spatial and chroma weighting. The scene switching score is then used to determine whether the target video frame meets the preset scene switching conditions.

[0035] Specifically, the ratio between the first full-frame cost and the second full-frame cost is determined, and the difference between this ratio and the given value is determined as the scene switching score of the target video frame. The scene switching score is compared with a preset score threshold to obtain a corresponding comparison result. If the comparison result indicates that the scene switching score is less than the preset score threshold, the target video frame is determined to meet the preset scene switching conditions. If the comparison result indicates that the scene switching score is not less than the preset score threshold, the target video frame is determined not to meet the preset scene switching conditions. That is, the ratio between the first full-frame cost and the second full-frame cost is first calculated, and the scene switching score of the target video frame is obtained by subtracting this ratio from the given value. The specific formula for calculating the scene switching score is as follows: ; in, The scene transition score is used to characterize the scene transition. After obtaining the scene transition score, the score is compared with a preset score threshold: if the score is less than the threshold, then... If the preset scene switching conditions are met, the target video frame is an IDR frame; otherwise, the conditions are not met. This is the judgment threshold calculated by the `scenecut_internal` function (a built-in private function under the Lookahead module of the x264 encoder) in x264. In this way, the algorithm in this embodiment only modifies the cost calculation method in the Lookahead stage, achieving accurate and automated judgment of scene switching in vertical short dramas while reducing computational complexity, making it suitable for large-scale cloud transcoding deployment.

[0036] As can be seen from the above, this application embodiment targets any target video frame in a vertical short drama video. First, it divides the vertical screen into target gradient regions using a preset gradient weight strategy and assigns weight coefficients to macroblocks within each target gradient region. Then, after downsampling the target video frame, it calculates the luminance and chrominance component SATD values ​​of the macroblocks. Combining a preset weighted cost formula with the weight coefficients, it calculates the weighted cost value of each macroblock, thereby obtaining the target video frame as both a P-frame and an I-frame full-frame cost. Based on the full-frame cost, it calculates the scene switching score of the target video frame to determine whether the frame meets the scene switching conditions. In this way, through the above process of this application embodiment, by adapting gradient weights to vertical screen features and combining multi-dimensional cost calculation including chrominance component SATD values, it accurately identifies scene switching, improving the accuracy and adaptability of scene switching determination in vertical short drama encoding. This optimizes the x264 encoder scene switching detection method, thereby improving the scene switching detection accuracy of vertical short drama videos.

[0037] Accordingly, see Figure 2 As shown in the figure, this application embodiment also provides an x264 encoder scene switching detection device for vertical short drama videos, including: The coefficient allocation module 11 is used to divide the vertical screen of the target video frame into target gradient regions using a preset gradient weight strategy, and to allocate corresponding weight coefficients to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video. The value calculation module 12 is used to downsample the target video frame to obtain corresponding processed frame data, and calculate the SATD value of each macroblock based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value. The cost value determination module 13 is used to determine the weighted cost value of each macroblock according to a preset weighted cost calculation formula and using the SATD value and the weight coefficient, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame. The condition determination module 14 is used to determine the scene switching score of the target video frame through the full frame cost, and to determine whether the target video frame meets the preset scene switching conditions based on the scene switching score.

[0038] In some specific embodiments, the coefficient allocation module 11 may specifically include: The region division unit is used to determine the screen height of the vertical screen of the target video frame, and with the upper left corner of the vertical screen as the origin of the coordinates, divides the vertical screen into a first target gradient region, a second target gradient region and a third target gradient region within the screen height according to the corresponding vertical coordinate values. Wherein, any vertical coordinate value of the first target gradient region is less than any vertical coordinate value of the second target gradient region, and any vertical coordinate value of the second target gradient region is less than any vertical coordinate value of the third target gradient region.

[0039] In some specific embodiments, the coefficient allocation module 11 may specifically include: The first coefficient allocation unit is used to allocate a first weight coefficient to macroblocks in the first target gradient region and allocate a second weight coefficient to macroblocks in the third target gradient region; the second weight coefficient is lower than the first weight coefficient. The second coefficient allocation unit is used to allocate corresponding weight coefficients to macroblocks in the second target gradient region according to their vertical coordinate values; the vertical coordinate values ​​of each macroblock in the second target gradient region are negatively correlated with the weight coefficients; the weight coefficients of each macroblock in the second target gradient region are all within the target weight coefficient range; the target weight coefficient range is composed of the first weight coefficient and the second weight coefficient.

[0040] In some specific embodiments, the cost determination module 13 may specifically include: The first sum determination unit is used to determine the target weight coefficient, target luminance component SATD value, and target chrominance component SATD value of the target macroblock, and to determine the first sum value among the target chrominance component SATD values; The second sum determination unit is used to determine the product between the first sum and the preset chromaticity sensitivity coefficient, and to determine the second sum between the product and the target luminance component SATD value; The first-generation value determination unit is used to determine the weighted value of the target macroblock by multiplying the second sum value and the target weight coefficient.

[0041] In some specific embodiments, any of the SATD values ​​includes a first SATD value and a second SATD value; the first SATD value is the SATD value when the target video frame is a P-frame; the second SATD value is the SATD value when the target video frame is an I-frame. Accordingly, the cost determination module 13 may specifically include: The second-generation value determination unit is used to determine the first weighted cost value of each macroblock according to the preset weighted cost calculation formula and by using the first SATD value and the weight coefficient. The third-generation value determination unit is used to determine the second weighted cost value of each macroblock according to the preset weighted cost calculation formula and by using the second SATD value and the weight coefficient. Wherein, the first weighted cost value is the weighted cost value when the target video frame is a P-frame; the second weighted cost value is the weighted cost value when the target video frame is an I-frame.

[0042] In some specific embodiments, the cost determination module 13 may specifically include: The first cost determination unit is used to determine the third sum between the first weighted cost values ​​as the first full frame cost of the target video frame. The second cost determination unit is used to determine the fourth sum between the second weighted cost values ​​as the second full-frame cost of the target video frame.

[0043] In some specific embodiments, the condition determination module 14 may specifically include: The scoring determination unit is used to determine the ratio between the first full-frame cost and the second full-frame cost, and to determine the difference between the ratio and the target video frame as the scene switching score; The scoring comparison unit is used to compare the scene switching score with a preset scoring threshold to obtain the corresponding comparison result; The first condition determination unit is used to determine that the target video frame meets the preset scene switching condition if the comparison result indicates that the scene switching score is less than the preset score threshold. The second condition determination unit is used to determine that the target video frame does not meet the preset scene switching condition if the comparison result indicates that the scene switching score is not less than the preset score threshold.

[0044] Furthermore, embodiments of this application also disclose an electronic device, Figure 3This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the x264 encoder scene switching detection method for vertical short-form video disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be a computer.

[0045] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0046] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0047] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the x264 encoder scene switching detection method for vertical short video dramas executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0048] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed x264 encoder scene switching detection method for vertical short drama videos. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0049] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0050] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0051] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0052] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0053] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for scene switching detection using an x264 encoder for vertical short drama videos, characterized in that, include: Using a preset gradient weighting strategy, the vertical screen of the target video frame is divided into target gradient regions, and corresponding weight coefficients are assigned to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video. The target video frame is downsampled to obtain corresponding processed frame data, and the SATD value of each macroblock is calculated based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value. According to the preset weighted cost calculation formula and using the SATD value and the weight coefficient, the weighted cost value of each macroblock is determined, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame. The scene switching score of the target video frame is determined by the full frame cost, and the scene switching score is used to determine whether the target video frame meets the preset scene switching conditions.

2. The x264 encoder scene switching detection method for vertical short drama videos according to claim 1, characterized in that, The method of dividing the vertical screen image of the target video frame into target gradient regions using a preset gradient weight strategy includes: Determine the screen height of the vertical screen of the target video frame, and take the upper left corner of the vertical screen as the origin of the coordinate system. Within the screen height, divide the vertical screen into a first target gradient region, a second target gradient region, and a third target gradient region according to the corresponding vertical coordinate values. Wherein, any vertical coordinate value of the first target gradient region is less than any vertical coordinate value of the second target gradient region, and any vertical coordinate value of the second target gradient region is less than any vertical coordinate value of the third target gradient region.

3. The x264 encoder scene switching detection method for vertical short drama videos according to claim 2, characterized in that, Assigning corresponding weight coefficients to macroblocks in each of the target gradient regions includes: A first weight coefficient is assigned to macroblocks in the first target gradient region, and a second weight coefficient is assigned to macroblocks in the third target gradient region; the second weight coefficient is lower than the first weight coefficient. Based on the vertical coordinate values, corresponding weight coefficients are assigned to macroblocks in the second target gradient region; the vertical coordinate values ​​of each macroblock in the second target gradient region are negatively correlated with the weight coefficients; the weight coefficients of each macroblock in the second target gradient region are all within the target weight coefficient range; the target weight coefficient range is composed of the first weight coefficient and the second weight coefficient.

4. The x264 encoder scene switching detection method for vertical short drama videos according to claim 1, characterized in that, The process of determining the weighted cost value includes: Determine the target weight coefficient, target luminance component SATD value, and target chrominance component SATD value of the target macroblock, and determine the first sum value among the target chrominance component SATD values; Determine the product between the first sum and the preset chromaticity sensitivity coefficient, and determine the second sum between the product and the target luminance component SATD value; The product of the second sum and the target weight coefficient is determined as the weighted cost of the target macroblock.

5. The x264 encoder scene switching detection method for vertical short drama videos according to claim 1, characterized in that, Any of the SATD values ​​includes a first SATD value and a second SATD value; the first SATD value is the SATD value when the target video frame is a P-frame; the second SATD value is the SATD value when the target video frame is an I-frame. Accordingly, determining the weighted cost value of each macroblock according to the preset weighted cost calculation formula and using the SATD value and the weight coefficient includes: The first weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the first SATD value and the weight coefficient. The second weighted cost value of each macroblock is determined according to the preset weighted cost calculation formula and using the second SATD value and the weight coefficient. Wherein, the first weighted cost value is the weighted cost value when the target video frame is a P-frame; the second weighted cost value is the weighted cost value when the target video frame is an I-frame.

6. The x264 encoder scene switching detection method for vertical short drama videos according to claim 5, characterized in that, The determination of the full-frame cost of the target video frame based on the weighted cost value includes: The third sum between the first weighted cost values ​​is determined as the first full-frame cost of the target video frame; The fourth sum between the second weighted cost values ​​is determined as the second full-frame cost of the target video frame.

7. The x264 encoder scene switching detection method for vertical short drama videos according to any one of claims 1 to 6, characterized in that, The step of determining the scene switching score of the target video frame through the full-frame cost, and determining whether the target video frame meets the preset scene switching conditions based on the scene switching score, includes: Determine the ratio between the first full-frame cost and the second full-frame cost, and determine the difference between the first and the second full-frame cost as the scene switching score of the target video frame; The scene switching score is compared with a preset score threshold to obtain the corresponding comparison result; If the comparison result indicates that the scene switching score is less than the preset score threshold, then the target video frame is determined to meet the preset scene switching conditions. If the comparison result indicates that the scene switching score is not less than the preset score threshold, then the target video frame is determined not to meet the preset scene switching conditions.

8. A scene switching detection device for an x264 encoder for vertical short drama videos, characterized in that, include: The coefficient allocation module is used to divide the vertical screen of the target video frame into target gradient regions using a preset gradient weight strategy, and to assign corresponding weight coefficients to macroblocks in each target gradient region; the target video frame is any video frame in the target vertical short drama video. The value calculation module is used to downsample the target video frame to obtain the corresponding processed frame data, and calculate the SATD value of each macroblock based on the processed frame data; the SATD value includes the luminance component SATD value and the chrominance component SATD value. The cost value determination module is used to determine the weighted cost value of each macroblock according to a preset weighted cost calculation formula and using the SATD value and the weight coefficient, so as to determine the full frame cost of the target video frame based on the weighted cost value; the full frame cost includes the first full frame cost when the target video frame is a P frame and the second full frame cost when it is an I frame. The condition determination module is used to determine the scene switching score of the target video frame through the full frame cost, and to determine whether the target video frame meets the preset scene switching conditions based on the scene switching score.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor is configured to execute the computer program to implement the x264 encoder scene switching detection method for vertical short drama videos as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the x264 encoder scene switching detection method for vertical short drama videos as described in any one of claims 1 to 7.