CN-121985189-A - Self-adaptive video watermarking method based on Web front end
Abstract
The invention discloses a self-adaptive video watermarking method based on a Web front end. The method comprises the steps of establishing a standardized percentage coordinate system based on a video effective area, obtaining a preview canvas size and a device pixel ratio DPR, executing rendering precision compensation calculation to generate a vectorization logic component, sensing transparency in real time, triggering self-adaptive visual enhancement assistance based on background brightness contrast when a threshold value is met, capturing an interaction instruction, updating a proportion parameter in real time based on bidirectional mapping, and executing boundary clamping deviation correction. An atomized attribute stripping is performed in response to the save instruction to restore the original visual attributes and generate a structured configuration information stream. According to the invention, through the DPR compensation and threshold perception visualization means, engineering pain points such as geometric distortion of heterogeneous resolution, difficult interaction of high transparent watermarks, fuzzy cross-end display and the like are solved, and watermark positioning accuracy, editing interaction efficiency and cross-platform visual consistency are remarkably improved.
Inventors
- FENG ZHIYUAN
- Ding Guangce
- ZHANG BINGYU
- ZHANG XIAOLEI
- WANG XIAOWEI
- LI HAO
- SUN NAN
- ZHENG XIAOBO
- ZOU MINGSONG
Assignees
- 杭州阿启视科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260408
Claims (10)
- 1. A self-adaptive video watermarking method based on a Web front end is characterized by comprising the following steps: Establishing a standardized two-dimensional percentage coordinate system based on a video effective content area, wherein geometric attributes of watermarks are expressed by proportional parameters relative to the size of the video effective content area; In response to a visual editing instruction for a target watermark in a target video with original video resolution, acquiring a physical pixel size of a current preview canvas and a device pixel ratio DPR of a display terminal, and executing rendering precision compensation calculation based on the device pixel ratio to generate a corresponding vectorization logic component in the preview canvas; Sensing transparency parameters of the vectorization logic component in real time, triggering a visualization enhancement mechanism when the transparency parameters meet a preset auxiliary display threshold value, and superposing an auxiliary frame and an auxiliary background color for the vectorization logic component, wherein the color of the auxiliary frame is adaptively adjusted based on an average brightness value of a picture of an area covered by the vectorization logic component so as to realize accurate positioning of a high-transparency watermark in an interaction stage; capturing an interaction instruction aiming at the vectorization logic component, updating the standardized two-dimensional percentage coordinate system in real time based on a bi-directional coordinate mapping algorithm, and executing dynamic deviation correction according to a boundary clamping rule so as to lock the geometric edge of the vectorization logic component in the video effective content area; And responding to a save instruction, executing an atomization attribute stripping operation, and forcibly removing the auxiliary frame and the auxiliary background color while extracting the proportion parameters to generate structural configuration information so as to restore the original visual attribute of the watermark and ensure that the generated structural configuration information is decoupled from the video resolution.
- 2. The method of claim 1, wherein performing rendering precision compensation calculations based on the device pixel ratios comprises performing physical pixel alignment compensation for the vectorized logic component with the device pixel ratios, the calculation formula satisfying: , wherein, To render the coordinates for the compensated alignment, As a function of the said ratio parameter(s), The physical side length of the preview canvas; rendering edge distortion of the preview canvas under heterogeneous pixel per inch PPI screens is eliminated by the physical pixel alignment compensation.
- 3. The method of claim 1, further comprising a polymorphic anchor point locating process based on a nine-grid distribution: Configuring a corresponding logic anchor point for the vectorization logic component; and when the aspect ratio of the video picture is changed, locking relative reference bits of the vectorization logic component in the standardized two-dimensional percentage coordinate system according to the logic anchor point so as to inhibit watermark center position drift.
- 4. The method of claim 1, wherein the auxiliary border color adaptation in the visualization enhancement mechanism comprises: Calculating the average gray value of the video picture below the vectorization logic component in real time; And if the average gray value is lower than or equal to the preset brightness threshold value, configuring the color of the auxiliary frame as a light color system.
- 5. The method of claim 1, wherein the boundary clamping rules include coordinate range logic for horizontal and vertical directions: If the sum of the horizontal proportion parameter and the width proportion parameter is larger than a preset full value, the horizontal proportion parameter is kept unchanged, and the width proportion parameter is reset to be the difference between the preset full value and the horizontal proportion parameter; and in the vertical direction, if the vertical proportion parameter is smaller than zero, the vertical proportion parameter is forcedly reset to zero, and if the sum of the vertical proportion parameter and the height proportion parameter is larger than the preset full value, the vertical proportion parameter is kept unchanged, and the height proportion parameter is reset to the difference between the preset full value and the vertical proportion parameter.
- 6. The method of claim 5, wherein the dynamic correction further comprises a minimum visual scale hard constraint: verifying the width proportion parameter and the height proportion parameter of the vectorization logic component in real time; and if any scaling parameter is lower than a preset minimum scaling threshold, blocking the current scaling instruction.
- 7. The method of claim 1, further comprising a heterogeneous resolution mapping procedure: receiving a switching instruction aiming at target preview resolution, re-initializing the preview canvas and extracting the proportion parameters in the structural configuration information; And performing scaling adaptation according to a short-side priority principle, namely performing equal-proportion mapping on the vectorization logic component according to a side length proportion with smaller scaling magnification in the target preview resolution, and maintaining the relative position ratio of the vectorization logic component in the standardized two-dimensional percentage coordinate system unchanged.
- 8. The method of claim 7, wherein the heterogeneous resolution mapping process further comprises shape fidelity based anisometric distortion compensation logic: Obtaining an original aspect ratio of the vectorization logic component at the original video resolution; When the aspect ratio of the target preview resolution is changed relative to the original video resolution, dynamically correcting the width scale parameter or the height scale parameter in the standardized two-dimensional percentage coordinate system by calculating the scaling weight of the preview canvas in the length direction of the corresponding edge, so that the target watermark maintains the original aspect ratio after cross-resolution mapping.
- 9. The method of claim 1, wherein the watermark type comprises at least one of a text watermark, a rectangular watermark, and a picture watermark; if the character watermark is the character watermark, the method further comprises the steps of performing vectorization scaling of the font size based on the standardized two-dimensional percentage coordinate system, and recording rotation angle metadata of the character watermark in real time.
- 10. The method of claim 1, further comprising responsive redraw monitoring based on a viewport listening interface: When the size of the display viewport is dynamically changed, triggering a redrawing process in real time and reapplying the bidirectional coordinate mapping algorithm to keep the absolute consistency of the watermark display proportion in the preview canvas and the proportion parameter in the structural configuration information.
Description
Self-adaptive video watermarking method based on Web front end Technical Field The invention relates to the technical field of video processing and Web front end development, in particular to a self-adaptive video watermarking method based on a Web front end. Background The Web front-end video watermarking technology refers to a technical means for realizing copyright protection, brand propaganda or information identification by superposing a specific identification (such as characters, rectangles or pictures) in a video picture. With the diversification of display terminals and the popularization of video applications, video resolution exhibits a significant difference from standard definition, quasi-high definition to ultra-high definition (e.g., 1080P, 4K, etc.). The realization of adaptive display of watermarks in heterogeneous resolution environments has become a core technical requirement in the field of front-end development. At present, the Web front-end video watermarking technology mainly adopts the following schemes: 1. Fixed pixel coordinate positioning methods-positioning in video pictures using fixed pixel physical coordinates (px) and physical width height. The method is simple to realize, but the relative position of the watermark and the occupied picture proportion can be changed drastically under different resolutions. 2. CSS positioning method-positioning watermark elements using absolute or relative positioning of CSS. While supporting partial percentage values, they often lack complete interactive editing logic, which makes it difficult to support complex dynamic transformations. 3. Canvas rendering method-watermark is directly rendered on video frames by CANVASAPI. This approach is still typically based on fixed pixel coordinate calculations, without the ability to adapt across resolutions. The above scheme works well in a scene with fixed resolution, but when the same watermark configuration is applied to heterogeneous resolution video (such as video transcoding or cross-device playing), since the watermark highly depends on fixed physical pixels, the relative position offset or proportional distortion of the watermark can be caused, and the consistency of visual effects can not be maintained. Specifically, the prior art reveals the following technical drawbacks in practical applications: 1. The cross-resolution adaptation is poor and the shape is distorted-traditional localization schemes are highly dependent on physical pixels, and watermark positions can shift unevenly when video resolution is switched (e.g., 1920 x 1080 to 720 x 480). Especially in the case of sharp aspect ratio changes (e.g. 16:9 to 4:3), the watermark tends to undergo significant shape distortion as the coordinate axes stretch due to the lack of geometric distortion compensation. 2. The cross-device rendering definition is different, the Web front-end running environment is complex, and the Device Pixel Ratio (DPR) of different terminals (such as a common screen and a Retina high split screen) has huge difference. The existing percentage scheme does not consider sub-pixel alignment during Canvas rendering, so that the problem of rendering precision such as edge blurring, blurring and the like of watermarks under different PPI screens is often caused. 3. The high-transparency watermark editing interaction is difficult, namely, under the scene requiring the high-transparency watermark, the watermark is hardly visible in an editing state due to the lack of a visual auxiliary enhancement mechanism, and the user is difficult to accurately adjust. 4. The conventional visual editing tool is used for solving the problem of visibility, an auxiliary layer is often added on a component, but due to lack of an atomized attribute stripping mechanism, temporary auxiliary frames or background colors are extremely easy to remain and write back into persistent configuration data, so that production environment data is impure. 5. The risks of the interactive editing, the data disjointing and the boundary crossing are that a unified and reversible mapping algorithm is lacking, and in the complex interaction of zooming, rotation and the like, strict boundary crossing deviation rectifying logic is lacking, so that watermark part pictures are easy to exceed video boundaries. In summary, how to construct a set of adaptive system integrating proportional mapping, rendering precision compensation, geometric fidelity and atomization attribute control in the Web front-end environment is a technical problem to be solved in the current urgent need. Disclosure of Invention The invention aims to provide a self-adaptive video watermarking method based on a Web front end, which aims to overcome the defects of position offset, shape stretching distortion during aspect ratio switching, rendering edge blurring under heterogeneous screens, invisible high transparent watermark editing, auxiliary information pollution production data and the like caus