Video processing method, client and storage medium
By merging and dynamically generating watermark information on the client, combined with multi-threaded downloading and video transcoding, the existing video watermark processing efficiency and security issues are solved, and efficient and secure video watermark processing is achieved.
Patent Information
- Application Number
- CN202410951113.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-24
AI Technical Summary
Existing video watermark processing methods have low efficiency and insufficient security, resulting in redundant server storage and user-modifiable watermarks, which affects the security and traceability of video transmission.
Merge multiple segmented videos on the client and dynamically generate target watermark information based on the target object's watermark configuration information, add it in one go, and combine multi-threaded downloading and video transcoding to ensure the uniqueness and security of the watermark.
It improves the efficiency and security of video processing, ensures the consistency and traceability of watermarks in the video transmission process, and avoids the risk of server storage redundancy and user tampering with watermarks.
Smart Images

Figure CN118695052A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video processing, and in particular to a video processing method, a client and a storage medium. Background Art
[0002] During the process of video downloading and dissemination, watermarks are generally added to the video in order to ensure copyright declaration and traceability.
[0003] At present, there are two ways to add watermarks to videos during the watermark processing process. The first is to keep the source file while calling the server resources to directly compress the watermark into the video when downloading the file. If 1,000 people download a video file, then the file will be compressed thousands of times, and the video content has not changed, only the watermark is different. This method will call to add watermarks at a high frequency, which will cause server storage redundancy and service crash in the long run; the second is to directly use hypertext markup language (html) to add dynamic watermarks on the front-end page, but users can directly modify the html elements, so it is easy for users to remove the watermark. The above video processing methods will result in low efficiency and security of video processing. Summary of the invention
[0004] The present invention provides a video processing method, a client and a storage medium to solve the problems of low efficiency and security of video watermarking in the prior art.
[0005] The technical solution adopted by the present invention is as follows:
[0006] A video processing method is applied to a client, and the method includes: obtaining multiple segmented videos corresponding to a video to be played, and watermark configuration information of a target object corresponding to the video to be played; merging the multiple segmented videos in a playback order to obtain a merged video, and generating target watermark information corresponding to the target object based on the watermark configuration information; and superimposing the target watermark information on the merged video to obtain a target video.
[0007] According to the above technical means, by adding target watermark information to the merged video at one time on the client, and the added target watermark information is information dynamically generated based on the watermark configuration information of the target object, the efficiency of video processing is improved while ensuring the security of the video.
[0008] Further, multiple segmented videos corresponding to the video to be played and watermark configuration information of the target object corresponding to the video to be played are obtained, including: sending a first request carrying the video identification information of the video to be played and the user information of the target object to a server; receiving a download list file of the multiple segmented videos corresponding to the video to be played sent by the server based on the video identification information, and the watermark configuration information sent based on the user information; and downloading the multiple segmented videos based on the download list file.
[0009] According to the above technical means, what the client obtains in the present invention is a download list file, not a segmented video, which can improve the security of the video. In addition, the watermark configuration information is information corresponding to the target object. In this way, the uniqueness of the video can be guaranteed, and the video can be traced during the video transmission process to improve the security of the video.
[0010] Furthermore, the download list file includes download addresses of multiple picture qualities corresponding to each segmented video in the multiple segmented videos; downloading the multiple segmented videos based on the download list file includes: obtaining at least one download thread that can be allocated by the client, and network download information corresponding to the client; based on the network download information, determining the target picture quality from the multiple picture qualities, and generating a target download list file based on the download address of the target picture quality corresponding to each segmented video in the segmented videos; using the at least one download thread, based on the target download list file, downloading the multiple segmented videos.
[0011] According to the above technical means, multiple segmented videos can be downloaded in a multi-threaded manner, which improves the efficiency of video downloading, and can select video streams with appropriate picture quality based on network download information, with high flexibility.
[0012] Further, the target download list file includes a download identifier corresponding to each segmented video in the multiple segmented videos; downloading the multiple segmented videos based on the target download list file includes: if the download times of the target segmented video exceed the preset download times, marking the download identifier corresponding to the target segmented video in the target download list file as download failure; the target segmented video is any segmented video in the multiple segmented videos; if in the target download list file, the download identifiers corresponding to the segmented videos exceeding the preset number in the multiple segmented videos are download failures, determining that the download of the multiple segmented videos has failed; if the download of the multiple segmented videos has failed, re-downloading the segmented videos in the multiple segmented videos whose download identifiers are download failures.
[0013] According to the above technical means, the present invention allows the target segmented video to be downloaded multiple times, and when the preset number of downloads is exceeded, the download mark is marked as a download failure to avoid the problem of the entire download being delayed due to the failure to download a certain segmented video; in addition, if there are more than a preset number of segmented videos that have failed to download, it will be determined that multiple segmented videos have failed to download, so that the continuity between the downloaded multiple segmented videos can be guaranteed; in addition, when re-downloading, what is downloaded is the segmented video with the download mark as a download failure among the multiple segmented videos, so that the repeated downloading of the segmented video with the download mark as a download success among the multiple segmented videos is avoided, and the efficiency of re-downloading can also be improved.
[0014] Furthermore, after merging the multiple segmented videos in the playback order to obtain a merged video, the method further includes: deleting the multiple segmented videos and the download list file.
[0015] According to the above technical means, after merging multiple segmented videos, the multiple segmented videos can be deleted, and the download list file can be deleted, so that the storage resources of the client can be released and data redundancy of the client can be avoided.
[0016] Furthermore, superimposing the target watermark information onto the merged video to obtain the target video includes: performing video transcoding on the merged video, and superimposing the target watermark information onto the transcoded video to obtain the target video.
[0017] According to the above technical means, in the process of transcoding the merged video, the present invention superimposes the target watermark information on the transcoded video, and ensures that the target watermark information always follows the video by changing the video source, thereby ensuring the security of the video.
[0018] Furthermore, superimposing the target watermark information onto the merged video to obtain the target video includes: loading the merged video, and drawing the target watermark information onto the upper layer of the merged video to obtain the target video.
[0019] According to the above technical means, the present invention draws the target watermark information onto the upper layer of the merged video, which can improve the efficiency of adding watermarks.
[0020] A client, comprising:
[0021] Obtain multiple segmented videos corresponding to the video to be played, and watermark configuration information corresponding to the target object;
[0022] Merging the multiple segmented videos in a playback order to obtain a merged video, and generating target watermark information corresponding to the target object based on the watermark configuration information;
[0023] The target watermark information is superimposed on the merged video to obtain the target video.
[0024] A client comprises: a processor, a memory and a communication bus;
[0025] The communication bus is used to realize the communication connection between the processor and the memory;
[0026] The processor is used to execute the computer program stored in the memory to implement the above-mentioned video processing method.
[0027] A computer-readable storage medium storing one or more computer programs, wherein the one or more computer programs can be executed by one or more processors to implement the above-mentioned video processing method
[0028] Beneficial effects of the present invention:
[0029] (1) The present invention improves the efficiency of video processing while ensuring the security of the video by adding target watermark information to the merged video at one time on the client, and the added target watermark information is information dynamically generated based on the watermark configuration information of the target object.
[0030] (2) The present invention can perform multi-threaded downloading of multiple segmented videos, thereby improving the efficiency of video downloading, and can select a video stream with appropriate image quality based on network download information, thus having high flexibility.
[0031] (3) The present invention allows the target segmented video to be downloaded multiple times, and when the number of downloads exceeds a preset number, the download mark is marked as download failure, thereby avoiding the problem of the entire download being delayed due to the failure to download a certain segmented video. In addition, if there are more than a preset number of segmented videos that have failed to download, it will be determined that multiple segmented videos have failed to download, thus ensuring the continuity of the downloaded multiple segmented videos and the integrity of the videos. In addition, when re-downloading, the segmented videos that are downloaded are those marked as download failures among the multiple segmented videos, thus improving the efficiency of re-downloading. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A schematic diagram of a flow chart of a video processing method provided by an embodiment of the present invention;
[0033] Figure 2 A schematic diagram of an exemplary video downloading method provided by an embodiment of the present invention Figure 1 ;
[0034] Figure 3A schematic diagram of an exemplary video downloading method provided by an embodiment of the present invention Figure 2 ;
[0035] Figure 4 A schematic diagram of an exemplary video downloading method provided by an embodiment of the present invention Figure 3 ;
[0036] Figure 5 A schematic diagram of a flow chart of an exemplary video processing method provided by an embodiment of the present invention;
[0037] Figure 6 A schematic diagram of a client structure provided by an embodiment of the present invention Figure 1 ;
[0038] Figure 7 A schematic diagram of a client structure provided by an embodiment of the present invention Figure 2 . DETAILED DESCRIPTION
[0039] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0040] The present invention provides a video processing method, which is implemented by a client, such as Figure 1 As shown, the steps S101 to S103 are included:
[0041] Step S101: Acquire multiple segmented videos corresponding to the video to be played, and watermark configuration information of the target object corresponding to the video to be played.
[0042] In an embodiment of the present invention, the client can obtain multiple segmented videos corresponding to the video to be played and watermark configuration information corresponding to the corresponding target object. Exemplarily, the video to be played can be the video selected for the target object; the watermark configuration information can include information such as the font, font size, interval, transparency, and rotation orientation of the watermark; the video format of the video to be played can be a multimedia container format (mp4 format), and the multiple segmented videos here can be in a transport stream (ts) format.
[0043] Exemplarily, the client may obtain multiple segmented videos and watermark configuration information by sending a Hypertext Transfer Protocol (HTTP) request to the server, and after receiving the request, the server may respond to the client with the corresponding multiple segmented videos and watermark configuration information.
[0044] In the embodiment of the present invention, the client is an electronic device with video processing function, which may be a tablet computer, a laptop computer, a PDA, a desktop computer, etc. The specific client is not limited here.
[0045] Step S102: merge the multiple segmented videos in the order of playback to obtain a merged video, and generate target watermark information corresponding to the target object based on the watermark configuration information.
[0046] In an embodiment of the present invention, after acquiring multiple segmented videos, the client will merge the multiple segmented videos in order to obtain a merged video. An exemplary merging method can be: the client can merge the multiple segmented videos with the help of an audio and video conversion tool (FFmpeg) to obtain a merged video, and the entire merging process can be performed with the help of the content of an M3U8 file (M3U file in UTF-8 encoding format), wherein the M3U8 file records the slice number (segment number) of each segmented video, the number of ts slices (number of segments) corresponding to the video to be played, and other information.
[0047] In an embodiment of the present invention, the client can also generate target watermark information corresponding to the target object based on the watermark configuration information. The target watermark information can be a watermark image, watermark letters, watermark Chinese characters or other watermark information that can represent the target object, for example, Zhang San (10000) is the user name (target object) (user identity ID); illustratively, the implementation method of generating the target watermark information corresponding to the target object based on the watermark configuration information can be: using document.createElement('canvas') to create a canvas environment, setting the height (height) and width (width) attributes to set the watermark size, using the context.clearRect (text transparency) method to set the transparency, using context.fillStyle (text filling method) to set the text format, using context.font to set the text font, and then using the canvas.toDataURL method to return the watermark portable network graphics (png) picture. For example, the setting program involved can be:
[0048] const canvas=document.createElement('canvas');
[0049] / / If the word is less than 32, add 1; if the word is less than 60, add 2; if the word is less than 80, add 4; if the word is less than 100, add 6;
[0050] let buHeight=props.buHeight;
[0051] let buWidth=props.buWidth;
[0052] / / Sometimes letters like g or j are blocked, so you can add some height here;
[0053] canvas.height = buHeight;
[0054] canvas.width = buWidth;
[0055] const context:any=canvas.getContext('2d');
[0056] / / Erase the rectangle of size 200×200 at position (0,0);
[0057] context.clearRect(0, 0, canvas.width, anvas.height);
[0058] context.fillStyle = fontcolor;
[0059] context.font = fontsize + 'px Arial';
[0060] / / top (top alignment); hanging; middle (middle alignment); bottom (bottom alignment); alphabetic is the default value;
[0061] context.textBaseline = props.textBaseline;
[0062] context.translate(props.x, props.y);
[0063] / / Rotation;
[0064] context.rotate((props.rotate * Math.PI) / 180));
[0065] / / Text;
[0066] context.fillText('张三(10000)', 0, 0);
[0067] / / Note that if the background is transparent here, you need to use png return canvas.toDataURL('image / png').
[0068] After the above procedure, the watermark image corresponding to Zhang San can be obtained. In this way, it is possible to dynamically generate a watermark according to the user.
[0069] Step S103, superimpose the target watermark information onto the merged video to obtain the target video.
[0070] In an embodiment of the present invention, after the client obtains the target watermark information and the merged video, it can superimpose the target watermark information onto the merged video at one time to obtain the target video. In this way, it is possible to add a watermark through a filter at one time, without adding a watermark to each segmented video and storing it. The addition speed is definitely improved compared to the traditional method.
[0071] Exemplarily, the client can select the method of superimposing the target watermark information onto the merged video based on the confidentiality level or grade of the video to be played. Here, it can be set based on actual needs and application scenarios, and the present invention does not make any limitations in this regard.
[0072] Compared with the problems of low efficiency and security of video watermarking in related technologies, the present invention adds target watermark information to the merged video at one time, and the added target watermark information is dynamically generated based on the watermark configuration information of the target object, thereby improving the efficiency of video processing while ensuring the security of the video. In addition, the target watermark information is added on the client side, and the watermark function can still be realized without suppressing the watermark on the server, which has certain use value and commercial prospects.
[0073] In some embodiments, when the client performs the above step S101, Figure 2 As shown, the following steps S201 to S203 may also be included:
[0074] Step S201: Send a first request carrying video identification information of a video to be played and user information of a target object to a server.
[0075] In an embodiment of the present invention, the client may send a first request carrying video identification information of a video to be played and user information of a target object to the server. The video identification information may be an identifier of the video to be played, based on which the video to be played may be locked. The user information may be a user key, a user login password, or other information capable of verifying the identity of the user. The first request may be a Hypertext Transfer Protocol (HTTP) request.
[0076] Exemplarily, the client may send an HTTP request carrying an identifier of the video to be played and a user key (token) to the server.
[0077] Step S202: receiving a download list file of multiple segmented videos corresponding to the to-be-played video sent by the server based on the video identification information, and watermark configuration information sent based on the user information.
[0078] In an embodiment of the present invention, after receiving an HTTP request, the server can parse the user information (token) from the HTTP request, and then use the user information to obtain the session identifier (sessionId). From the session, the user's work number, name and other information can be obtained to verify whether the user information has the right to download the video, and if the user has the right to download the video, the user's corresponding watermark configuration information is placed in the session so that the client can obtain it.
[0079] In an embodiment of the present invention, the server can also parse the video identification information from the HTTP request, and then determine the video to be played, and then generate a playlist.json file (download list file) containing metadata. Exemplarily, the field download (download identification) in the JSON file is used to mark whether this segment is downloaded successfully, and also contains M3U8 file media stream information, including #EXT-X-MEDIA-NUMBER identifies the number of slices 1000, #EXT-X-MEDIA-SEQUENCE identifies the slice sequence number 0, and URL identifies each slice (segmented video) address http...ts, and the background server divides the original video file input.mp4 stream (video to be played) into 1000 ts segments, and each segment provides http download.
[0080] Exemplarily, the media stream information of an M3U8 file may be:
[0081] #EXTM3U
[0082] #EXT-X-VERSION:3
[0083] #EXT-X-TARGETDURATION:10
[0084] #EXT-X-MEDIA-NUMBER:1000
[0085] #EXT-X-MEDIA-SEQUENCE:0
[0086] #EXTINF:10.000000,
[0087] http: / / www.example.com / video_00001.ts
[0088] #EXTINF:10.000000,
[0089] http: / / www.example.com / video_00002.ts
[0090] #EXTINF:10.000000,
[0091] http: / / www.example.com / video_00003.ts
[0092] …
[0093] #EXTINF:10.000000,
[0094] http: / / www.example.com / video_01000.ts.
[0095] In this way, the server can send the playlist.json file (download list file) to the client.
[0096] In this way, the client can receive the download list file and watermark configuration information.
[0097] Step S203: Download multiple segmented videos based on the download list file.
[0098] In an embodiment of the present invention, after obtaining the download list file, the client can perform multi-threaded parallel downloading of multiple segmented videos based on the download addresses included in the download list file.
[0099] In this way, what the client obtains in the present invention is a download list file, not a segmented video, which can improve the security of the video. In addition, the watermark configuration information is information corresponding to the target object. In this way, the uniqueness of the video can be guaranteed, and the video can be traced during the video transmission process to improve the security of the video.
[0100] In some embodiments, the download list file includes download addresses of multiple video quality corresponding to each segmented video in the multiple segmented videos; when the client executes the above step S203, if Figure 3 As shown, the following steps S301 to S303 may also be performed:
[0101] Step S301: Obtain at least one download thread that can be allocated to the client, and network download information corresponding to the client.
[0102] In an embodiment of the present invention, the client can obtain at least one download thread that can be allocated to it. The threads that can be allocated to the client are related to the device performance of the client, and the device performance is determined by the graphics processing unit (GPU) and the central processing unit (CPU) on the client. The network download information can be the network bandwidth and device performance currently corresponding to the client. Considering the different network bandwidths and device performances, the client download speed is also different.
[0103] Step S302: based on the network download information, determine the target image quality from multiple image qualities, and generate a target download list file based on the download address of each segmented video corresponding to the target image quality in the segmented video.
[0104] In an embodiment of the present invention, the download list file includes download addresses of multiple image qualities corresponding to each segmented video in the multiple segmented videos, and the download address of the most suitable target image quality is selected to download the segmented video of the corresponding image quality in consideration of the current network bandwidth and device performance (network download information) corresponding to the client. The different image qualities refer to different resolutions and bit rates of the segmented videos.
[0105] For example, the client will select the most suitable video stream based on the HTTP live streaming (HLS) protocol by measuring the current network bandwidth and device performance. If the bandwidth is sufficient, the client can select a high-resolution and high-bitrate video stream; if the bandwidth is insufficient, it can select a low-resolution and low-bitrate video stream.
[0106] Step S303: using at least one download thread to download multiple segmented videos based on the target download list file.
[0107] In an embodiment of the present invention, the client may utilize at least one download thread to download multiple segmented videos based on a target download list file.
[0108] For example, if the number of at least one download thread is 32, and the number of multiple segmented videos is 1000, then each thread can be allocated 31 segments (segmented videos) to download. In this case, the remaining 8 segments have not yet been allocated to threads. At this time, the allocation of the remaining segments depends on the download speed of the threads. For example, thread 8 completes the download first, and thread 8 will receive 1 segment for downloading the remaining 8 segments, that is, the first to complete will receive it first, so that each thread can be guaranteed to download evenly. Of course, it can also be allocated in sequence, that is, first allocate the first 32 of the 1000 segmented videos to the download threads, and then which thread finishes which thread receives it, so that it can be guaranteed that when multiple segmented videos are downloaded, the download time of each thread differs by one segmented video.
[0109] In this way, multiple segmented videos can be downloaded in multi-threaded manner, which improves the efficiency of video downloading, and can select video streams with appropriate picture quality based on network download information, which is highly flexible.
[0110] In some embodiments, the target download list file includes a download identifier corresponding to each segmented video in the plurality of segmented videos; when the client executes the above step S303 of "downloading the plurality of segmented videos based on the target download list file", as Figure 4 As shown, the following steps S401 to S403 may be included:
[0111] Step S401: if the number of downloads of the target segmented video exceeds the preset number of downloads, the download identifier corresponding to the target segmented video in the target download list file is marked as download failure; the target segmented video is any segmented video among the multiple segmented videos.
[0112] In an embodiment of the present invention, the preset number of downloads may be 5 times, 7 times or other values. Considering that the failure to download a certain segmented video may cause the entire download to lag, the preset number of downloads is set. If the number of downloads of the target segmented video exceeds the preset number of downloads, the download identifier corresponding to the target segmented video in the target download list file is marked as download failure. In the target download list file, multiple download addresses are set for segmented videos of the same image quality. If a download address fails to download, the download will continue from the backup download address until the download is successful (the download of the corresponding segmented video will be marked as download success), or after the download number exceeds the preset number of downloads, the download identifier of the corresponding segmented video will be marked as download failure.
[0113] For example, assuming that the preset number of downloads is 5 times, if a download error occurs in a certain slice (segmented video), the erroneous video slice will be deleted, and the slice's backup download server will be used for download. If the maximum number of failures exceeds 5 times, the download of the slice will be abandoned, and download will be modified to download: false (download indicator: failure), and the slice will be skipped when merging video streams.
[0114] Step S402: If in the target download list file, the download marks corresponding to the segmented videos exceeding the preset number among the multiple segmented videos are download failures, it is determined that the download of the multiple segmented videos has failed.
[0115] In the embodiment of the present invention, the preset number may be 2, 5, or other values. The smaller the preset number is, the higher the requirement for video continuity is, and vice versa.
[0116] In an embodiment of the present invention, if the download mark corresponding to the segmented videos exceeding the preset number among the multiple segmented videos in the target download list file is a download failure, it can be determined that the download of the multiple segmented videos has failed. In this way, the integrity of the video merged based on the multiple segmented videos is guaranteed to be higher.
[0117] Step S403: if the download of multiple segmented videos fails, re-download the segmented videos among the multiple segmented videos that are marked as failed to download.
[0118] In an embodiment of the present invention, if multiple segmented videos fail to be downloaded, the segmented videos marked as failed to be downloaded among the multiple segmented videos can be downloaded again. Exemplarily, when the number of errors exceeds the allowed range, it is determined that the download of the entire file has failed, but when re-downloading, as long as the header file (playlist.json file) and the segments (segmented videos) are not manually deleted by the user, the download can be continued, and there is no need to repeatedly download the segments that have been successfully downloaded.
[0119] In this way, the present invention allows the target segmented video to be downloaded multiple times, and when the preset number of downloads is exceeded, the download mark is marked as download failure to avoid the problem of the entire download being delayed due to the failure to download a certain segmented video; in addition, if there are more than a preset number of segmented videos that have failed to download, it will be determined that multiple segmented videos have failed to download, thus ensuring the continuity of the downloaded multiple segmented videos; in addition, when re-downloading, the segmented videos that are downloaded with the download mark as download failure among the multiple segmented videos are downloaded, thus also improving the efficiency of re-downloading.
[0120] In some embodiments, after executing the above step S102 of "merging the multiple segmented videos in the playback order to obtain a merged video", the client may further execute the following steps: deleting the multiple segmented videos and downloading the list file.
[0121] For example, after the merge is completed, the client can clear the temporary *.ts slice files (multiple segmented videos) and playlist.json header file (download list file) to ensure that the user has no perception. This step is transparent to the user and will not affect the user experience. It is no different from downloading videos normally.
[0122] In an embodiment of the present invention, after merging multiple segmented videos, the client deletes the multiple segmented videos used for merging and the download list file, so that the storage resources of the client can be released and data redundancy of the client can be avoided.
[0123] In some embodiments, when executing the above step S103, the client may further execute the following steps: transcoding the merged video, and superimposing the target watermark information on the transcoded video to obtain the target video.
[0124] In an embodiment of the present invention, the client transcodes the merged video into the source video format, usually an H.264 encoded output.mp4 file, and in this process, uses an overlay filter to overlay the watermark image onto the video. The position and style of the watermark can be adjusted as needed to ensure information security and copyright protection.
[0125] In this way, during the process of transcoding the merged video, the target watermark information is superimposed on the transcoded video. By changing the video source, the target watermark information is ensured to always follow the video, thereby ensuring the security of the video. Compared with adding watermarks in HTML, the security is greatly increased.
[0126] Of course, the embedding of the target watermark information can be adjusted according to the confidentiality level of the video to ensure that the watermark always follows the video. Through this process, segmented videos can be processed efficiently and the integrity and security of the content can be protected.
[0127] In some embodiments, when executing the above step S103, the client may further execute the following steps: loading the merged video, and drawing the target watermark information to the upper layer of the merged video to obtain the target video.
[0128] In the embodiment of the present invention, if the video has a lower confidentiality level, the video source may not be changed, that is, the md5 may not be modified, and the video may be directly loaded into the HTML page, and the video content may be read using a canvas container, and the watermark may be drawn on the upper layer, so that the watermark may be added more quickly. In this way, the video and the watermark may be distinguished.
[0129] In this way, the present invention draws the target watermark information onto the upper layer of the merged video, which can improve the efficiency of adding watermarks.
[0130] like Figure 5 As shown, a flowchart of an exemplary video processing method is provided, and an exemplary implementation method includes the following steps S501 to S505:
[0131] Step S501: The client sends a video download request to a backend server, carrying a key.
[0132] Here, the client can send a download video request (first request) to the background server, and the background server receives the download video request carrying a key (token) and video identification information, and generates a playlist JSON file (playlist.json) containing metadata according to the video identification information in the download video request (download list file corresponding to the video to be played). In the JSON file, there is a mark for downloading whether the available media stream is downloaded successfully, and breakpoint continuation is realized. It also includes M3U8 file information including the number of slices (the number of segmented videos), the sequence number of the slices (the order of the segmented videos), and each slice address (including video streams of different resolutions and bit rates), and the background server divides the original video file stream (video to be played) into multiple ts segments (segmented videos), and each segment provides http download. Wherein, if the original video file stream is in mp4 format, it will be converted to M3U8 format first, and then converted to ts format.
[0133] Step S502: Return the header file, obtain the session through the key, and put the user information in.
[0134] Here, after receiving the video download request carrying the key (token), the background server obtains the user information. If the user has the authority to download the video, the user information corresponding to the user (watermark configuration (watermark configuration information props)) is placed in the session, and the header file (playlist.json, playlist JSON file) is returned to the client.
[0135] Step S503: The client parses the header file, assigns the segmented videos to threads, and executes the download plan according to the download strategy and bandwidth.
[0136] Here, the client downloads the header file requested by the video, uses the FFmpeg tool to parse the file to obtain the video stream information, and implements multi-threaded parallel downloading based on the Uniform Resource Locator (URL) (download address) in the header file. Each segmented video is usually a video file of several seconds to more than ten seconds. The client will dynamically modify the download bit rate and resolution according to the bandwidth. Each thread will be assigned a corresponding number of download segment sets and their corresponding download addresses. If a segment download error occurs, the erroneous video segment will be deleted, and the backup download server of the segment will be used for downloading. If the maximum number of failures is exceeded, the download of the segment will be abandoned, and the segment will be skipped when merging the video streams.
[0137] Step S504: The client obtains user information and watermark configuration through the session and constructs a watermark map.
[0138] Here, after the download queue ends, the client obtains the watermark configuration (watermark configuration information) through the session, and obtains the watermark font, font size, interval, transparency, rotation orientation and other configurations, and then creates a canvas environment, uses fillText, font, etc. to fill in text, color, font size transparency, etc., and then returns the watermark image (target watermark information).
[0139] Step S505: Merge and transcode the segmented videos and add watermarks using filters.
[0140] Here, after the client completes downloading the ts sliced video (multiple segmented videos) and returns the watermark image, it uses the FFmpeg tool to merge them. The merging order is specified by the slice sequence number in the initial header file, with smaller numbers in front and larger numbers in the back, such as from video_00001 to video_01000. After the merger is completed, all the temporary slice files and header files will be deleted. From the user's perspective, it is completely imperceptible, and there is no difference from the normal downloading of videos at the operational level. Then, after the merged video is restored according to the source video format through transcoding, such as converting the file to an H.264-encoded mp4 file (from ts format to M3U8 format, and then to mp4 format), and using the overlay filter to apply the watermark image, the watermark can be pressed into the video according to the video confidentiality level to ensure that the watermark always follows the video. If the video with a low confidentiality level does not need to change the video source, that is, does not modify the md5, directly load the video into the html page, use the canvas container to read the video content, and draw the watermark on the upper layer, which can add watermarks more quickly and with higher flexibility.
[0141] The present invention provides a video processing method, which is applied to a client, and obtains multiple segmented videos corresponding to a to-be-played video, and watermark configuration information of a target object corresponding to the to-be-played video; merges the multiple segmented videos in a playback order to obtain a merged video, and generates target watermark information corresponding to the target object based on the watermark configuration information; and superimposes the target watermark information on the merged video to obtain the target video. The present invention improves the efficiency of video processing while ensuring the security of the video by adding target watermark information to the merged video at one time, and the added target watermark information is information dynamically generated based on the watermark configuration information of the target object.
[0142] The embodiment of the present invention provides a client 6, such as Figure 6 As shown, including:
[0143] The acquisition module 61 is used to acquire multiple segmented videos corresponding to the video to be played, and watermark configuration information corresponding to the target object;
[0144] A merging module 62 is used to merge the multiple segmented videos in the playback order to obtain a merged video, and generate target watermark information corresponding to the target object based on the watermark configuration information;
[0145] The superimposition module 63 is used to superimpose the target watermark information onto the merged video to obtain the target video.
[0146] In one embodiment of the present invention, the acquisition model 81 is also used to send a first request carrying video identification information of a video to be played and user information of a target object to a server; receive a download list file of multiple segmented videos corresponding to the video to be played sent by the server based on the video identification information, and watermark configuration information sent based on user information; and download multiple segmented videos based on the download list file.
[0147] In one embodiment of the present invention, the download list file includes download addresses of multiple image qualities corresponding to each segmented video in a plurality of segmented videos; the acquisition model 61 is also used to obtain at least one download thread that can be allocated by the client, and the network download information corresponding to the client; based on the network download information, the target image quality is determined from the multiple image qualities, and a target download list file is generated based on the download address of the target image quality corresponding to each segmented video in the segmented videos; and the plurality of segmented videos are downloaded based on the target download list file using at least one download thread.
[0148] In one embodiment of the present invention, the target download list file includes a download identifier corresponding to each segmented video in a plurality of segmented videos; the acquisition model 61 is also used to mark the download identifier corresponding to the target segmented video in the target download list file as a download failure if the download times of the target segmented video exceed a preset download times; the target segmented video is any segmented video in the plurality of segmented videos; if in the target download list file, the download identifiers corresponding to the segmented videos exceeding a preset number in the plurality of segmented videos are download failures, it is determined that the download of the plurality of segmented videos has failed; if the download of the plurality of segmented videos has failed, the segmented videos in the plurality of segmented videos whose download identifiers are download failures are re-downloaded.
[0149] In one embodiment of the present invention, the merging module 62 is further used to delete multiple segmented videos and download list files.
[0150] In one embodiment of the present invention, the superposition module 63 is further used to perform video transcoding on the merged video, and superimpose the target watermark information on the transcoded video to obtain the target video.
[0151] In one embodiment of the present invention, the superposition module 63 is further used to load the merged video and draw the target watermark information to the upper layer of the merged video to obtain the target video.
[0152] The present invention provides a client, which obtains multiple segmented videos corresponding to a video to be played, and watermark configuration information of a target object corresponding to the video to be played; merges the multiple segmented videos in a playback order to obtain a merged video, and generates target watermark information corresponding to the target object based on the watermark configuration information; superimposes the target watermark information on the merged video to obtain the target video. The present invention improves the efficiency of video processing while ensuring the security of the video by adding target watermark information to the merged video at one time, and the added target watermark information is information dynamically generated based on the watermark configuration information of the target object.
[0153] The embodiment of the present invention provides a client 6, such as Figure 7 As shown, the client includes: a processor 71, a memory 72 and a communication bus 73;
[0154] A communication bus 73, used to realize the communication connection between the processor 71 and the memory 72;
[0155] The processor 71 is used to execute the computer program stored in the memory 72 to implement the above-mentioned video processing method.
[0156] An embodiment of the present invention provides a computer-readable storage medium, which stores one or more computer programs, and the one or more computer programs can be executed by one or more processors to implement the above-mentioned video processing method. The computer-readable storage medium can be a volatile memory (volatile memory), such as a random access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (Read-Only Memory, ROM), a flash memory (flash memory), a hard disk (Hard Disk Drive, HDD) or a solid-state drive (Solid-State Drive, SSD); or it can be a respective device including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.
[0157] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0158] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0159] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0161] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A video processing method, characterized in that: Applied to a client, the method comprises: Acquire multiple segmented videos corresponding to the video to be played, and watermark configuration information of the target object corresponding to the video to be played; Merging the multiple segmented videos in a playback order to obtain a merged video, and generating target watermark information corresponding to the target object based on the watermark configuration information; The target watermark information is superimposed on the merged video to obtain the target video.
2. The method according to claim 1, characterized in that The step of obtaining a plurality of segmented videos corresponding to the video to be played, and watermark configuration information of a target object corresponding to the video to be played, includes: Sending a first request carrying the video identification information of the video to be played and the user information of the target object to the server; Receiving a download list file of the plurality of segmented videos corresponding to the to-be-played video sent by the server based on the video identification information, and watermark configuration information sent based on the user information; Based on the download list file, the plurality of segmented videos are downloaded.
3. The method according to claim 2, characterized in that The download list file includes download addresses of multiple image qualities corresponding to each segmented video in the multiple segmented videos; and downloading the multiple segmented videos based on the download list file includes: Acquire at least one download thread that can be allocated to the client, and network download information corresponding to the client; Based on the network download information, determine a target image quality from the multiple image qualities, and generate a target download list file based on a download address corresponding to the target image quality for each segmented video in the segmented videos; The plurality of segmented videos are downloaded by utilizing the at least one download thread based on the target download list file.
4. The method according to claim 3, characterized in that The target download list file includes a download identifier corresponding to each segmented video in the plurality of segmented videos; The downloading of the plurality of segmented videos based on the target download list file comprises: If the number of downloads of the target segmented video exceeds the preset number of downloads, marking the download identifier corresponding to the target segmented video in the target download list file as download failure; the target segmented video is any segmented video among the multiple segmented videos; If, in the target download list file, the download identifiers corresponding to the segmented videos exceeding a preset number in the multiple segmented videos are the download failures, determining that the download of the multiple segmented videos has failed; If the download of the multiple segmented videos fails, the segmented videos whose download marks indicate the failed downloads are downloaded again.
5. The method according to claim 2, characterized in that: After merging the multiple segmented videos in the playback order to obtain a merged video, the method further includes: The plurality of segmented videos and the download list file are deleted.
6. The method according to any one of claims 1 to 5, characterized in that: The step of superimposing the target watermark information onto the merged video to obtain the target video includes: The merged video is transcoded, and the target watermark information is superimposed on the transcoded video to obtain the target video.
7. The method according to any one of claims 1 to 5, characterized in that: The step of superimposing the target watermark information onto the merged video to obtain the target video includes: The merged video is loaded, and the target watermark information is drawn to the upper layer of the merged video to obtain the target video.
8. A client, characterized in that: include: An acquisition module is used to acquire multiple segmented videos corresponding to the video to be played, and watermark configuration information corresponding to the target object; A merging module, used to merge the multiple segmented videos in a playback order to obtain a merged video, and generate target watermark information corresponding to the target object based on the watermark configuration information; The superposition module is used to superimpose the target watermark information onto the merged video to obtain the target video.
9. A client, characterized in that: include: processor, memory, and communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute the computer program stored in the memory to implement the video processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more computer programs, and the one or more computer programs can be executed by one or more processors to implement the video processing method according to any one of claims 1 to 7.
