Video watermark generation method and apparatus, medium, electronic device, and program product
Patent Information
- Application Number
- CN202510565365.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2026-10-30
AI Technical Summary
其中,视频中的水印是预先生成的,水印的大小和位置固定,可能无法与视频帧的尺寸相适配,例如,水印过大可能会造成视觉干扰,水印过小会降低水印的标识作用,从而影响视频质量
[0019]在上述技术方案中,首先,根据视频中的至少一个视频帧的第一尺寸,确定视频的水印参数的基准值,其中,水印参数包括水印画布的第二尺寸、水印的第三尺寸以及水印在水印画布中的位置偏移量;然后,针对至少一个视频帧中的每个视频帧,根据该视频帧的第一尺寸和水印画布的第二尺寸,确定第一缩放比,并将水印参数的基准值按照第一缩放比进行缩放;最后,基于缩放后的基准值,生成该视频帧的水印。其中,基于各视频帧的尺寸,计算一次水印参数的基准值即可,后续各视频帧的水印参数可以在该基准值的基础上,根据视频帧的尺寸进行缩放,以生成与该视频帧的尺寸相适配的水印,这样,可以减少内存的占用和计算复杂度,提升视频水印的生成效率。另外,各视频帧中的水印与该视频帧的尺寸相适配,可以避免水印过大导致的视觉干扰,还可以避免水印过小导致的标识作用降低,从而可以在不干扰视频内容的前提下,清晰地标识视频的所有权或来源,以提升视频质量。
Smart Images

Figure CN123020923A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of video processing technology, specifically to a video watermark generation method, apparatus, medium, electronic device, and program product. Background Technology
[0002] In video-based social applications, when editing videos, such as Figure 1 As shown, you can save the video with a watermark to your local device. When publishing a video, as shown... Figure 2 As shown, when publishing a video, you can also choose to save a watermarked copy to your local device. The watermark in the video is pre-generated, and its size and position are fixed. This may not be compatible with the video frame size; for example, a watermark that is too large may cause visual interference, while a watermark that is too small will reduce its identifying effect, thus affecting video quality. Summary of the Invention
[0003] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] Firstly, this disclosure provides a method for generating video watermarks, including:
[0005] A reference value for the watermark parameters of the video is determined based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas.
[0006] For each video frame in the at least one video frame, a first scaling ratio is determined based on the first size and the second size of the video frame;
[0007] The baseline value of the watermark parameter is scaled according to the first scaling ratio;
[0008] The watermark for this video frame is generated based on the scaled baseline value.
[0009] Secondly, this disclosure provides a video watermark generation apparatus, comprising:
[0010] A reference value determination module is used to determine a reference value for the watermark parameters of the video based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas.
[0011] A scaling ratio determination module is configured to determine a first scaling ratio for each video frame in the at least one video frame, based on the first size and the second size of the video frame;
[0012] The parameter scaling module is used to scale the baseline value of the watermark parameter according to the first scaling ratio;
[0013] The watermark generation module is used to generate a watermark for the video frame based on the scaled baseline value.
[0014] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the video watermark generation method provided in the first aspect of this disclosure.
[0015] Fourthly, this disclosure provides an electronic device, comprising:
[0016] A storage device on which computer programs are stored;
[0017] A processing device is configured to execute the computer program in the storage device to implement the steps of the video watermark generation method provided in the first aspect of this disclosure.
[0018] Fifthly, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the video watermark generation method provided in the first aspect of this disclosure.
[0019] In the above technical solution, firstly, a reference value for the watermark parameters is determined based on the first size of at least one video frame in the video. The watermark parameters include a second size of the watermark canvas, a third size of the watermark, and the positional offset of the watermark within the watermark canvas. Then, for each video frame in the at least one video frame, a first scaling ratio is determined based on the first size of the video frame and the second size of the watermark canvas, and the reference value of the watermark parameters is scaled according to the first scaling ratio. Finally, the watermark for that video frame is generated based on the scaled reference value. Since the reference value of the watermark parameters is calculated only once based on the size of each video frame, the watermark parameters for subsequent video frames can be scaled according to the size of the video frame based on this reference value to generate a watermark adapted to the size of that video frame. This reduces memory usage and computational complexity, improving the efficiency of video watermark generation. In addition, the watermark in each video frame is adapted to the size of that video frame, which can avoid visual interference caused by an overly large watermark, and also avoid the reduced identification effect caused by an overly small watermark. Thus, the ownership or source of the video can be clearly identified without interfering with the video content, thereby improving video quality.
[0020] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0021] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:
[0022] Figure 1 This is an exemplary embodiment illustrating how to save a watermarked video during video editing.
[0023] Figure 2 This is an illustration of a method for publishing a video while simultaneously saving the video with a watermark, according to an exemplary embodiment.
[0024] Figures 3A-3D This is a schematic diagram of video watermarking in related technologies.
[0025] Figure 4 This is a flowchart illustrating a video watermark generation method according to an exemplary embodiment.
[0026] Figure 5 This is a schematic diagram illustrating the positional offset of a watermark according to an exemplary embodiment.
[0027] Figures 6A-6D This is a schematic diagram illustrating a video watermark according to an exemplary embodiment.
[0028] Figure 7 This is a block diagram illustrating a video watermark generation apparatus according to an exemplary embodiment.
[0029] Figure 8 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation
[0030] As discussed in the background section, the watermarks in the video are pre-generated, and their size and position are fixed. They may not be able to fit the size of the video frames. For example, a watermark that is too large may cause visual interference, while a watermark that is too small will reduce the watermark's identifying function and thus affect the video quality.
[0031] like Figure 3AAs shown, the video includes three video frames of different sizes: video frame 11, video frame 12, and video frame 13. Video frame 11 is the smallest of the three video frames, video frame 12 has a width greater than its height, and video frame 13 has a width less than its height. Watermark 15 is a pre-generated watermark, and watermark canvas 14 is the virtual canvas where watermark 15 is located.
[0032] like Figure 3B As shown, the watermark 15 in video frame 11 is relatively large, which may cause visual interference; Figure 3C As shown, watermark 15 in video frame 12 is relatively to the right; as Figure 3D As shown, watermark 15 in video frame 13 is relatively far to the left.
[0033] In view of this, the present disclosure provides a video watermark generation method, apparatus, medium, electronic device and program product.
[0034] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0035] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0036] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0037] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0038] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0039] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0040] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0041] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0042] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0043] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0044] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0045] Figure 4 This is a flowchart illustrating a video watermark generation method according to an exemplary embodiment. Figure 4 As shown, the method may include the following S101 to S104.
[0046] In S101, a reference value for the watermark parameter of the video is determined based on the first size of at least one video frame in the video.
[0047] In this disclosure, the above method can be applied to terminals such as smartphones and tablets, as well as servers; this disclosure does not impose any specific limitations. Furthermore, the above video watermark generation method can be applied to scenarios where a video with a watermark is saved locally during video editing, or when publishing a video, where a copy of the watermarked video is saved locally at the same time, or even when publishing a video with a watermark.
[0048] In one implementation, the video may consist of multiple video segments or a single video segment, wherein the dimensions of each video frame in a single video segment are the same.
[0049] In another implementation, the video may consist of multiple images, wherein the images may all be the same size, partially the same size, or completely different size.
[0050] Furthermore, at least one video frame in the video is the video frame to be watermarked. All video frames in the video can be used as the watermarked frames, or only a portion of the video frames can be used, for example, watermarking can be added to frames with even-numbered sequences. The number of video frames to be watermarked can be one or more. When there are multiple video frames to be watermarked, these multiple video frames can include video frames of the same size (i.e., all video frames are the same size), or they can include video frames of multiple sizes. This disclosure does not impose specific limitations.
[0051] The first dimension may include a first width and a second height; that is, the first dimension of the video frame includes the first width and the first height of the video frame. The watermark parameters may include a second dimension of the watermark canvas, a third dimension of the watermark, and the positional offset of the watermark within the watermark canvas. The second dimension may include a second width and a second height, and the third dimension may include a third width and a third height. The watermark canvas may be a rectangular frame, and the positional offset of the watermark within the watermark canvas may include a horizontal offset and a vertical offset. The horizontal offset may be the horizontal distance of the watermark relative to the left or right border of the watermark canvas, and the vertical offset may be the vertical distance of the watermark relative to the bottom or top border of the watermark canvas.
[0052] like Figure 5 As shown, the positional offset of watermark 15 in watermark canvas 14 includes the horizontal distance d1 between watermark 15 and the right border of watermark canvas 14, and the vertical distance d2 between watermark 15 and the bottom border of watermark canvas 14.
[0053] In S102, for each video frame in at least one video frame, a first scaling ratio is determined based on the first size of the video frame and the second size of the watermark canvas.
[0054] In S103, the baseline value of the watermark parameter is scaled according to the first scaling ratio.
[0055] In this disclosure, the baseline value of the watermark parameters for the video serves as the adjustment baseline for the watermark parameters of subsequent video frames. For each video frame in at least one video frame, a first scaling ratio can be determined based on the first size of the video frame and the second size of the watermark canvas. Then, the baseline value of the watermark parameters is scaled according to the first scaling ratio so that the subsequently generated watermark is adapted to the size of the video frame. Scaled using the first scaling ratio on the baseline value of the watermark parameters, this is equivalent to scaling the watermark and watermark canvas corresponding to the baseline value of the watermark parameters as a whole according to the first scaling ratio.
[0056] In S104, a watermark for the video frame is generated based on the scaled baseline value.
[0057] In this disclosure, the watermark may be located in the lower right corner of the video frame (e.g., Figures 6A to 6D (As shown), the watermark can be located in the upper left corner, upper right corner, lower left corner, or in the center. This disclosure does not specify the exact location of the watermark.
[0058] For each video frame in at least one video frame, after scaling the reference value of the watermark parameter according to the first size of the video frame, a watermark adapted to the size of the video frame can be generated based on the scaled reference value, and the watermark can be added to the video frame.
[0059] Specifically, the reference values of the watermark parameters are scaled according to a first scaling ratio. This includes scaling the reference values of the second size of the watermark canvas, the third size of the watermark, and the position offset of the watermark within the watermark canvas according to the first scaling ratio. Then, the watermark for the video can be generated based on the scaled reference values of the second and third sizes and the scaled position offset.
[0060] In the above technical solution, firstly, a reference value for the watermark parameters is determined based on the first size of at least one video frame in the video. The watermark parameters include a second size of the watermark canvas, a third size of the watermark, and the positional offset of the watermark within the watermark canvas. Then, for each video frame in the at least one video frame, a first scaling ratio is determined based on the first size of the video frame and the second size of the watermark canvas, and the reference value of the watermark parameters is scaled according to the first scaling ratio. Finally, the watermark for that video frame is generated based on the scaled reference value. Since the reference value of the watermark parameters is calculated only once based on the size of each video frame, the watermark parameters for subsequent video frames can be scaled according to the size of the video frame based on this reference value to generate a watermark adapted to the size of that video frame. This reduces memory usage and computational complexity, improving the efficiency of video watermark generation. In addition, the watermark in each video frame is adapted to the size of that video frame, which can avoid visual interference caused by an overly large watermark, and also avoid the reduced identification effect caused by an overly small watermark. Thus, the ownership or source of the video can be clearly identified without interfering with the video content, thereby improving video quality.
[0061] The following is a detailed description of a specific implementation of S101 above, which involves determining the reference value of the video watermark parameter based on the first size of at least one video frame in the video. Specifically, this can be achieved through the following steps (a1) and (a2).
[0062] Step (a1): Determine the reference value of the second size of the watermark canvas based on the first size of at least one video frame.
[0063] Specifically, the maximum value of the first width of at least one video frame can be determined as the reference value of the second width of the watermark canvas, and the maximum value of the first height of at least one video frame can be determined as the reference value of the second height of the watermark canvas. This ensures that each video frame to be added falls within the watermark canvas, guaranteeing that the watermarks in subsequently generated video frames will not be offset due to different video frame sizes, such as being offset to the left, right, top, or bottom.
[0064] like Figure 6A As shown, the video includes three video frames of different sizes: video frame 11, video frame 12, and video frame 13. Video frame 11 is the smallest of the three video frames. The width of video frame 12 is greater than its height, and the width of video frame 13 is less than its height. The first width of video frame 12 is the maximum of the first widths of the three video frames, and the first height of video frame 13 is the maximum of the first heights of the three video frames. Therefore, the second width of the watermark canvas 14 is equal to the first width of video frame 12, and the second height of the watermark canvas 14 is equal to the first height of video frame 13.
[0065] Step (a2): Determine the reference value of the third dimension and the reference value of the position offset based on the reference value of the second dimension.
[0066] Specifically, the reference value of the third dimension and the reference value of the position offset can be determined based on the reference value of the second dimension through the following steps (a21) to (a23).
[0067] Step (a21): Obtain the preset values of the watermark parameters.
[0068] In this disclosure, the value of the watermark parameter can be preset, and the preset value of the watermark parameter is the preset value of the watermark parameter.
[0069] Step (a22): Determine the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension.
[0070] Step (a23): Scale the preset value of the third dimension using the second scaling ratio to obtain the reference value of the third dimension, and scale the preset value of the position offset using the second scaling ratio to obtain the reference value of the position offset.
[0071] In this disclosure, since the third dimension includes a third height and a third width, the preset values of the third dimension include preset values of the third height and the third width, and the reference values of the third dimension include reference values of the third height and the third width. Since the position offset includes horizontal and vertical offsets, the preset values of the position offset include preset values of the horizontal and vertical offsets, and the reference values of the position offset include reference values of the horizontal and vertical offsets.
[0072] Specifically, the product of the second scaling ratio and the preset value of the third width can be determined as the reference value of the third width, the product of the second scaling ratio and the preset value of the third height can be determined as the reference value of the third height, the product of the second scaling ratio and the preset value of the horizontal offset can be determined as the reference value of the horizontal offset, and the product of the second scaling ratio and the preset value of the vertical offset can be determined as the reference value of the vertical offset.
[0073] In the above implementation, the baseline values of the watermark parameters can be obtained through simple numerical calculations based on the size of each video frame to be watermarked, which is convenient and quick, thereby improving the watermark generation efficiency.
[0074] The following is a detailed description of the specific implementation method for determining the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension in step (a22) above. Specifically, it can be achieved through the following steps (a221) to (a225).
[0075] Step (a221): Calculate the first ratio of the reference value of the second width to the reference value of the second height, and the second ratio of the preset value of the second width to the preset value of the second height.
[0076] Step (a222): Determine whether the first ratio is greater than the second ratio.
[0077] In this disclosure, the first ratio is the aspect ratio of the watermarked canvas (referred to as watermarked canvas SY1) corresponding to the reference value of the second size, and the second ratio is the aspect ratio of the watermarked canvas (referred to as watermarked canvas SY2) corresponding to the preset value of the second size. If the first ratio is greater than the second ratio, it indicates that watermarked canvas SY1 is wider than watermarked canvas SY2. In this case, watermarked canvas SY2 can be scaled up so that the height of the scaled watermarked canvas SY2 is the same as the height of watermarked canvas SY1. Then, the ratio of the reference value of the second width to the width of the scaled watermarked canvas SY2 is determined as the second scaling ratio. This process can be converted into the following mathematical calculations: calculate the third ratio of the reference value of the second width to the preset value of the second width, and the fourth ratio of the preset value of the second height to the reference value of the second height, i.e., step (a223); determine the second scaling ratio by the product of the third ratio and the fourth ratio, i.e., step (a224). Therefore, if the first ratio is greater than the second ratio, then the following steps (a223) and (a224) are performed.
[0078] If the first ratio is not greater than the second ratio, then proceed with the following steps (225).
[0079] Step (a223): Calculate the third ratio of the reference value of the second width to the preset value of the second width, and the fourth ratio of the preset value of the second height to the reference value of the second height.
[0080] Step (a224): Determine the second scaling ratio by multiplying the third ratio and the fourth ratio.
[0081] Step (a225): Determine whether the first ratio is less than the second ratio.
[0082] If the first ratio is less than the second ratio, it indicates that the watermark canvas SY1 is taller than the watermark canvas SY2. In this case, the watermark canvas SY2 can be scaled up so that the width of the scaled watermark canvas SY2 is the same as the width of the watermark canvas SY1. Then, the ratio of the reference value of the second height to the height of the scaled watermark canvas SY2 is determined as the second scaling ratio. This process can be converted into the following mathematical calculations: calculate the fifth ratio of the reference value of the second height to the preset value of the second height, and the sixth ratio of the preset value of the second width to the reference value of the second width, i.e., step (a226); the product of the fifth ratio and the sixth ratio is determined as the second scaling ratio, i.e., step (a227). Therefore, if the first ratio is less than the second ratio, the following steps (a226) and (a227) are executed.
[0083] If the first ratio equals the second ratio, it indicates that watermark canvas SY1 is a similar rectangle to watermark canvas SY2. In this case, the third ratio can be directly determined as the second scaling ratio, i.e., the following steps (a228) can be performed.
[0084] Step (a226): Calculate the fifth ratio of the reference value of the second height to the preset value of the second height, and the sixth ratio of the preset value of the second width to the reference value of the second width.
[0085] Step (a227): Determine the second scaling ratio by multiplying the fifth ratio by the sixth ratio.
[0086] Step (a228): Determine the third ratio as the second scaling ratio.
[0087] In the above implementation, the scaling problem of the watermark canvas is transformed into a simple mathematical calculation, which not only makes it easier to implement, but also improves the efficiency of watermark generation.
[0088] The following is a detailed description of the specific implementation of determining the first scaling ratio based on the first size of the video frame and the second size of the watermark canvas in S102. Specifically, it can be achieved through the following steps (b1) and (b2).
[0089] Step (b1): Calculate the seventh ratio of the reference values of the first width to the second width of the video frame, and the eighth ratio of the reference values of the first height to the second height of the video frame.
[0090] Step (b2): Determine the minimum of the seventh and eighth ratios as the first scaling ratio.
[0091] Specifically, the reference value of the scaled second width is equal to the product of the reference value of the second width and the first scaling ratio; the reference value of the scaled second height is equal to the product of the reference value of the second height and the first scaling ratio; the reference value of the scaled third width is equal to the product of the reference value of the third width and the first scaling ratio; the reference value of the scaled third height is equal to the product of the reference value of the third height and the first scaling ratio; the reference value of the scaled horizontal offset is equal to the product of the reference value of the horizontal offset and the first scaling ratio; and the reference value of the scaled vertical offset is equal to the product of the reference value of the vertical offset and the first scaling ratio.
[0092] In the above embodiment, the seventh ratio is the ratio of the width of the video frame to the width of the watermark canvas SY1, and the eighth ratio is the ratio of the height of the video frame to the height of the watermark canvas SY1. Scaling the watermark canvas SY1 according to the minimum value between the seventh and eighth ratios can make the scaled watermark more closely resemble the shape of the video frame, thereby improving the fit between the watermark and the video frame.
[0093] For example, such as Figure 6A As shown, the ratio of the width of video frame 11 to the width of watermark canvas SY1 (i.e., the seventh ratio) is less than the ratio of the height of video frame 11 to the height of watermark canvas SY1 (the eighth ratio). Therefore, the seventh ratio can be determined as the first scaling ratio. Afterwards, the scaling ratio can be... Figure 6A The watermark 15 and watermark canvas 14 are scaled as a whole at the first scaling ratio to obtain... Figure 6B The watermark and watermark canvas shown.
[0094] For example, such as Figure 6A As shown, the ratio of the width of video frame 12 to the width of watermark canvas SY1 (i.e., the seventh ratio) is greater than the ratio of the height of video frame 12 to the height of watermark canvas SY1 (the eighth ratio). Therefore, the eighth ratio can be determined as the first scaling ratio. Afterwards, the scaling ratio can be... Figure 6A The watermark 15 and watermark canvas 14 are scaled as a whole at the first scaling ratio to obtain... Figure 6C The watermark and watermark canvas shown.
[0095] For example, such as Figure 6A As shown, the ratio of the width of video frame 13 to the width of watermark canvas SY1 (i.e., the seventh ratio) is less than the ratio of the height of video frame 13 to the height of watermark canvas SY1 (the eighth ratio). Therefore, the seventh ratio can be determined as the first scaling ratio. Afterwards, the scaling ratio can be... Figure 6A The watermark 15 and watermark canvas 14 are scaled as a whole at the first scaling ratio to obtain... Figure 6D The watermark and watermark canvas shown.
[0096] In addition, if at least one video frame contains video frames with the same first size, then the first scaling ratios corresponding to these video frames with the same first size are the same. Therefore, to simplify the calculation, it is only necessary to calculate the first scaling ratio corresponding to any one of these video frames with the same first size. The first scaling ratio corresponding to other video frames with the same size can be directly reused when generating the watermark.
[0097] Figure 7 This is a block diagram illustrating a video watermark generation apparatus according to an exemplary embodiment. Figure 7 As shown, the video watermark generation device 300 may include:
[0098] The reference value determination module 301 is used to determine the reference value of the watermark parameters of the video based on the first size of at least one video frame in the video, wherein the watermark parameters include the second size of the watermark canvas, the third size of the watermark, and the position offset of the watermark in the watermark canvas.
[0099] The scaling ratio determination module 302 is used to determine a first scaling ratio for each video frame in the at least one video frame, based on the first size and the second size of the video frame;
[0100] The parameter scaling module 303 is used to scale the baseline value of the watermark parameter according to the first scaling ratio;
[0101] The watermark generation module 304 is used to generate a watermark for the video frame based on the scaled reference value.
[0102] In the above technical solution, firstly, a reference value for the watermark parameters is determined based on the first size of at least one video frame in the video. The watermark parameters include a second size of the watermark canvas, a third size of the watermark, and the positional offset of the watermark within the watermark canvas. Then, for each video frame in the at least one video frame, a first scaling ratio is determined based on the first size of the video frame and the second size of the watermark canvas, and the reference value of the watermark parameters is scaled according to the first scaling ratio. Finally, the watermark for that video frame is generated based on the scaled reference value. Since the reference value of the watermark parameters is calculated only once based on the size of each video frame, the watermark parameters for subsequent video frames can be scaled according to the size of the video frame based on this reference value to generate a watermark adapted to the size of that video frame. This reduces memory usage and computational complexity, improving the efficiency of video watermark generation. In addition, the watermark in each video frame is adapted to the size of that video frame, which can avoid visual interference caused by an overly large watermark, and also avoid the reduced identification effect caused by an overly small watermark. Thus, the ownership or source of the video can be clearly identified without interfering with the video content, thereby improving video quality.
[0103] Optionally, the reference value determination module 301 includes:
[0104] A first determining submodule is configured to determine a reference value for the second size based on the first size of the at least one video frame;
[0105] The second determining submodule is used to determine the reference value of the third dimension and the reference value of the position offset based on the reference value of the second dimension.
[0106] Optionally, the first dimension includes a first width and a first height, and the second dimension includes a second width and a second height;
[0107] The first determining submodule is used to determine the maximum value of the first width of the at least one video frame as the reference value of the second width, and to determine the maximum value of the first height of the at least one video frame as the reference value of the second height.
[0108] Optionally, the second determining submodule includes:
[0109] The acquisition submodule is used to acquire the preset value of the watermark parameter;
[0110] The third determining submodule is used to determine the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension;
[0111] The scaling submodule is used to scale the preset value of the third dimension using the second scaling ratio to obtain the reference value of the third dimension, and to scale the preset value of the position offset using the second scaling ratio to obtain the reference value of the position offset.
[0112] Optionally, the second dimension includes a second width and a second height;
[0113] The third determining submodule includes:
[0114] The first calculation submodule is used to calculate a first ratio of the reference value of the second width to the reference value of the second height, and a second ratio of the preset value of the second width to the preset value of the second height;
[0115] The second calculation submodule is used to calculate, if the first ratio is greater than the second ratio, a third ratio between the reference value of the second width and the preset value of the second width, and a fourth ratio between the preset value of the second height and the reference value of the second height.
[0116] The fourth determining submodule is used to determine the product of the third ratio and the fourth ratio as the second scaling ratio.
[0117] Optionally, the third determining submodule further includes:
[0118] The third calculation submodule is used to calculate, if the first ratio is less than the second ratio, a fifth ratio between the reference value of the second height and the preset value of the second height, and a sixth ratio between the preset value of the second width and the reference value of the second width.
[0119] The fifth determining submodule is used to determine the product of the fifth ratio and the sixth ratio as the second scaling ratio.
[0120] Optionally, the third determining submodule further includes:
[0121] The sixth determining submodule is used to determine the third ratio as the second scaling ratio if the first ratio is equal to the second ratio.
[0122] Optionally, the first dimension includes a first width and a first height, and the second dimension includes a second width and a second height;
[0123] The scaling ratio determination module 302 includes:
[0124] The fourth calculation submodule is used to calculate the seventh ratio of the reference values of the first width and the second width of the video frame, and the eighth ratio of the reference values of the first height and the second height of the video frame.
[0125] The seventh determining submodule is used to determine the minimum value between the seventh ratio and the eighth ratio as the first scaling ratio.
[0126] This disclosure also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the video watermark generation method described above.
[0127] This disclosure also provides an electronic device, including:
[0128] A storage device on which computer programs are stored;
[0129] A processing device is configured to execute the computer program in the storage device to implement the steps of the video watermark generation method provided in this disclosure.
[0130] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the video watermark generation method described above.
[0131] The following is for reference. Figure 8The diagram illustrates a structural schematic of an electronic device (terminal device or server) 600 suitable for implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0132] like Figure 8 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0133] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0134] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0135] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0136] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0137] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0138] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: determine a reference value for watermark parameters of the video based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a positional offset of the watermark in the watermark canvas; determine a first scaling ratio for each video frame in the at least one video frame based on the first size and the second size of the video frame; scale the reference value of the watermark parameters according to the first scaling ratio; and generate a watermark for the video frame based on the scaled reference value.
[0139] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0141] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The names of the modules do not necessarily limit the module itself; for example, a watermark generation module can also be described as "a module that generates a watermark for the video frame based on a scaled reference value."
[0142] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0143] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0144] According to one or more embodiments of this disclosure, Example 1 provides a video watermark generation method, including:
[0145] A reference value for the watermark parameters of the video is determined based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas.
[0146] For each video frame in the at least one video frame, a first scaling ratio is determined based on the first size and the second size of the video frame;
[0147] The baseline value of the watermark parameter is scaled according to the first scaling ratio;
[0148] The watermark for this video frame is generated based on the scaled baseline value.
[0149] According to one or more embodiments of this disclosure, Example 2 provides the method of Example 1, wherein determining a reference value for a watermark parameter of a video based on a first size of at least one video frame in the video includes:
[0150] A reference value for the second size is determined based on the first size of the at least one video frame;
[0151] Based on the reference value of the second dimension, determine the reference value of the third dimension and the reference value of the position offset.
[0152] According to one or more embodiments of this disclosure, Example 3 provides the method of Example 2, wherein the first dimension includes a first width and a first height, and the second dimension includes a second width and a second height;
[0153] Determining the reference value of the second size based on the first size of the at least one video frame includes:
[0154] The maximum value of the first width of the at least one video frame is determined as the reference value of the second width, and the maximum value of the first height of the at least one video frame is determined as the reference value of the second height.
[0155] According to one or more embodiments of this disclosure, Example 4 provides the method of Example 2, wherein determining the reference value of the third dimension and the reference value of the position offset based on the reference value of the second dimension includes:
[0156] Obtain the preset value of the watermark parameter;
[0157] The second scaling ratio is determined based on the reference value of the second dimension and the preset value of the second dimension;
[0158] The preset value of the third dimension is scaled using the second scaling ratio to obtain the reference value of the third dimension, and the preset value of the position offset is scaled using the second scaling ratio to obtain the reference value of the position offset.
[0159] According to one or more embodiments of this disclosure, Example 5 provides the method of Example 4, wherein the second dimension includes a second width and a second height;
[0160] Determining the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension includes:
[0161] Calculate a first ratio of the reference value of the second width to the reference value of the second height, and a second ratio of the preset value of the second width to the preset value of the second height;
[0162] If the first ratio is greater than the second ratio, then calculate the third ratio of the reference value of the second width to the preset value of the second width, and the fourth ratio of the preset value of the second height to the reference value of the second height;
[0163] The product of the third ratio and the fourth ratio is determined as the second scaling ratio.
[0164] According to one or more embodiments of this disclosure, Example 6 provides the method of Example 5, wherein determining the second scaling ratio based on a reference value of the second dimension and a preset value of the second dimension further includes:
[0165] If the first ratio is less than the second ratio, then calculate the fifth ratio of the reference value of the second height to the preset value of the second height, and the sixth ratio of the preset value of the second width to the reference value of the second width;
[0166] The product of the fifth ratio and the sixth ratio is determined as the second scaling ratio.
[0167] According to one or more embodiments of this disclosure, Example 7 provides the method of Example 5, wherein determining the second scaling ratio based on a reference value of the second dimension and a preset value of the second dimension further includes:
[0168] If the first ratio is equal to the second ratio, then the third ratio is determined as the second scaling ratio.
[0169] According to one or more embodiments of this disclosure, Example 8 provides the method of Example 1, wherein the first dimension includes a first width and a first height, and the second dimension includes a second width and a second height;
[0170] Determining the first scaling ratio based on the first size and the second size of the video frame includes:
[0171] Calculate the seventh ratio of the reference values of the first width to the second width of the video frame, and the eighth ratio of the reference values of the first height to the second height of the video frame;
[0172] The minimum value between the seventh ratio and the eighth ratio is determined as the first scaling ratio.
[0173] According to one or more embodiments of this disclosure, Example 9 provides a video watermark generation apparatus, comprising:
[0174] A reference value determination module is used to determine a reference value for the watermark parameters of the video based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas.
[0175] A scaling ratio determination module is configured to determine a first scaling ratio for each video frame in the at least one video frame, based on the first size and the second size of the video frame;
[0176] The parameter scaling module is used to scale the baseline value of the watermark parameter according to the first scaling ratio;
[0177] The watermark generation module is used to generate a watermark for the video frame based on the scaled baseline value.
[0178] According to one or more embodiments of the present disclosure, Example 10 provides a computer-readable medium having a computer program stored thereon that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-8.
[0179] According to one or more embodiments of this disclosure, Example 11 provides an electronic device, including:
[0180] A storage device on which computer programs are stored;
[0181] A processing device for executing the computer program in the storage device to implement the steps of any one of the methods in Examples 1-8.
[0182] According to one or more embodiments of the present disclosure, Example 12 provides a computer program product including a computer program that, when executed by a processor, implements the steps of the method described in any one of Examples 1-8.
[0183] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0184] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0185] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.
Claims
1. A method for generating video watermarks, characterized in that, include: A reference value for the watermark parameters of the video is determined based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas. For each video frame in the at least one video frame, a first scaling ratio is determined based on the first size and the second size of the video frame; The baseline value of the watermark parameter is scaled according to the first scaling ratio; The watermark for this video frame is generated based on the scaled baseline value.
2. The method according to claim 1, characterized in that, Determining the reference value of the watermark parameter of the video based on a first size of at least one video frame in the video includes: A reference value for the second size is determined based on the first size of the at least one video frame; Based on the reference value of the second dimension, determine the reference value of the third dimension and the reference value of the position offset.
3. The method according to claim 2, characterized in that, The first dimension includes a first width and a first height, and the second dimension includes a second width and a second height; Determining the reference value of the second size based on the first size of the at least one video frame includes: The maximum value of the first width of the at least one video frame is determined as the reference value of the second width, and the maximum value of the first height of the at least one video frame is determined as the reference value of the second height.
4. The method according to claim 2, characterized in that, The step of determining the reference value of the third dimension and the reference value of the position offset based on the reference value of the second dimension includes: Obtain the preset value of the watermark parameter; The second scaling ratio is determined based on the reference value of the second dimension and the preset value of the second dimension; The preset value of the third dimension is scaled using the second scaling ratio to obtain the reference value of the third dimension, and the preset value of the position offset is scaled using the second scaling ratio to obtain the reference value of the position offset.
5. The method according to claim 4, characterized in that, The second dimension includes a second width and a second height; Determining the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension includes: Calculate a first ratio of the reference value of the second width to the reference value of the second height, and a second ratio of the preset value of the second width to the preset value of the second height; If the first ratio is greater than the second ratio, then calculate the third ratio of the reference value of the second width to the preset value of the second width, and the fourth ratio of the preset value of the second height to the reference value of the second height; The product of the third ratio and the fourth ratio is determined as the second scaling ratio.
6. The method according to claim 5, characterized in that, The step of determining the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension further includes: If the first ratio is less than the second ratio, then calculate the fifth ratio of the reference value of the second height to the preset value of the second height, and the sixth ratio of the preset value of the second width to the reference value of the second width; The product of the fifth ratio and the sixth ratio is determined as the second scaling ratio.
7. The method according to claim 5, characterized in that, The step of determining the second scaling ratio based on the reference value of the second dimension and the preset value of the second dimension further includes: If the first ratio is equal to the second ratio, then the third ratio is determined as the second scaling ratio.
8. The method according to claim 1, characterized in that, The first dimension includes a first width and a first height, and the second dimension includes a second width and a second height; Determining the first scaling ratio based on the first size and the second size of the video frame includes: Calculate the seventh ratio of the reference values of the first width to the second width of the video frame, and the eighth ratio of the reference values of the first height to the second height of the video frame; The minimum value between the seventh ratio and the eighth ratio is determined as the first scaling ratio.
9. A video watermark generation device, characterized in that, include: A reference value determination module is used to determine a reference value for the watermark parameters of the video based on a first size of at least one video frame in the video, wherein the watermark parameters include a second size of the watermark canvas, a third size of the watermark, and a position offset of the watermark in the watermark canvas. A scaling ratio determination module is configured to determine a first scaling ratio for each video frame in the at least one video frame, based on the first size and the second size of the video frame; The parameter scaling module is used to scale the baseline value of the watermark parameter according to the first scaling ratio; The watermark generation module is used to generate a watermark for the video frame based on the scaled baseline value.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by a processing device, the computer program performs the steps of the method according to any one of claims 1-8.
11. An electronic device, characterized in that, include: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method according to any one of claims 1-8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-8.
