Video watermark adding method, server, system and storage medium
By adding video watermarks in the memory space, using memory replica and memory duplicator for video processing, solving the problem of video watermarking in the existing technology Effect.
Patent Information
- Application Number
- CN202310925042.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-25
- Publication Date
- 2025-01-28
AI Technical Summary
The prior art occupies a large amount of server storage space during the video watermark addition process, resulting in a shortened disk life and a risk of server crashes.
By downloading and processing source video data in the memory space, the memory replication device and memory relicnter are used for video decoding, watermarking and encoding, and the target video file is generated to avoid temporary storage video files of the hard disk.
Reduced the storage space occupying the server, extended the life of the disk, and improved the speed and efficiency of video water marks.
Smart Images

Figure CN119383420A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of digital image processing technology, and in particular to a method, server, system and storage medium for adding video watermarks. Background Art
[0002] With the popularity of online videos, the copyright issue of videos has become increasingly prominent. In order to protect the copyright of video content, it is usually necessary to add watermark information with identification to the video.
[0003] In the prior art, when adding a watermark to a video, it is usually necessary to first download the video and generate a file with the watermark added and the same size as the original video, which requires a storage space on the server that is twice the size of the original video. When there are multiple requests to add watermarks, a large amount of storage space is required, which may cause a temporary crash of the server storage and make it impossible to provide services. After downloading the video and adding the watermark to the server, the processed video needs to be deleted, which will cause a large amount of temporary reading and writing on the server and occupy a large amount of storage space on the server, greatly consuming the life of the disk. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a method, server, system and storage medium for adding video watermarks to solve the problem of occupying a large amount of storage space on the server and consuming the life of the disk during the watermark adding process.
[0005] The embodiments of the present application provide the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a method for adding a video watermark, which is applied to a server, wherein the server includes a memory space, a memory demultiplexer, and a memory multiplexer, including:
[0007] Obtain a source video download request, and download the source video data to the memory space according to the source video download request;
[0008] Parsing the source video data in the memory space through the memory demultiplexer to obtain a first source video code stream and an audio code stream corresponding to the source video data;
[0009] Decoding a first source video code stream to obtain a first image frame;
[0010] Adding a watermark to the first image frame to obtain a second image frame;
[0011] Encoding the second image frame to obtain a second source video code stream;
[0012] The second source video code stream and audio code stream are integrated through the memory multiplexer to obtain a target video file.
[0013] In some embodiments, the server further includes a video decoder, which decodes the first source video code stream to obtain a first image frame, including:
[0014] Decompressing and decapsulating the first source video code stream by a video decoder to obtain a decoded frame;
[0015] The decoded frame is restored to obtain the first image frame.
[0016] In some embodiments, the source video download request includes a source video identifier, and according to the source video download request, downloading the source video data to the memory space includes:
[0017] According to the source video identifier, obtain the source video download address;
[0018] Download the source video data to the memory space according to the source video download address.
[0019] In some embodiments, the source video download request includes a user identifier, and the method includes:
[0020] According to the user identifier, the user's watermark information is obtained, where the watermark information includes the watermark position and the watermark text and / or watermark image;
[0021] Adding a watermark to the first image frame to obtain a second image frame includes:
[0022] Performing pixel conversion on the watermark text and / or the watermark image to obtain watermark pixels, wherein the watermark pixels are pixels of the watermark text and / or pixels of the watermark image;
[0023] According to the watermark position, the pixels at the position on the first image frame corresponding to the watermark position are replaced with watermark pixels to obtain a second image frame.
[0024] In some embodiments, the server further includes a video encoder, which encodes the second image frame to obtain a second source video code stream, including:
[0025] Compressing the second image frame by a video encoder to obtain a compressed frame;
[0026] The compressed frame is encoded to obtain a second source video code stream.
[0027] In some embodiments, the second source video code stream and the audio code stream are integrated by a memory multiplexer to obtain a target video file, including:
[0028] Performing time base alignment on the second source video code stream and the audio code stream through the memory multiplexer to obtain the second source video code stream and the audio code stream with time base alignment;
[0029] According to the specified format, the second source video code stream and audio code stream whose time bases are aligned are encapsulated to obtain the target video file.
[0030] In a second aspect, an embodiment of the present application provides a server, including:
[0031] At least one processor and at least one memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method for adding a video watermark according to the first aspect.
[0032] In a third aspect, an embodiment of the present application provides a system for adding a video watermark, including:
[0033] A download server, wherein the download server is the server of the second aspect;
[0034] The source video server is used to provide source video data to the download server.
[0035] In some embodiments, the download server includes:
[0036] A memory demultiplexer, used for parsing the source video data in the memory space to obtain a first source video code stream and an audio code stream corresponding to the source video data;
[0037] A memory multiplexer, used for integrating the second source video code stream and the audio code stream to obtain a target video file;
[0038] A video decoder, used for decoding the first source video code stream to obtain a first image frame;
[0039] The video encoder is used to encode the second image frame to obtain a second source video code stream.
[0040] In a fourth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, wherein the non-volatile computer storage medium stores a plurality of instructions, and the instructions are suitable for loading by a processor to execute the video watermark adding method of the first aspect.
[0041] The beneficial effect of the implementation of the present application is: different from the prior art, the implementation of the present application provides a method for adding a video watermark, the method comprising: obtaining a source video download request, downloading the source video data to the memory space according to the source video download request; parsing the source video data in the memory space through a memory demultiplexer to obtain a first source video code stream and an audio code stream; decoding the first source video code stream to obtain a first image frame; adding a watermark to the first image frame to obtain a second image frame; encoding the second image frame to obtain a second source video code stream; integrating the second source video code stream and the audio code stream through a memory multiplexer to obtain a target video file. By adding a watermark in the memory space, the storage space occupied by the server is reduced, and the present application can save disk space and extend the life of the disk. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] One or more embodiments are exemplarily described by corresponding drawings, which do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and the figures in the drawings do not constitute proportional limitations unless otherwise stated.
[0043] Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0044] Figure 2 It is a flowchart of a method for adding a video watermark provided in an embodiment of the present application;
[0045] Figure 3 yes Figure 2 A detailed flow chart of step S201 in FIG.
[0046] Figure 4 yes Figure 2 A detailed flow chart of step S203 in FIG.
[0047] Figure 5 It is a schematic diagram of a process of obtaining watermark information and a second image frame according to a video download request provided by an embodiment of the present application;
[0048] Figure 6 yes Figure 5 A detailed flow chart of step S502 in FIG.
[0049] Figure 7 yes Figure 2 A detailed flow chart of step S205 in FIG.
[0050] Figure 8 yes Figure 2 A detailed flow chart of step S206 in FIG.
[0051] Fig. 9It is a structural schematic diagram of a video watermarking system provided in an embodiment of the present application;
[0052] Fig.10 yes Fig. 9 A schematic diagram of the structure of the download server 20;
[0053] Fig.11 It is a structural schematic diagram of a method for adding a video watermark provided in an embodiment of the present application;
[0054] Fig.12 This is a timing diagram of obtaining a target video file provided by an embodiment of the present application;
[0055] Fig.13 It is a structural schematic diagram of a video watermark adding device provided in an embodiment of the present application;
[0056] Fig.14 It is a structural diagram of a download server provided in an embodiment of the present application.
[0057] Description of Figure Numbers:
[0058] Label name Label name 100 Application Environment 1034 Add watermark module 10 Electronic devices 1035 Encoding module 20 Download Server 1036 Integration Module 30 Source Video Server 2001 Memory Demultiplexer 900 Video watermarking system 2002 Memory Multiplexer 1300 Video watermark adding device 2003 Video Decoder 1031 Download Module 2004 Video Encoder 1032 Parsing module 2005 processor 1033 Decoding module 2006 Memory DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0060] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, and all are within the scope of protection of the present application. In addition, the words "first", "second", etc. used in the present application do not limit the data, but only divide the same or similar items with basically the same functions and effects.
[0061] Currently, adding a watermark to a video usually involves downloading the original video to a server, using a watermark adding tool to add a watermark to the original video, and saving the watermarked video to the server.
[0062] Since the original video and the video with the watermark need to be saved, the server's storage space is twice the size of the original video. When there are multiple requests to add watermarks, a large amount of storage space is required, which may cause the server to crash. After the request is completed, the processed video is deleted. There are a lot of temporary reads and writes in the server, which greatly consumes the life of the disk.
[0063] Based on this, an embodiment of the present application provides a method, server, system and storage medium for adding video watermarks. By downloading the source video data to the memory space, a memory demultiplexer and a memory multiplexer are used to perform video processing to add a watermark in the memory space, thereby solving the problem of occupying a large amount of server storage space in the current watermark adding process, thereby extending the life of the disk.
[0064] The technical solution of the present application is described in detail below in conjunction with the accompanying drawings:
[0065] See also Figure 1 , Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0066] like Figure 1 As shown, the application environment 100 includes: an electronic device 10, a download server 20, and a source video server 30, wherein the electronic device 10 is used to save the video file downloaded by the download server 20, the download server 20 is used to download the video file in the source video server 30 and add a watermark to the video file, and return the video file with the watermark added to the electronic device 10, the electronic device 10 is connected to the download server 20 through a wireless network or a wired interface, and the download server 20 is connected to the source video server 30 through a wireless network. It can be understood that the wired interface includes interfaces such as SerialPort, USB, Ethernet, etc., and the wireless network includes wireless networks such as Bluetooth and wireless LAN.
[0067] In the embodiment of the present application, the electronic device 10 includes a device or equipment that can be connected to the Internet, such as a tablet computer, a computer terminal, etc. The source video server 30 provides a communication interface for the download server 20, so that the download server 20 downloads the video file from the source video server 30, and the download server 20 provides a communication interface for the electronic device 10, so that the electronic device 10 obtains the video file with the watermark added from the download server.
[0068] See also Figure 2 , Figure 2 It is a flowchart of a method for adding a video watermark provided in an embodiment of the present application;
[0069] The method for adding a video watermark is applied to a server. Specifically, the execution subject of the method for adding a video watermark is one or at least two processors of an electronic device.
[0070] The server includes a memory space, and the memory space includes a cache, such as a static random access memory (SRAM) and a dynamic random access memory (DRAM).
[0071] like Figure 2 As shown, the method includes:
[0072] Step S201: Obtain a source video download request, and download source video data to a memory space according to the source video download request;
[0073] In the embodiment of the present application, the source video data is stored in a source video server, and the server to which the video watermark adding method is applied is a download server, that is, the download server includes a memory space.
[0074] In the embodiment of the present application, the user sends an original video download request to the download server using Hypertext Transfer Protocol (HTTP).
[0075] Specifically, the download server receives a video download request initiated by a user, parses information in the video download request, finds source video data in the source video server according to the information, and then downloads the source video data to the memory space of the download server.
[0076] In the embodiment of the present application, by downloading the source video data into the memory space, the space occupied by the disk is reduced to extend the life of the disk.
[0077] Please refer to Figure 3 , Figure 3 yes Figure 2 A detailed flow chart of step S201 in FIG.
[0078] The information included in the video download request includes various identifications (IDs), such as a user identification (user ID) and a source video identification (source video ID).
[0079] like Figure 3 As shown, step S201 includes:
[0080] Step S211: Obtain the source video download address according to the source video identifier;
[0081] In the embodiment of the present application, it can be understood that the server includes a database, and the database is used to store various information in the server.
[0082] In an embodiment of the present application, the download server parses the information in the source video download request, which includes the source video ID. It is understandable that each source video ID is unique. The download server queries the database for relevant video information based on the source video ID, such as the storage path or address (Uniform Resource Locator, URL) of the source video, the file name of the source video, the format of the source video, etc. The download server splices the storage path or URL of the source video with the file name of the source video according to the storage rules and path settings in the server, and can generate the actual download URL of the source video.
[0083] Specifically, the download server obtains the source video ID, searches the database for the storage path or storage address of the source video and the file name of the source video according to the source video ID, and then concatenates the storage path or storage address of the source video with the file name of the source video to obtain the actual download URL of the source video, that is, the download address of the source video.
[0084] In an embodiment of the present application, the actual download address of the source video is found, and the download server obtains the source video data through the actual download address of the source video.
[0085] Step S212: downloading source video data to memory space according to the source video download address;
[0086] Specifically, the download server finds the source video download address, finds the source video data in the source video server according to the source video download address, and then downloads and saves the source video data into the memory space of the download server.
[0087] In the embodiment of the present application, the source video data is downloaded into the memory space to reduce temporary read and write operations of the disk, thereby saving disk space and improving disk performance.
[0088] Step S202: parsing the source video data in the memory space through the memory demultiplexer to obtain a first source video code stream and an audio code stream corresponding to the source video data;
[0089] In an embodiment of the present application, after the download server receives the user's source video download request, the download server initiates the user's source video download request to the source video server, the source video server receives the source video download request and gives a response to the download server. Further, after the download server receives the source video response returned by the source video server, the download server creates a memory demultiplexer corresponding to the source video response in the memory space.
[0090] In the embodiment of the present application, the above-mentioned saving of the downloaded source video data into the memory space is actually inputting the downloaded source video data into the memory demultiplexer in the memory space.
[0091] In the embodiment of the present application, after the download server receives the source video response and creates the memory demultiplexer, it starts to download the source video data from the source video server and inputs it into the memory demultiplexer.
[0092] In the embodiment of the present application, it can be understood that the source video code stream and the audio code stream in the source video data can be extracted separately. The function of the memory demultiplexer is to extract the source video code stream and the audio code stream separately, and distribute the separately extracted source video code stream and the audio code stream to the designated receiving device or processing unit.
[0093] In the embodiment of the present application, the function of the memory demultiplexer is actually completed by some program codes, and the program codes include a callback function, and the function of the callback function is to initiate a request to read data. When writing the program code, the callback function is overloaded as a custom function, and the request to read data can be redirected to the source video data corresponding to the source video response through the custom function, so that the memory demultiplexer continuously receives and parses the source video data.
[0094] In an embodiment of the present application, the memory demultiplexer can automatically identify the format of the video and parse the source video data according to the specifications of the video format.
[0095] Specifically, the download server inputs the downloaded source video data into the memory demultiplexer. After the memory demultiplexer receives the source video data corresponding to the source video response, it starts to parse the source video data. The memory demultiplexer splits the source video code stream and audio code stream in the source video data to obtain a source video code stream and an audio code stream. The source video code stream is the first source video code stream.
[0096] In an embodiment of the present application, the source video code stream carries some parameters, including the wall clock time, which is the time of the server. The memory demultiplexer can parse the source video code stream in the order of the wall clock time.
[0097] In an embodiment of the present application, the memory demultiplexer can parse the content of the encapsulation format of the source video data, such as the encapsulation format of MP4, MKV, FLV, etc., to obtain the code stream information of the video data. For example: the memory demultiplexer includes an FFmpeg demultiplexer, and the process of FFmpeg parsing the source video in the memory space includes: creating a format context, reading the source video data in the source server into the format context, automatically parsing the source video data through the custom function in the format context, and obtaining the first source video code stream and audio code stream, wherein the first source video code stream and audio code stream both carry information parameters such as encoding format, duration, start time, wall clock time, etc.
[0098] In the embodiment of the present application, whether all parsing of video data of different formats is completed needs to be determined according to different video format standards. For example, when the format of the video data read by the memory demultiplexer is MP4 format, according to the standard of the MP4 format, the audio and video content in the data in MP4 format is actually stored in the moov box in the MP4 file, and the moov box is composed of sub-boxes, wherein the sub-boxes of the moov box include the mdat box, which is usually the last box in the source video data. When the memory demultiplexer recognizes that the parsed source video data comes from the mdat box, it is assumed that all the data in MP4 format corresponding to the response of the source video server have been read. Among them, the standards of different video formats can be specifically referred to the prior art, which will not be repeated here.
[0099] In an embodiment of the present application, the source video data is split into a source video code stream and an audio code stream through a memory demultiplexer, so that the source video data is easier to process, so as to further realize the addition of a watermark.
[0100] Step S203: decoding the first source video code stream to obtain a first image frame;
[0101] Specifically, the first source video code stream of the source video data parsed by the memory demultiplexer is obtained, and the first source video code stream is further decoded to obtain an image frame corresponding to the first source video code stream, that is, to obtain a first image frame. The specific decoding process is carried out through the following steps.
[0102] Please refer to Figure 4 , Figure 4 yes Figure 2 A detailed flow chart of step S203 in FIG.
[0103] like Figure 4 As shown, step S203 includes:
[0104] Step S231: decompressing and decapsulating the first source video code stream through a video decoder to obtain a decoded frame;
[0105] In an embodiment of the present application, when the download server creates a memory multiplexer in the memory space, it also creates a corresponding video decoder in the memory space. The function of the video decoder is to receive the first source video code stream output from the memory multiplexer and decode the received first source video code stream to obtain an image frame on which a watermark can be directly drawn.
[0106] Specifically, the video decoder receives the first source video code stream output by the memory multiplexer, and the video decoder starts to extract source video frame data from the first source video code stream. According to the video coding standard, the video decoder decompresses and decapsulates the source video frame data to obtain a decoded frame. The source video frame data is usually compressed data, which needs to be further decompressed to obtain the desired data.
[0107] Step S232: restore the decoded frame to obtain a first image frame;
[0108] Specifically, after obtaining the decoded frame, the video decoder converts the decoded frame into an original pixel image. The original pixel image is composed of pixels one by one. The pixel image is the first image frame.
[0109] In an embodiment of the present application, there is a one-to-one relationship between the memory demultiplexer and the video decoder, that is, when the memory demultiplexer parses out the first source video stream, it inputs the first source video stream into the video decoder, and can simultaneously parse the source video data and decode the first source video stream.
[0110] In the embodiment of the present application, the source video code stream is processed into an original pixel image through a video decoder, so that a watermark can be directly drawn on the pixel image.
[0111] Step S204: adding a watermark to the first image frame to obtain a second image frame;
[0112] Specifically, the first image frame and the user's watermark information are acquired, and a watermark is added to the first image frame to obtain an image frame after the watermark is added, and the image frame after the watermark is added is the second image frame.
[0113] Please refer to Figure 5 , Figure 5 It is a schematic diagram of a process of obtaining watermark information and a second image frame according to a video download request provided by an embodiment of the present application;
[0114] like Figure 5 As shown, including:
[0115] Step S501: acquiring the user's watermark information according to the user identifier, the watermark information including the watermark position and the watermark text and / or watermark image;
[0116] In an embodiment of the present application, the download server parses the information carried in the video download request, which includes a user identification, i.e., a user ID. It can be understood that each user ID is unique, and each unique user ID has a unique watermark corresponding to it, i.e., each user's watermark is different, and the same user can only use one watermark to identify his own video to distinguish it from other users' videos, and protect the copyright of his own video by using the unique watermark.
[0117] It is understandable that the user's watermark can be text, or a picture or other related logo.
[0118] Specifically, according to the user ID, find the watermark text and / or watermark image corresponding to the user ID, and find the specific position of the watermark text and / or watermark image in the image, such as the upper right corner, upper left corner or lower right corner of the image, etc.
[0119] In the embodiment of the present application, the user's watermark and the location information of the watermark are obtained to further implement the step of adding the watermark.
[0120] Step S502: adding a watermark to the first image frame to obtain a second image frame;
[0121] Specifically, the first image frame and the user's watermark information are acquired, and a watermark is added to the first image frame to obtain an image frame after the watermark is added, and the image frame after the watermark is added is the second image frame.
[0122] Please refer to Figure 6 , Figure 6 yes Figure 5 A detailed flow chart of step S502 in FIG.
[0123] like Figure 6 As shown, step S502 includes:
[0124] Step S521: performing pixel conversion on the watermark text and / or the watermark image to obtain watermark pixels, wherein the watermark pixels are pixels of the watermark text and / or pixels of the watermark image;
[0125] In the embodiment of the present application, after obtaining the user's watermark information, such as watermark text and / or watermark image, the watermark text and / or watermark image needs to be converted into pixel representation before the user's watermark can be drawn on the image frame.
[0126] In the embodiment of the present application, for watermark text, the watermark text can be converted into pixel representation by drawing a font or converting the text into pixel representation by a specific algorithm. For the watermark image, the original pixel image is obtained by decompressing it according to the encoding method of the image. The specific algorithm and encoding method can refer to the prior art and will not be repeated here.
[0127] Specifically, the user's watermark text or watermark image is obtained, and according to the above conversion method, the watermark text or watermark image is converted into pixel representation to obtain the pixels of the watermark text or the pixels of the watermark image.
[0128] Step S522: according to the watermark position, replace the pixels at the position on the first image frame corresponding to the watermark position with the watermark pixels to obtain a second image frame;
[0129] In the embodiment of the present application, the watermark position is a certain position of the user's watermark drawn on the image, for example, the watermark is drawn at the upper left corner, upper right corner, lower left corner or lower right corner of the image, etc. The specific position of drawing the watermark depends on different user needs.
[0130] Specifically, the position where the user watermark is drawn, the pixels of the watermark text or the pixels of the watermark image are obtained, and the position on the first image frame corresponding to the position where the user watermark is drawn is determined according to the set fixed coordinates, and the watermark adding tool provided by the download server is used to replace the pixels of the watermark text or the pixels of the watermark image with the pixels corresponding to the position of the watermark on the image, so as to obtain the image frame after the watermark is drawn, that is, the second image frame.
[0131] In the embodiment of the present application, the video decoder and the watermark adding tool also have a one-to-one relationship. When the video decoder outputs the image frame, the watermark adding tool receives the output image frame and draws the watermark on the image frame, and then outputs the image frame with the watermark added.
[0132] In the embodiment of the present application, a watermark is successfully drawn on an image frame by replacing pixels between watermark pixels and image frame pixels.
[0133] Step S205: Encode the second image frame to obtain a second source video code stream;
[0134] In the embodiment of the present application, when a video decoder is created, a corresponding video encoder needs to be created. The video encoder is used to encode the image frame with the watermark added to obtain a video code stream.
[0135] Specifically, the second image frame is input into the video encoder, that is, the image frame with the watermark added is input into the video encoder, and the video encoder encodes the image frame with the watermark added to obtain the second source video code stream. The specific encoding process is as follows.
[0136] Please refer to Figure 7 , Figure 7 yes Figure 2 A detailed flow chart of step S205 in FIG.
[0137] like Figure 7As shown, step S205 includes:
[0138] Step S251: compressing the second image frame by a video encoder to obtain a compressed frame;
[0139] Specifically, the second image frame is compressed by a video encoder to reduce the volume of the second image frame, thereby obtaining a compressed second image frame, that is, a compressed frame.
[0140] In the embodiment of the present application, the image frame is compressed in volume to facilitate transmission, which is beneficial to increase the transmission speed, so as to further increase the speed of adding video watermarks.
[0141] Step S252: Encode the compressed frame to obtain a second source video code stream;
[0142] Specifically, a compressed second image frame is obtained, and a video encoder encodes the compressed second image frame according to a specific encoding format to obtain a code stream corresponding to the second image frame, that is, a second source video code stream.
[0143] In the embodiment of the present application, the video encoder encodes the image frame according to the encoding standard of the video format received by the memory demultiplexer, and can also convert the format of the video according to the needs of the user. For example, when the format of the source video is MP4 format, the image frame can be encoded according to the encoding rules of the MP4 format during encoding. When it is necessary to convert the MP4 format to other formats, the MP4 format of the source video can be converted to other formats by modifying the relevant parameters of the encoding format in the video encoder, thereby realizing the conversion of the video frame format.
[0144] In an embodiment of the present application, the image frame is converted into a code stream through a video encoder to obtain the code stream data with a watermark added. The format of the code stream data can also be changed through the video encoder to meet the needs of users.
[0145] Step S206: integrating the second source video code stream and the audio code stream through the memory multiplexer to obtain a target video file;
[0146] In an embodiment of the present application, while creating a memory demultiplexer, it is also necessary to create a memory multiplexer in the memory space. The memory multiplexer is used to receive the video stream output by the video encoder and the audio stream output by the memory demultiplexer, and integrate the video stream with the audio stream to obtain a video file.
[0147] In the embodiment of the present application, the function of the memory multiplexer is actually completed by some program codes, which contain callback functions, and the function of the callback function is to initiate a request to write data. When writing the program code, the callback function is overloaded as a custom function, and the function of the custom function is to respond to the user's request to download the source video, and send the video file with the watermark added to the user, so that the user can see the download progress of the current video, so that the user has a good user experience.
[0148] Specifically, the second source video code stream and audio code stream are obtained, and the second source video code stream and audio code stream are input into the memory multiplexer, and the second source video code stream and audio code stream are integrated through the memory multiplexer to obtain a video file with a watermark added.
[0149] Please refer to Figure 8 , Figure 8 yes Figure 2 A detailed flow chart of step S206 in FIG.
[0150] like Figure 8 As shown, step S206 includes:
[0151] Step S261: performing time base alignment on the second source video code stream and the audio code stream through the memory multiplexer to obtain the second source video code stream and the audio code stream with time base alignment;
[0152] In the embodiment of the present application, the time reference is used to ensure that the second source video stream and audio stream can be played and synchronized according to the correct time relationship.
[0153] In an embodiment of the present application, since the second source video stream and audio stream are encoded and processed separately, in order to ensure that the video and audio can be aligned in normal time order during playback, it is necessary to align the time base of the second source video stream and audio stream through a memory multiplexer.
[0154] Specifically, a wall clock time parameter is set in the memory multiplexer, and the parameter is the same as the wall clock time parameter of the first source video stream. The memory multiplexer uses the parameter as a timestamp to align the time base of the second source video stream and the audio stream, thereby obtaining a second source video stream and audio stream with aligned time bases.
[0155] Step S262: encapsulating the second source video bitstream and audio bitstream aligned with the time base according to the specified format to obtain a target video file;
[0156] In the embodiment of the present application, the download server also creates a new container file in the memory multiplexer, which is used to receive the second source video stream and audio stream aligned with the time base. There are many formats of the container file, such as AVI, MP4, MKV and other multimedia formats, and the specific format of the container file needs to be determined according to the needs of the user.
[0157] Specifically, the memory multiplexer encapsulates the second source video code stream and the audio code stream according to the format of the selected container file and the structure and specification specific to the format to obtain the target video file.
[0158] In an embodiment of the present application, when all second source video code streams and audio code streams are processed, the memory demultiplexer returns an end status code to the download server. After receiving the end status code, the download server closes the video decoder, container file, video encoder, memory multiplexer, and memory demultiplexer to release memory. Afterwards, the download server sends the watermarked video file to the user's electronic device, such as a user terminal. After successfully sending the watermarked video file to the user terminal, the download server terminates the HTTP response corresponding to the source video download request initiated by the user using the HTTP protocol. It can be understood that the HTTP response is the watermarked video content that the server finally sends to the user terminal.
[0159] In an embodiment of the present application, by obtaining a source video download request, the source video data is downloaded to the memory space according to the source video download request; the source video data in the memory space is parsed by a memory demultiplexer to obtain a first source video code stream and an audio code stream; the first source video code stream is decoded to obtain a first image frame; a watermark is added to the first image frame to obtain a second image frame; the second image frame is encoded to obtain a second source video code stream; the second source video code stream and the audio code stream are integrated by a memory multiplexer to obtain a target video file. The entire process of adding watermarks in the present application is carried out in the memory space, and the hard disk is not used to temporarily store video files, which improves the performance of the disk, saves disk space and extends the life of the disk. In addition, since the memory space is a high-speed cache, the speed of adding watermarks can be further improved.
[0160] In an embodiment of the present application, the present application also uses a custom function to send the watermarked video file to the user in a timely manner, so that the user can see the download progress of the watermarked video, thereby improving the user's user experience.
[0161] See also Fig. 9 , Fig. 9 It is a structural schematic diagram of a video watermarking system provided in an embodiment of the present application;
[0162] like Fig. 9As shown, the video watermark adding system 900 includes: a download server 20 and a source video server 30 , wherein the download server 20 is communicatively connected to the source video server 30 .
[0163] Specifically, the download server 20 includes a memory space, which is used to download source video data from the source video server 30 to the memory space, and parse the source video data in the memory space to obtain a first source video code stream and an audio code stream corresponding to the source video data, decode the first source video code stream to obtain a first image frame, add a watermark to the first image frame to obtain a second image frame, encode the second image frame to obtain a second source video code stream, integrate the second source video code stream and the audio code stream to obtain a target video file, and output the target video file.
[0164] Specifically, the source video server 30 is used to provide source video data to the download server.
[0165] In the embodiment of the present application, the source video server 30 includes one or at least two servers, and the at least two servers constitute a server cluster, which is used to store multiple video files for downloading by the download server 20.
[0166] In the embodiment of the present application, by adding a watermark to the video in the memory space of the download server to obtain the target video file, the disk space can be saved and the life of the disk can be extended.
[0167] Please refer to Fig.10 , Fig.10 yes Fig. 9 A schematic diagram of the structure of the download server 20;
[0168] like Fig.10 As shown, the download server 20 includes:
[0169] The memory demultiplexer 2001 is used to parse the source video data in the memory space to obtain the first source video code stream and audio code stream corresponding to the source video data;
[0170] The memory multiplexer 2002 is used to integrate the second source video code stream and the audio code stream to obtain a target video file;
[0171] The video decoder 2003 is used to decode the first source video code stream to obtain a first image frame. Specifically, the video decoder 2003 decompresses and decapsulates the first source video code stream to obtain a decoded frame, and restores the decoded frame to obtain the first image frame.
[0172] The video encoder 2004 is used to encode the second image frame to obtain a second source video code stream. Specifically, the second image frame is compressed by the video encoder to obtain a compressed frame, and the compressed frame is encoded to obtain a second source video code stream.
[0173] In an embodiment of the present application, by creating a memory demultiplexer, a memory multiplexer, a video decoder and a video encoder in the memory space of the download server, the source video data can be parsed and the target video file can be generated in the memory space, which can save disk space and thereby improve disk performance.
[0174] See also Fig.11 , Fig.11 It is a structural schematic diagram of a method for adding a video watermark provided in an embodiment of the present application;
[0175] like Fig.11 As shown, the structure diagram of the method for adding video watermarks includes a source video server and a download server, and the download server includes a memory space, and the memory space includes a memory demultiplexer, a video decoder, a watermark adding tool, a video encoder, and a memory multiplexer. Among them, the source video server provides source video data to the download server. After the download server obtains the source video data, the source video data is input into the memory demultiplexer. The memory demultiplexer parses the source video data to obtain a first video code stream and an audio code stream, and further inputs the first video code stream into the video decoder. After decoding, the video decoder converts the first video code stream into a first image frame, and then inputs the first image frame into the watermark adding tool to obtain a second image frame, that is, to obtain an image frame after adding a watermark, and then further inputs the second image frame into the video encoder. The video encoder converts the second image frame into a second video code stream after encoding. Finally, the second video code stream and the audio code stream are integrated through the memory multiplexer and the target video file is output.
[0176] In the embodiment of the present application, by completing a series of steps of adding watermarks to videos in the memory space, occupying too much storage space of the server is avoided and disk space is saved.
[0177] See also Fig.12 , Fig.12 This is a timing diagram of obtaining a target video file provided by an embodiment of the present application;
[0178] like Fig.12 As shown, including:
[0179] Step S1201: Send a source video download request;
[0180] Specifically, the user terminal sends a source video download request to the download server.
[0181] Step S1202: Send a source video download request;
[0182] Specifically, the download server receives a source video download request from a user terminal, and forwards the source video download request sent by the user terminal to a source video server.
[0183] Step S1203: Returning source video data;
[0184] Specifically, after receiving the source video download request, the source video server responds to the source video download request and returns the source video data corresponding to the source video download request to the download server.
[0185] Step S1204: parsing the source video data in the memory space and adding a watermark, and outputting a target file;
[0186] In an embodiment of the present application, the download server includes a memory space.
[0187] Specifically, the download server receives the source video data, parses the source video data in the memory space of the download server, adds a watermark to the parsed data, and finally outputs the video file with the watermark added, that is, the target video file.
[0188] Step S1205: Return the target video file;
[0189] Specifically, the download server responds to the download source video request of the user terminal and returns the target video file to the user terminal, that is, returns the video file with the watermark added to the user terminal.
[0190] In the embodiment of the present application, by adding a watermark in the memory space of the download server and returning the video file with the watermark added to the user terminal, the space occupied by the disk can be reduced and the life of the disk can be extended.
[0191] See also Fig.13 , Fig.13 It is a structural schematic diagram of a video watermark adding device provided in an embodiment of the present application;
[0192] like Fig.13 As shown, the video watermark adding device 1300 includes:
[0193] The download module 1031 is used to obtain a source video download request and download the source video data to the memory space according to the source video download request;
[0194] The parsing module 1032 is used to parse the source video data in the memory space through the memory demultiplexer to obtain a first source video code stream and an audio code stream corresponding to the source video data;
[0195] The decoding module 1033 is used to decode the first source video code stream to obtain a first image frame;
[0196] A watermark adding module 1034 is used to add a watermark to the first image frame to obtain a second image frame;
[0197] The encoding module 1035 is used to encode the second image frame to obtain a second source video code stream;
[0198] The integration module 1036 is used to integrate the second source video code stream and the audio code stream through the memory multiplexer to obtain a target video file.
[0199] In the embodiments of the present application, the video watermark adding device may be a software module, which includes a number of instructions stored in a memory. The processor may access the memory and call the instructions for execution to complete the video watermark adding method of the above embodiments.
[0200] In the embodiments of the present application, the video watermark adding device can also be constructed by hardware devices. For example, the video watermark adding device can be constructed by one or more chips, and the chips can work in coordination with each other to complete the video watermark adding method described in the above embodiments. For another example, the video watermark adding device can also be constructed by various logic devices, such as a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, or any combination of these components.
[0201] The video watermark adding device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0202] The video watermark adding device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0203] The video watermark adding device provided in the embodiment of the present application can achieve Figure 2 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0204] It should be noted that the above device can execute the video watermark adding method provided in the embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the device embodiment, please refer to the video watermark adding method provided in the embodiment of the present application.
[0205] In an embodiment of the present application, a video watermark adding device is provided, including a download module, which is used to obtain a source video download request, and download the source video data to the memory space according to the source video download request; a parsing module, which is used to parse the source video data in the memory space through a memory demultiplexer to obtain a first source video code stream and an audio code stream corresponding to the source video data; a decoding module, which is used to decode the first source video code stream to obtain a first image frame; a watermark adding module, which adds a watermark to the first image frame to obtain a second image frame; an encoding module, which is used to encode the second image frame to obtain a second source video code stream; and an integration module, which is used to integrate the second source video code stream and the audio code stream through the memory multiplexer to obtain a target video file.
[0206] This application can save disk space and extend the life of the disk by adding a watermark in the memory space.
[0207] See also Fig.14 , Fig.14 It is a schematic diagram of the structure of a download server provided in an embodiment of the present application;
[0208] like Fig.14 As shown, the download server 20 includes one or more processors 2005 and a memory 2006. Fig.14 A processor 2005 is taken as an example.
[0209] The processor 2005 and the memory 2006 may be connected via a bus or other means. Fig.14 The example of connecting through bus is taken in the following.
[0210] A processor, configured to execute the method for adding a video watermark in any embodiment of the present application, comprising:
[0211] Obtain a source video download request, download the source video data to the memory space according to the source video download request, parse the source video data in the memory space through a memory demultiplexer, obtain a first source video code stream and an audio code stream corresponding to the source video data, decode the first source video code stream to obtain a first image frame, add a watermark to the first image frame to obtain a second image frame, encode the second image frame to obtain a second source video code stream, integrate the second source video code stream and the audio code stream through a memory multiplexer to obtain a target video file.
[0212] This application can save disk space and extend the life of the disk by adding a watermark in the memory space.
[0213] The memory 2006 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the method for adding a video watermark in the embodiment of the present invention. The processor 2005 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions and modules stored in the memory 2006, that is, the method for adding a video watermark in the above method embodiment is implemented.
[0214] The memory 2006 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 2006 may optionally include a memory remotely arranged relative to the processor 2005. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0215] One or more modules are stored in the memory 2006, and when executed by one or more processors 2005, the video watermark adding method in any of the above method embodiments is executed, for example, the above described method is executed. Figure 2 The steps shown.
[0216] An embodiment of the present application also provides a computer program product, which includes one or more program codes, and the program code is stored in a non-volatile computer-readable storage medium. A processor of an electronic device reads the program code from the non-volatile computer-readable storage medium, and the processor executes the program code to complete the steps of the video watermark adding method provided in the above embodiment.
[0217] Through the description of the above implementation methods, ordinary technicians in this field can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or by hardware related to program code, and the program can be stored in a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium mentioned above can be a read-only memory, a disk or an optical disk, etc.
[0218] Through the description of the above implementation methods, a person of ordinary skill in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, can also be implemented by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the non-volatile computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0219] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as mentioned above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for adding a video watermark, characterized in that: Applied to a server, the server includes a memory space, a memory demultiplexer, and a memory multiplexer, and the method includes: Obtain a source video download request, and download source video data to the memory space according to the source video download request; Parsing the source video data in the memory space by the memory demultiplexer to obtain a first source video code stream and an audio code stream corresponding to the source video data; Decoding the first source video code stream to obtain a first image frame; adding a watermark to the first image frame to obtain a second image frame; Encoding the second image frame to obtain a second source video code stream; The second source video code stream and the audio code stream are integrated through the memory multiplexer to obtain a target video file.
2. The method according to claim 1, characterized in that The source video download request includes a source video identifier, and downloading the source video data to the memory space according to the source video download request includes: According to the source video identifier, obtain the source video download address; According to the source video download address, the source video data is downloaded to the memory space.
3. The method according to claim 1, characterized in that The server further includes a video decoder, and the decoding of the first source video code stream to obtain a first image frame includes: Decompressing and decapsulating the first source video code stream by the video decoder to obtain a decoded frame; The decoded frame is restored to obtain the first image frame.
4. The method according to claim 1, characterized in that: The source video download request includes a user identifier, and the method further includes: According to the user identifier, acquiring watermark information of the user, the watermark information including a watermark position and watermark text and / or a watermark image; The step of adding a watermark to the first image frame to obtain a second image frame comprises: Performing pixel conversion on the watermark text and / or watermark image to obtain watermark pixels, wherein the watermark pixels are pixels of the watermark text and / or pixels of the watermark image; According to the watermark position, pixels at a position on the first image frame corresponding to the watermark position are replaced with watermark pixels to obtain a second image frame.
5. The method according to claim 4, characterized in that The server further includes a video encoder, and the encoding of the second image frame to obtain a second source video code stream includes: Compressing the second image frame by the video encoder to obtain a compressed frame; The compressed frame is encoded to obtain the second source video code stream.
6. The method according to claim 1, characterized in that The step of integrating the second source video code stream and the audio code stream through the memory multiplexer to obtain a target video file includes: Performing time base alignment on the second source video code stream and the audio code stream through the memory multiplexer to obtain a second source video code stream and audio code stream with time base alignment; According to the specified format, the second source video code stream and audio code stream aligned with the time base are encapsulated to obtain a target video file.
7. A server, characterized in that: include: At least one processor and at least one memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.
8. A video watermarking system, characterized in that: include: A download server, wherein the download server is the server according to claim 7; The source video server is used to provide source video data to the download server.
9. The video watermark adding system according to claim 8, characterized in that: The download server comprises: A memory demultiplexer, used for parsing the source video data in the memory space to obtain a first source video code stream and an audio code stream corresponding to the source video data; A memory multiplexer, used for integrating the second source video code stream and the audio code stream to obtain a target video file; A video decoder, used for decoding the first source video code stream to obtain a first image frame; The video encoder is used to encode the second image frame to obtain a second source video code stream.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the method for adding a video watermark according to any one of claims 1 to 6.
Citation Information
Patent Citations
Stream media digital watermarking system
CN101198045A
Picture watermark adding method, electronic device and computer readable storage medium
CN108769828A
Video transcoding method and device, electronic equipment and storage medium
CN113014926A
Video frame processing method and electronic equipment
CN113038141A
Video watermark adding method and device and electronic equipment
CN114598939A