Video processing method, device, electronic device and storage medium

By judging the video file size on the user side and processing it using preset compression methods, the problem of video file size exceeding the server storage threshold is solved, automatic video size adjustment is realized, user operation complexity is reduced, and user experience is improved.

CN116208789BActive Publication Date: 2025-01-21SHANGHAI ZHONG YUAN NETWORK CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310198149.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2025-01-21
Estimated Expiration
2043-03-03

AI Technical Summary

Technical Problem

When users record and upload videos, the video file size may exceed the server's storage threshold, causing the server to be unable to store and complete authentication, increasing the complexity of user operations and reducing the user experience.

Method used

By judging whether the size of the video file to be uploaded is greater than the maximum file size allowed to be stored by the server, if it exceeds, the video will be processed using the preset compression method until the file size is not greater than the threshold, and the processed video will be uploaded to the server.

Benefits of technology

It realizes automatic adjustment of video file size, reduces the frequency of user adjustments, reduces the complexity of user operations and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116208789B_ABST
    Figure CN116208789B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a video processing method, device, electronic device and storage medium, which are applied to electronic devices, and a web page is deployed in the electronic device. The method includes: judging whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server; if the file size of the first video is greater than the first threshold, the first video is processed according to a preset compression method to obtain a second video; wherein the file size of the second video is not greater than the first threshold; and the second video is sent to the first server so that the first server receives and stores the second video. Based on this, the web page can automatically adjust the size of the video without the user having to adjust the file size of the video multiple times, which can reduce the complexity of user operations and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and in particular to a video processing method, device, electronic device and storage medium. Background Art

[0002] At present, when users register a platform account, they often need to record a video and upload the video to the server through the web page. The server can store the video and authenticate the user based on the video. For example, the user records an authentication video containing specific body movements and uploads the authentication video to the server through the web page. Accordingly, the server can perform live authentication on the user based on the authentication video; or the user records an authentication video of himself holding an identity certificate and uploads the authentication video to the server through the web page. Accordingly, the server can authenticate the user based on the authentication video.

[0003] However, the file size of the video recorded by the user may exceed the preset threshold, where the preset threshold represents the maximum file size of a single video that the server allows to store. In this case, the server cannot store the video and cannot complete the authentication. In the related art, the user needs to adjust the file size of the recorded video by himself so that the file size of the recorded video does not exceed the storage limit of the server. For example, the user can re-record the video by changing the device.

[0004] Based on the above method, the user may need to adjust the file size of the recorded video multiple times, which increases the complexity of the user operation and reduces the user experience. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a video processing method, device, electronic device and storage medium to reduce the complexity of user operations and improve user experience. The specific technical solution is as follows:

[0006] In a first aspect of the implementation of the present application, a video processing method is first provided, which is applied to an electronic device, wherein a web page is deployed in the electronic device, and the method includes:

[0007] Determine whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server;

[0008] If the file size of the first video is greater than the first threshold, the first video is processed according to a preset compression method to obtain a second video; wherein the file size of the second video is not greater than the first threshold;

[0009] The second video is sent to the first server, so that the first server receives and stores the second video.

[0010] Optionally, the processing the first video according to a preset compression method to obtain the second video includes:

[0011] Based on a preset compression algorithm and / or a pre-trained video compression network model, the first video is processed to obtain a second video;

[0012] Among them, the preset compression algorithm is used to adjust the preset attributes of the video; the preset attributes include at least one of the frame rate, bit rate and resolution; the video compression network model is used to compress motion information and / or residual information in the video.

[0013] Optionally, before processing the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video, the method further includes:

[0014] Determine whether the file size of the first video is greater than a second threshold; wherein the second threshold represents the maximum file size of a single video allowed to be compressed by the preset compression algorithm;

[0015] The processing of the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video includes:

[0016] When the file size of the first video is greater than the second threshold, segmenting the first video to obtain a plurality of first video segments; wherein the file size of any first video segment is not greater than the second threshold;

[0017] For each first video segment, compress the first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment;

[0018] The second video segments are spliced ​​in the order of timestamps to obtain a second video.

[0019] Optionally, for each first video segment, compressing the video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment includes:

[0020] For each first video clip, when the first attribute information of the first video clip for the preset attribute is greater than the preset attribute threshold, adjust the preset attribute of the first video clip so that the adjusted attribute information of the first video clip is not greater than the preset attribute threshold, and obtain the second video clip corresponding to the first video clip.

[0021] Optionally, the method further includes:

[0022] For each first video segment, when the first attribute information is not greater than the preset attribute threshold, the first video segment is input into the video compression network model to obtain a second video segment corresponding to the first video segment.

[0023] Optionally, the step of splicing the second video clips in the order of the timestamps to obtain the second video includes:

[0024] splicing the second video clips in the order of timestamps to obtain a third video;

[0025] Determine whether the file size of the third video is greater than the first threshold;

[0026] If the file size of the third video is greater than the first threshold, for each first video segment, input the first video segment into the video compression network model to obtain a third video segment corresponding to the first video segment; splice the third video segments in the order of timestamps to obtain a second video;

[0027] Alternatively, if the file size of the third video is greater than the first threshold, for each second video segment, the second video segment is input into the video compression network model to obtain a fourth video segment corresponding to the second video segment; and the fourth video segments are spliced ​​in the order of timestamps to obtain the second video;

[0028] Alternatively, if the file size of the third video is greater than the first threshold, the first video is input into the video compression network model to obtain a second video;

[0029] Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

[0030] Optionally, the method further includes:

[0031] When the file size of the first video is not greater than the second threshold, the first video is compressed based on the preset compression algorithm and / or the video compression network model to obtain a second video.

[0032] Optionally, compressing the first video based on the preset compression algorithm and / or the video compression network model to obtain the second video includes:

[0033] When the second attribute information of the first video for the preset attribute is greater than the preset attribute threshold, adjust the preset attribute of the first video so that the attribute information of the adjusted first video is not greater than the preset attribute threshold, thereby obtaining a fourth video;

[0034] Based on the fourth video, a second video is obtained.

[0035] Optionally, obtaining the second video based on the fourth video includes:

[0036] Determine whether the file size of the fourth video is greater than the first threshold;

[0037] If the file size of the fourth video is greater than the first threshold, the fourth video is input into the video compression network model to obtain the second video.

[0038] Optionally, before processing the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video, the method further includes:

[0039] Determine whether there is a compression code file in the preset cache space; wherein the compression code file includes: a code file of the preset compression algorithm and a code file of the video compression network model;

[0040] If the compressed code file exists in the preset cache space, obtaining the compressed code file from the preset cache space;

[0041] If the compressed code file does not exist in the preset cache space, obtaining the compressed code file from the second server and storing it in the preset cache space;

[0042] The processing of the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video includes:

[0043] The obtained compression code file is loaded to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video.

[0044] Optionally, the processing the first video according to a preset compression method to obtain the second video includes:

[0045] The first video is processed in a preset compression method through a compression thread to obtain a second video; wherein the compression thread is asynchronous with the main thread of the web page.

[0046] In a second aspect of the implementation of the present application, a video processing device is further provided, which is applied to an electronic device, wherein a web page is deployed in the electronic device, and the device includes:

[0047] A first judgment module is used to judge whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server;

[0048] a video processing module, configured to process the first video according to a preset compression method to obtain a second video if the file size of the first video is greater than the first threshold; wherein the file size of the second video is not greater than the first threshold;

[0049] The video sending module is used to send the second video to the first server so that the first server receives and stores the second video.

[0050] Optionally, the video processing module includes:

[0051] A video processing submodule is used to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video; wherein the preset compression algorithm is used to adjust preset attributes of the video; the preset attributes include at least one of frame rate, bit rate and resolution; and the video compression network model is used to compress motion information and / or residual information in the video.

[0052] Optionally, the device further comprises:

[0053] A second judgment module is used to judge whether the file size of the first video is greater than a second threshold before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video; wherein the second threshold represents the maximum file size of a single video allowed to be compressed by the preset compression algorithm;

[0054] The video processing submodule comprises:

[0055] a video segmentation unit, configured to segment the first video to obtain a plurality of first video segments when the file size of the first video is greater than the second threshold, wherein the file size of any first video segment is not greater than the second threshold;

[0056] A video segment compression unit, configured to compress each first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment;

[0057] The video segment splicing unit is used to splice the second video segments in the order of timestamps to obtain a second video.

[0058] Optionally, the video segment compression unit is specifically used to adjust the preset attribute of each first video segment, if the first attribute information of the first video segment for the preset attribute is greater than a preset attribute threshold, so that the attribute information of the adjusted first video segment is not greater than the preset attribute threshold, and obtain a second video segment corresponding to the first video segment.

[0059] Optionally, the device further comprises:

[0060] The video segment input module is used to input each first video segment into the video compression network model to obtain a second video segment corresponding to the first video segment when the first attribute information is not greater than the preset attribute threshold.

[0061] Optionally, the video segment splicing unit is specifically configured to splice the second video segments in the order of timestamps to obtain a third video;

[0062] Determine whether the file size of the third video is greater than the first threshold;

[0063] If the file size of the third video is greater than the first threshold, for each first video segment, input the first video segment into the video compression network model to obtain a third video segment corresponding to the first video segment; splice the third video segments in the order of timestamps to obtain a second video;

[0064] Alternatively, if the file size of the third video is greater than the first threshold, for each second video segment, the second video segment is input into the video compression network model to obtain a fourth video segment corresponding to the second video segment; and the fourth video segments are spliced ​​in the order of timestamps to obtain the second video;

[0065] Alternatively, if the file size of the third video is greater than the first threshold, the first video is input into the video compression network model to obtain a second video;

[0066] Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

[0067] Optionally, the device further comprises:

[0068] The video compression processing module compresses the first video based on the preset compression algorithm and / or the video compression network model to obtain a second video when the file size of the first video is not greater than the second threshold.

[0069] Optionally, the video compression processing module includes:

[0070] A preset attribute adjustment submodule, configured to adjust the preset attribute of the first video when the second attribute information of the first video for the preset attribute is greater than the preset attribute threshold, so that the attribute information of the adjusted first video is not greater than the preset attribute threshold, thereby obtaining a fourth video;

[0071] The second video acquisition submodule is used to obtain the second video based on the fourth video.

[0072] Optionally, the second video acquisition submodule is specifically used to determine whether the file size of the fourth video is greater than the first threshold;

[0073] If the file size of the fourth video is greater than the first threshold, the fourth video is input into the video compression network model to obtain the second video.

[0074] Optionally, the device further comprises:

[0075] A third judgment module is used to judge whether there is a compression code file in the preset cache space before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video; wherein the compression code file includes: a code file of the preset compression algorithm and a code file of the video compression network model;

[0076] A first acquisition module, configured to acquire the compressed code file from the preset cache space if the compressed code file exists in the preset cache space;

[0077] A second acquisition module, configured to acquire the compressed code file from a second server and store it in the preset cache space if the compressed code file does not exist in the preset cache space;

[0078] The video processing submodule comprises:

[0079] A compression code file loading unit is used to load the obtained compression code file to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video.

[0080] Optionally, the video processing module is specifically used to process the first video according to a preset compression method through a compression thread to obtain a second video; wherein the compression thread is asynchronous with the main thread of the web page.

[0081] In a third aspect of the implementation of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0082] Memory, used to store computer programs;

[0083] The processor is used to implement any of the above-mentioned video processing method steps when executing the program stored in the memory.

[0084] In another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned video processing methods is implemented.

[0085] In another aspect of the implementation of the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned video processing methods.

[0086] A video processing method provided in an embodiment of the present application is applied to an electronic device, wherein a web page is deployed in the electronic device, and the method determines whether the file size of a first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by a first server; if the file size of the first video is greater than the first threshold, the first video is processed according to a preset compression method to obtain a second video; wherein the file size of the second video is not greater than the first threshold; and the second video is sent to the first server so that the first server receives and stores the second video.

[0087] Based on the above processing, when the file size of the video (i.e., the first video) uploaded by the user to the server (i.e., the first server) through the web page is larger than the maximum file size of a single video allowed to be stored by the server (i.e., the first threshold), the web page can process the first video according to the preset compression method so that the file size of the processed video (i.e., the second video) is not larger than the first threshold. Accordingly, the server can store the second video. In this way, the web page can automatically adjust the size of the video without the user having to adjust the file size of the video multiple times, which can reduce the complexity of user operations and improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0089] Figure 1 A first flow chart of a video processing method provided in an embodiment of the present application;

[0090] Figure 2 A second flow chart of the video processing method provided in an embodiment of the present application;

[0091] Figure 3 A third flow chart of the video processing method provided in an embodiment of the present application;

[0092] Figure 4 A fourth flow chart of the video processing method provided in an embodiment of the present application;

[0093] Figure 5 A schematic diagram of the structure of a video processing device provided in an embodiment of the present application;

[0094] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0095] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0096] At present, when users register a platform account, they often need to record a video and upload the video to the server through the web page. The server can store the video and authenticate the user based on the video. For example, the user records an authentication video containing specific body movements and uploads the authentication video to the server through the web page. Accordingly, the server can perform live authentication on the user based on the authentication video; or the user records an authentication video of himself holding an identity certificate and uploads the authentication video to the server through the web page. Accordingly, the server can authenticate the user based on the authentication video.

[0097] However, the duration of the video often needs to reach a specified duration, for example, the specified duration can be 3-5 seconds. The file size of the video recorded by the user that meets the specified duration requirement may exceed a preset threshold, where the preset threshold represents the maximum file size of a single video that the server allows to store. In this case, the server cannot store the video and cannot complete the authentication.

[0098] In the related art, the user needs to adjust the file size of the recorded video by himself so that the file size of the recorded video does not exceed the storage limit of the server. For example, the user can re-record the video by changing the device. Based on this method, the user may need to adjust the file size of the recorded video by himself many times, which increases the complexity of the user operation and reduces the user experience.

[0099] In order to reduce the complexity of user operations and improve user experience, the embodiment of the present application provides a video processing method, which is applied to an electronic device, in which a web page is deployed. Accordingly, the electronic device can perform the steps of the video processing method provided in the embodiment of the present application based on the web page deployed therein. Figure 1 , Figure 1 The first flow chart of the video processing method provided in the embodiment of the present application may include the following steps:

[0100] Step S101: Determine whether the file size of a first video to be uploaded is greater than a first threshold.

[0101] The first threshold represents the maximum file size of a single video that the first server is allowed to store.

[0102] Step S102: If the file size of the first video is greater than a first threshold, the first video is processed according to a preset compression method to obtain a second video.

[0103] The file size of the second video is not greater than the first threshold.

[0104] Step S103: Send the second video to the first server, so that the first server receives and stores the second video.

[0105] The video processing method provided in the embodiment of the present application is that when the file size of the video (i.e., the first video) uploaded by the user to the server (i.e., the first server) through the web page is larger than the maximum file size of a single video allowed to be stored by the server (i.e., the first threshold), the web page can process the first video according to a preset compression method so that the file size of the processed video (i.e., the second video) is not larger than the first threshold. Accordingly, the server can store the second video. In this way, the web page can automatically adjust the size of the video without the user having to adjust the file size of the video multiple times, which can reduce the complexity of the user's operation and improve the user experience.

[0106] For step S101, the first video to be uploaded may be: a video that the current user needs to upload to the server through the web page. For example, in a scenario where a user is authenticated, the first video may be a video used to authenticate the user. The first server is a server for storing videos. In addition, in a scenario where a user is authenticated, the first server may also authenticate the user based on the stored video. Since the storage resources of the first server are limited, in order to maximize the number of videos that can be stored, the administrator may pre-set a first threshold to limit the maximum file size of a single video that the first server is allowed to store. For example, the first threshold may be 8M, or 16M.

[0107] When the file size of the first video is greater than the first threshold, step S102 may be executed.

[0108] When the file size of the first video is not greater than the first threshold, the web page can send the first video to the first server, and accordingly, the first server can receive and store the first video. In addition, in the scenario of authenticating the user, the first server can authenticate the user based on the stored first video.

[0109] With respect to step S102, when the file size of the first video is greater than the first threshold, the first video may be processed according to a preset compression method to obtain a second video whose file size is not greater than the first threshold. Then, the second video is uploaded according to step S103.

[0110] In one embodiment, the first video is processed according to a preset compression method to obtain the second video, including:

[0111] Step 1: Process the first video according to a preset compression method through a compression thread to obtain a second video.

[0112] Among them, the compression thread is asynchronous with the main thread of the web page.

[0113] In an embodiment of the present application, the main thread of the web page can be used to implement interactive functions with the user, and can also be used to update the content displayed on the web page. For example, the main thread of the web page can be a JS (JavaScript, a scripting language) engine thread, which is used to process JS events. The compression thread is asynchronous with the main thread of the web page, and the compression thread is used to process the video according to a preset compression method. For example, the compression thread can be a webworker (webpage worker thread, a thread running in the background) thread.

[0114] Based on the above processing, a compression thread that is asynchronous with the main thread of the web page can be set. By processing the first video through the compression thread, it is possible to avoid the process of processing the first video occupying the main thread, and avoid the process of processing the first video affecting the main thread of the web page. In other words, while processing the first video, the main thread of the web page can be guaranteed to run normally, avoiding web page freezes caused by occupying the main thread of the web page, thereby further improving the user experience.

[0115] In one embodiment, see Figure 2 , Figure 2 The second flow chart of the video processing method provided in the embodiment of the present application processes the first video according to the preset compression method to obtain the second video (S102), including:

[0116] Step S1021: Based on a preset compression algorithm and / or a pre-trained video compression network model, the first video is processed to obtain a second video.

[0117] Among them, the preset compression algorithm is used to adjust the preset attributes of the video; the preset attributes include at least one of the frame rate, bit rate and resolution; the video compression network model is used to compress the motion information and / or residual information in the video.

[0118] Based on the above processing, the web page can process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video whose file size is not greater than the first threshold, and then the web page can upload the second video to the server, and accordingly, the server can store the second video. In addition, in the scenario of authenticating the user, the server can authenticate the user based on the stored second video. In this way, the web page can automatically adjust the size of the video without the user having to adjust the file size of the first video multiple times, thereby reducing the complexity of user operations and improving the user experience.

[0119] Exemplarily, the first video may be processed using any one of a preset compression algorithm and a pre-trained video compression network model. Alternatively, the first video may be processed using a preset compression algorithm first, and then the processed first video may be further processed using a pre-trained video compression network model; or, the first video may be processed using a pre-trained video compression network model first, and then the processed first video may be further processed using a preset compression algorithm.

[0120] The preset properties of the video can be adjusted by the preset compression algorithm. For example, the preset properties of the video can be adjusted by calling the ffmpeg (a multimedia video processing tool) API (Application Programming Interface). The preset properties include at least one of the frame rate, bit rate and resolution. That is, at least one of the frame rate, bit rate and resolution of the video can be adjusted by the preset compression algorithm.

[0121] For example, the bit rate of the video can be adjusted based on CRF encoding (Constant Rate Factor Encoding, a single-pass encoding mode). The bit rate of the video can be adjusted by adjusting the value of the CRF (Constant Rate Factor, rate limiting factor) of the video. The CRF value can range from 0 to 51. The larger the CRF value, the smaller the bit rate of the adjusted video.

[0122] The video compression network model can compress the motion information and / or residual information in the video. For example, the video compression network model can use two auto-encoder style neural networks to compress the corresponding motion information and residual information.

[0123] The motion information in the video refers to the motion features in the video image used to reflect the motion state of the object. For example, the motion information in the video can be the optical flow in the video. The motion information in the video can be obtained based on the optical flow estimation method. The redundant motion information in the video can be removed by the video compression network model, and the motion information in the video can be compressed. The video compression network model can also reduce the residual information in the video to compress the residual information in the video. For example, for each video frame in the video, the predicted frame corresponding to the video frame can be obtained based on the optical flow estimation method, and then the difference between the video frame and the corresponding predicted frame (i.e., the residual information) can be calculated. The residual information is quantized and reconstructed by the residual encoder-decoder to achieve compression of the residual information in the video.

[0124] For example, the video compression network model may be a DVC (Deep Video Compression, an end-to-end deep video compression) architecture, or the video compression network model may be trained based on a CNN (Convolutional Neural Network, convolutional neural network).

[0125] In one embodiment, see Figure 3 , Figure 3 The third flow chart of the video processing method provided in the embodiment of the present application, before processing the first video based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video (S1021), the video processing method further includes:

[0126] Step S104: Determine whether there is a compressed code file in the preset cache space.

[0127] The compression code file includes: a code file of a preset compression algorithm and a code file of a video compression network model.

[0128] Step S105: If the compressed code file exists in the preset cache space, the compressed code file is obtained from the preset cache space.

[0129] Step S106: If the compressed code file does not exist in the preset cache space, the compressed code file is obtained from the second server and stored in the preset cache space.

[0130] Based on a preset compression algorithm and / or a pre-trained video compression network model, the first video is processed to obtain a second video (S1021), including:

[0131] Step S10211: Load the obtained compression code file to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video.

[0132] In an embodiment of the present application, technicians can pre-write code files for preset compression algorithms and code files for video compression network models. For example, they can use C / C++ language (programming language) to write code files, that is, write code files containing functions that implement compression functions.

[0133] The web page uses JS to implement basic functions, such as the interaction with the user. The technician writes a code file corresponding to the interface function called by JS (JavaScript, a scripting language), and informs JS of the function that can be called to implement the compression function. In turn, the web page can call the function that implements the compression function to compress the video.

[0134] The written code files can be stored in a pre-set code library. Furthermore, the technician can use the compilation tool to compile the code files of the preset compression algorithm, the code files of the video compression network model, and the code files corresponding to the interface functions to obtain the compressed code files that can be called by the web page. For example, the technician can use emcc (a compilation tool) to compile the code files of the preset compression algorithm, the code files of the video compression network model, and the code files corresponding to the interface functions to obtain wasm (WebAssembly, a web page collection, a binary format for web pages) files and JS glue files. The wasm file contains functions for implementing the compression function, and the JS glue file contains interface functions.

[0135] The compressed code file can be stored on the second server, and the second server can be a pre-set CDN (Content Delivery Network) node server. Before processing the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain the second video, the web page needs to obtain the compressed code file and load the obtained compressed code file to process the first video based on the compressed code file. When the compressed code file is obtained for the first time, the web page can store the obtained compressed code file in a preset cache space. For example, the web page can use a service worker (a caching method) to cache the compressed code file.

[0136] Based on the above processing, when the web page first obtains the compressed code file, it can store the compressed code file in the preset cache space, and can subsequently obtain the compressed code file from the preset cache space. Accordingly, when other videos need to be processed later, the compressed code file can be obtained from the preset cache space without obtaining the compressed code file from the second server, which can increase the speed of obtaining the compressed code file and further improve the efficiency of compressing the video. In addition, obtaining the compressed code file from the preset cache space can reduce the traffic consumption of obtaining the compressed code file from the second server, reduce the traffic cost, and also reduce the consumption of network resources.

[0137] For step S103, after the first video is processed according to a preset compression method, a second video whose file size is not greater than the first threshold can be obtained, and then the web page can send the second video to the first server. For example, the web page can call the upload interface of the first server to send the second video to the first server. The upload interface can be an HTTP (HyperText Transfer Protocol) interface. Since the file size of the second video is not greater than the first threshold, the first server can receive and store the second video. In addition, in the scenario of authenticating the user, the first server can also authenticate the user based on the stored second video.

[0138] In one embodiment, before processing the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain the second video, the video processing method further includes:

[0139] Step 1: Determine whether the file size of the first video is greater than a second threshold.

[0140] The second threshold represents the maximum file size of a single video that can be compressed by the preset compression algorithm.

[0141] Processing the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video includes:

[0142] Step 2: When the file size of the first video is greater than the second threshold, the first video is segmented to obtain multiple first video segments.

[0143] The file size of any first video segment is not greater than the second threshold.

[0144] Step 3: For each first video segment, compress the first video segment based on a preset compression algorithm to obtain a second video segment corresponding to the first video segment.

[0145] Step 4: splice the second video clips in the order of timestamps to obtain a second video.

[0146] Step 5: When the file size of the first video is not greater than the second threshold, the first video is compressed based on a preset compression algorithm and / or a video compression network model to obtain a second video.

[0147] In the embodiment of the present application, when the file size of the video to be compressed is large, the efficiency of processing the video using the preset compression algorithm is low, and the preset compression algorithm may not be used to achieve compression. Therefore, the administrator may pre-set the second threshold to limit the videos that the preset compression algorithm allows to be compressed, so as to ensure the execution efficiency of the preset compression algorithm. For example, the second threshold may be 200M, or 150M. The second threshold may not be less than the first threshold.

[0148] When the file size of the first video to be processed is greater than the second threshold, the first video may be segmented to obtain a plurality of video segments (i.e., first video segments). For example, ffmpeg may be used to segment the first video. The plurality of first video segments obtained may be video segments of the same size, or may be video segments of different sizes. The file size of each first video segment is not greater than the second threshold.

[0149] For each first video segment, the first video segment can be compressed based on a preset compression algorithm to obtain a second video segment corresponding to the first video segment, that is, for each first video segment, a compressed second video segment can be obtained. Furthermore, the second video segments can be spliced ​​in the order of their timestamps to obtain a second video.

[0150] When the file size of the first video to be processed is not greater than the second threshold, the first video can be compressed based on a preset compression algorithm and / or a video compression network model to obtain a second video. For example, the first video can be compressed using any of the preset compression algorithms or video compression network models. Alternatively, the first video can be processed using a preset compression algorithm first, and then the processed first video can be further processed using a video compression network model; alternatively, the first video can be processed using a video compression network model first, and then the processed first video can be further processed using a preset compression algorithm.

[0151] Based on the above processing, when the file size of the first video to be processed is greater than the second threshold, the first video can be segmented, and then the segmented video segments can be compressed, and the compressed video segments can be spliced ​​to achieve compression of the first video. This can also reduce the file size that the preset compression algorithm needs to compress at a time, avoid the preset compression algorithm needing to process a file size that is too large at a time, causing the preset compression algorithm to freeze during compression processing, and may even cause the preset compression algorithm to crash and fail to achieve compression processing, thereby reducing the impact of the file size on the efficiency of the compression processing of the preset compression algorithm.

[0152] In one embodiment, for each first video segment, compressing the video segment based on a preset compression algorithm to obtain a second video segment corresponding to the first video segment includes:

[0153] Step 31: For each first video clip, when the first attribute information of the first video clip for the preset attribute is greater than the preset attribute threshold, adjust the preset attribute of the first video clip so that the adjusted attribute information of the first video clip is not greater than the preset attribute threshold, and obtain the second video clip corresponding to the first video clip.

[0154] In the embodiment of the present application, for each first video segment, attribute information (ie, first attribute information) of the first video segment for a preset attribute may be obtained based on a preset compression algorithm.

[0155] For example, the preset attribute is the frame rate, and the frame rate of the first video clip can be obtained based on the preset compression algorithm using AVFormatContext (a structure used in ffmpeg to describe the composition and basic information of a media file or media stream), that is, the frame rate of the first video clip can be obtained. Accordingly, the preset attribute threshold can be 20fps (Frame Per Second, the number of frames transmitted per second), or 25fps.

[0156] When the first attribute information of the first video clip is not greater than the preset attribute threshold, the compression of the first video clip by adjusting the preset attribute may affect the video quality of the obtained second video. Therefore, the technician can set a preset attribute threshold, and when the first attribute information of the first video clip for the preset attribute is greater than the preset attribute threshold, the preset attribute of the first video clip is adjusted to compress the first video clip, which guarantees the video quality of the obtained second video clip to a certain extent, and further, the video quality of the spliced ​​second video can be guaranteed. Based on this, it is possible to achieve compression while ensuring a good compression effect.

[0157] For example, the pts (Presentation Time Stamp) of the first video clip may be adjusted using the ffmpeg API to adjust the frame rate of the first video clip. When the preset attribute threshold is 20fps, the frame rate of the first video clip may be adjusted to 20fps, or may be adjusted to 19fps.

[0158] After adjusting the preset attributes of each first video segment, each second video segment corresponding to each first video segment can be obtained.

[0159] Based on the above processing, each first video segment can be compressed by adjusting the preset attributes of each first video segment, thereby achieving video compression and further ensuring the user experience.

[0160] In one embodiment, the video processing method further includes:

[0161] Step 32: For each first video segment, when the first attribute information is not greater than a preset attribute threshold, the first video segment is input into a video compression network model to obtain a second video segment corresponding to the first video segment.

[0162] In the embodiment of the present application, when the first attribute information of the first video segment is not greater than the preset attribute threshold, compressing the first video segment by adjusting the preset attribute may affect the video quality of the first video segment, for example, the clarity of the first video segment may be affected. As a result, the video quality of the second video that is finally uploaded is not high, and the clarity of the second video may not support the completion of authentication.

[0163] Based on the above processing, when the first attribute information of the first video clip is not greater than the preset attribute threshold, the first video clip is compressed through the video compression network model. The video compression network model can compress the first video clip while ensuring the video quality, which means that the video quality of the second video clip obtained can be guaranteed while compressing the first video clip, which means that the video quality of the second video obtained by splicing the second video clips can be guaranteed, and the first server can be authenticated based on the second video.

[0164] In one embodiment, the second video segments are spliced ​​in the order of timestamps to obtain the second video, including:

[0165] Step 41: splice the second video clips in the order of timestamps to obtain a third video.

[0166] Step 42: Determine whether the file size of the third video is greater than a first threshold;

[0167] Step 43: if the file size of the third video is greater than the first threshold, for each first video segment, input the first video segment into the video compression network model to obtain a third video segment corresponding to the first video segment; splice the third video segments in the order of timestamps to obtain a second video;

[0168] Alternatively, if the file size of the third video is greater than the first threshold, for each second video segment, the second video segment is input into the video compression network model to obtain a fourth video segment corresponding to the second video segment; the fourth video segments are spliced ​​in the order of timestamps to obtain the second video;

[0169] Alternatively, if the file size of the third video is greater than the first threshold, the first video is input into the video compression network model to obtain the second video;

[0170] Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

[0171] Step 44: If the file size of the third video is not greater than the first threshold, the third video is determined as the second video.

[0172] In the embodiment of the present application, after the first video segments are compressed to obtain the second video segments, the second video segments are spliced ​​in the order of timestamps to obtain the third video. Due to the influence of the compression processing accuracy, the file size of the third video may still be greater than the first threshold. At this time, the first server cannot store the third video. Therefore, the compression processing can be performed in any one of the methods 1 to 4 to obtain the second video.

[0173] Method 1: Input each first video clip into the video compression network model, compress each first video clip to obtain each compressed third video clip, and then splice each third video clip to obtain the second video. In this method, the compression process is performed on each uncompressed first video clip, which can achieve compression while ensuring the efficiency of the compression process. Compared with method 2, it can avoid the problem of reducing the quality of the video clips due to multiple compression of the video clips, resulting in lower video quality of the second video.

[0174] Method 2: Input each second video clip into the video compression network model, compress each second video clip to obtain each fourth video clip after further compression, and then splice each fourth video clip to obtain the second video. In this method, further compressing each compressed second video clip can further reduce the file size of each video clip, and further ensure the effect of compression processing.

[0175] Method 3: Input the first video into the video compression network model, compress the first video, and obtain the second video. In this method, the uncompressed first video can also be compressed to obtain the second video, without splicing the compressed video clips, thereby improving the efficiency of the compression process. Compared with method 4, it can avoid the problem of reducing video quality due to multiple compressions.

[0176] Method 4: Input the third video into the video compression network model, compress the third video, and obtain the second video. In this method, the compressed third video is further compressed to further reduce the file size of the video, which can ensure to a certain extent that the second video has a file size not greater than the first threshold.

[0177] When the file size of the third video is not greater than the first threshold, the web page may determine the third video as the second video and send the second video to the first server.

[0178] Based on the above processing, after compression processing based on the preset compression algorithm, it cannot be guaranteed that the file size of the third video obtained is not greater than the first threshold value. For example, when compression processing is performed by setting the CRF value, the file size of the compressed video can be reduced, but the file size of the compressed video cannot be determined, that is, it cannot be guaranteed that the file size of the third video obtained is not greater than the first threshold value. Therefore, after compression processing based on the preset compression algorithm, when the file size of the third video obtained is greater than the first threshold value, the third video can be compressed based on the video compression network model. In this way, it can be further ensured that the web page can automatically adjust the size of the video so that the server can store the adjusted video without the user having to adjust the file size of the video multiple times, thereby reducing the complexity of user operations and improving user experience.

[0179] In one embodiment, based on a preset compression algorithm and / or a video compression network model, compressing the first video to obtain the second video includes:

[0180] Step 51: When the second attribute information of the first video for the preset attribute is greater than the preset attribute threshold, adjust the preset attribute of the first video so that the adjusted attribute information of the first video is not greater than the preset attribute threshold, thereby obtaining a fourth video.

[0181] Step 52: Based on the fourth video, obtain the second video.

[0182] In the embodiment of the present application, the attribute information (ie, the second attribute information) of the first video for a preset attribute may be obtained based on a preset compression algorithm.

[0183] Since when the second attribute information of the first video is not greater than the preset attribute threshold, compressing the first video by adjusting the preset attribute may affect the video quality of the obtained second video. Therefore, the technician can set the preset attribute threshold, and when the second attribute information of the first video for the preset attribute is greater than the preset attribute threshold, the preset attribute of the first video is adjusted to compress the first video, which can guarantee the video quality of the obtained second video to a certain extent, and can also ensure a better compression effect while achieving compression.

[0184] After adjusting the preset attributes of the first video, the fourth video can be obtained. Then, the second video can be obtained based on the fourth video. It is also possible to compress the first video by adjusting the preset attributes of the first video, and then, it is possible to compress the first video, further ensuring the user experience.

[0185] In one embodiment, obtaining the second video based on the fourth video includes:

[0186] Step 521: Determine whether the file size of the fourth video is greater than a first threshold.

[0187] Step 522: If the file size of the fourth video is greater than the first threshold, the fourth video is input into the video compression network model to obtain the second video.

[0188] Step 523: If the file size of the fourth video is not greater than the first threshold, the fourth video is determined as the second video.

[0189] In an embodiment of the present application, after adjusting the preset attribute of the first video, a fourth video can be obtained. After the first video is compressed by adjusting the preset attribute, the file size of the fourth video obtained may still be greater than the first threshold. At this time, the fourth video can be input into the video compression network model, and the fourth video is compressed to obtain the second video.

[0190] When the file size of the fourth video is not greater than the first threshold, the fourth video may be determined as the second video and the second video may be sent to the first server.

[0191] Based on the above processing, when the file size of the fourth video is greater than the first threshold, for example, when the preset compression algorithm is not effective, the fourth video can be compressed based on the video compression network model. In this way, it can be further ensured that the web page can automatically adjust the size of the video so that the server can store the adjusted video without the user having to adjust the file size of the video multiple times, thereby reducing the complexity of user operations and improving the user experience.

[0192] In one embodiment, see Figure 4 , Figure 4This is a fourth flow chart of a video processing method provided in an embodiment of the present application. The video processing method may include the following steps:

[0193] Step S401: Load and initialize the wasm (web page collection) file, and use the service worker (service worker thread) to cache the wasm file. That is, when the user needs to upload a video through the web page, the web page obtains the compressed code file from the second server, loads the obtained compressed code file and stores it in the preset cache space. The wasm file is the compressed code file in the above embodiment.

[0194] Step S402: Detect whether the file size exceeds a threshold. That is, determine whether the file size of the first video to be uploaded is greater than a first threshold. The first video may be a video to be uploaded shot or selected by the current user. If yes, execute step S403. If no, call the upload interface of the first server to send the first video to the first server, so that the first server receives and stores the first video.

[0195] Step S403: Start the webworker task, that is, start the compression thread.

[0196] Step S404: Detect whether the file size exceeds the compression module processing threshold. That is, determine whether the file size of the first video is greater than the second threshold. If yes, execute step S405; if no, execute step S408.

[0197] Step S405: Slice the file into segments, that is, slice the first video into segments to obtain a plurality of first video segments.

[0198] Step S406: calling the wasm file to compress the segment. That is, for each first video segment, the first video segment is compressed based on a preset compression algorithm to obtain a second video segment corresponding to the first video segment.

[0199] Step S407: splicing compressed segments, that is, splicing the second video segments in the order of timestamps to obtain the second video.

[0200] Step S408: calling the wasm file to compress the video, that is, based on a preset compression algorithm, compressing the first video to obtain a second video.

[0201] Step S409: calling an interface for upload, that is, calling an upload interface of the first server to send the second video to the first server, so that the first server receives and stores the second video.

[0202] Based on the same inventive concept, the embodiment of the present application also provides a video processing device applied to an electronic device, wherein a web page is deployed in the electronic device, see Figure 5 , Figure 5 A schematic diagram of the structure of a video processing device provided in an embodiment of the present application, the device comprising:

[0203] A first judgment module 501 is used to judge whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server;

[0204] The video processing module 502 is configured to process the first video according to a preset compression method to obtain a second video if the file size of the first video is greater than the first threshold; wherein the file size of the second video is not greater than the first threshold;

[0205] The video sending module 503 is used to send the second video to the first server, so that the first server receives and stores the second video.

[0206] The video processing device provided in the embodiment of the present application can process the first video in accordance with a preset compression method, so that the file size of the processed video (i.e., the second video) is not larger than the first threshold value, when the file size of the video (i.e., the first video) uploaded by the user to the server (i.e., the first server) through the web page is larger than the maximum file size of a single video allowed to be stored by the server (i.e., the first threshold value). Accordingly, the server can store the second video. In this way, the web page can automatically adjust the size of the video without the user having to adjust the file size of the video multiple times, thereby reducing the complexity of the user's operation and improving the user's experience.

[0207] In one embodiment, the video processing module 502 includes:

[0208] A video processing submodule is used to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video; wherein the preset compression algorithm is used to adjust preset attributes of the video; the preset attributes include at least one of frame rate, bit rate and resolution; and the video compression network model is used to compress motion information and / or residual information in the video.

[0209] In one embodiment, the apparatus further comprises:

[0210] A second judgment module is used to judge whether the file size of the first video is greater than a second threshold before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video; wherein the second threshold represents the maximum file size of a single video allowed to be compressed by the preset compression algorithm;

[0211] The video processing submodule comprises:

[0212] a video segmentation unit, configured to segment the first video to obtain a plurality of first video segments when the file size of the first video is greater than the second threshold, wherein the file size of any first video segment is not greater than the second threshold;

[0213] A video segment compression unit, configured to compress each first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment;

[0214] The video segment splicing unit is used to splice the second video segments in the order of timestamps to obtain a second video.

[0215] In one embodiment, the video segment compression unit is specifically used to adjust the preset attribute of each first video segment, when the first attribute information of the first video segment for the preset attribute is greater than the preset attribute threshold, so that the attribute information of the adjusted first video segment is not greater than the preset attribute threshold, and obtain a second video segment corresponding to the first video segment.

[0216] In one embodiment, the apparatus further comprises:

[0217] The video segment input module is used to input each first video segment into the video compression network model to obtain a second video segment corresponding to the first video segment when the first attribute information is not greater than the preset attribute threshold.

[0218] In one embodiment, the video segment splicing unit is specifically used to splice the second video segments in the order of timestamps to obtain a third video;

[0219] Determine whether the file size of the third video is greater than the first threshold;

[0220] If the file size of the third video is greater than the first threshold, for each first video segment, input the first video segment into the video compression network model to obtain a third video segment corresponding to the first video segment; splice the third video segments in the order of timestamps to obtain a second video;

[0221] Alternatively, if the file size of the third video is greater than the first threshold, for each second video segment, the second video segment is input into the video compression network model to obtain a fourth video segment corresponding to the second video segment; and the fourth video segments are spliced ​​in the order of timestamps to obtain the second video;

[0222] Alternatively, if the file size of the third video is greater than the first threshold, the first video is input into the video compression network model to obtain a second video;

[0223] Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

[0224] In one embodiment, the apparatus further comprises:

[0225] The video compression processing module compresses the first video based on the preset compression algorithm and / or the video compression network model to obtain a second video when the file size of the first video is not greater than the second threshold.

[0226] In one embodiment, the video compression processing module includes:

[0227] A preset attribute adjustment submodule, configured to adjust the preset attribute of the first video when the second attribute information of the first video for the preset attribute is greater than the preset attribute threshold, so that the attribute information of the adjusted first video is not greater than the preset attribute threshold, thereby obtaining a fourth video;

[0228] The second video acquisition submodule is used to obtain the second video based on the fourth video.

[0229] In one embodiment, the second video acquisition submodule is specifically used to determine whether the file size of the fourth video is greater than the first threshold;

[0230] If the file size of the fourth video is greater than the first threshold, the fourth video is input into the video compression network model to obtain the second video.

[0231] In one embodiment, the apparatus further comprises:

[0232] A third judgment module is used to judge whether there is a compression code file in the preset cache space before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video; wherein the compression code file includes: a code file of the preset compression algorithm and a code file of the video compression network model;

[0233] A first acquisition module, configured to acquire the compressed code file from the preset cache space if the compressed code file exists in the preset cache space;

[0234] A second acquisition module, configured to acquire the compressed code file from a second server and store it in the preset cache space if the compressed code file does not exist in the preset cache space;

[0235] The video processing submodule comprises:

[0236] A compression code file loading unit is used to load the obtained compression code file to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video.

[0237] In one embodiment, the video processing module 502 is specifically used to process the first video according to a preset compression method through a compression thread to obtain a second video; wherein the compression thread is asynchronous with the main thread of the web page.

[0238] The present application also provides an electronic device, such as Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.

[0239] Memory 603, used for storing computer programs;

[0240] The processor 601 is used to execute the program stored in the memory 603 to implement the following steps:

[0241] Determine whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server;

[0242] If the file size of the first video is greater than the first threshold, the first video is processed according to a preset compression method to obtain a second video; wherein the file size of the second video is not greater than the first threshold;

[0243] The second video is sent to the first server, so that the first server receives and stores the second video.

[0244] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0245] The communication interface is used for communication between the above terminal and other devices.

[0246] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0247] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0248] In another embodiment provided in the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the video processing method described in any one of the above embodiments is implemented.

[0249] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the video processing method described in any one of the above embodiments.

[0250] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0251] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0252] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0253] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A video processing method, characterized in that: Applied to an electronic device, wherein a web page is deployed in the electronic device, the method comprises: Determine whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server; If the file size of the first video is larger than the first threshold, the first video is processed according to a preset compression method to obtain a second video; wherein the file size of the second video is not larger than the first threshold; Sending the second video to the first server so that the first server receives and stores the second video; The step of processing the first video according to a preset compression method to obtain a second video includes: Based on a preset compression algorithm and / or a pre-trained video compression network model, the first video is processed to obtain a second video; The preset compression algorithm is used to adjust the preset attributes of the video; the preset attributes include at least one of the frame rate, bit rate and resolution; the video compression network model is used to compress the motion information and / or residual information in the video; Before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video, the method further includes: Determine whether the file size of the first video is greater than a second threshold; wherein the second threshold represents the maximum file size of a single video allowed to be compressed by the preset compression algorithm; The processing of the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video includes: When the file size of the first video is greater than the second threshold, segmenting the first video to obtain a plurality of first video segments; wherein the file size of any first video segment is not greater than the second threshold; For each first video segment, compress the first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment; splicing the second video clips in the order of timestamps to obtain a second video; The step of splicing the second video clips in the order of the timestamps to obtain the second video includes: splicing the second video clips in the order of timestamps to obtain a third video; Determine whether the file size of the third video is greater than the first threshold; If the file size of the third video is greater than the first threshold, for each second video segment, input the second video segment into the video compression network model to obtain a fourth video segment corresponding to the second video segment; splice the fourth video segments in the order of timestamps to obtain the second video; Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

2. The method according to claim 1, characterized in that The step of compressing each first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment includes: For each first video clip, when the first attribute information of the first video clip for the preset attribute is greater than the preset attribute threshold, adjust the preset attribute of the first video clip so that the adjusted attribute information of the first video clip is not greater than the preset attribute threshold, and obtain the second video clip corresponding to the first video clip.

3. The method according to claim 2, characterized in that The method further comprises: For each first video segment, when the first attribute information is not greater than the preset attribute threshold, the first video segment is input into the video compression network model to obtain a second video segment corresponding to the first video segment.

4. The method according to claim 1, characterized in that The method further comprises: When the file size of the first video is not greater than the second threshold, the first video is compressed based on the preset compression algorithm and / or the video compression network model to obtain a second video.

5. The method according to claim 4, characterized in that The compressing the first video based on the preset compression algorithm and / or the video compression network model to obtain the second video includes: When the second attribute information of the first video for the preset attribute is greater than a preset attribute threshold, adjusting the preset attribute of the first video so that the attribute information of the adjusted first video is not greater than the preset attribute threshold, thereby obtaining a fourth video; Based on the fourth video, a second video is obtained.

6. The method according to claim 5, characterized in that The step of obtaining a second video based on the fourth video includes: Determine whether the file size of the fourth video is greater than the first threshold; If the file size of the fourth video is greater than the first threshold, the fourth video is input into the video compression network model to obtain the second video.

7. The method according to claim 1, characterized in that Before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video, the method further includes: Determine whether there is a compression code file in the preset cache space; wherein the compression code file includes: a code file of the preset compression algorithm and a code file of the video compression network model; If the compressed code file exists in the preset cache space, obtaining the compressed code file from the preset cache space; If the compressed code file does not exist in the preset cache space, obtaining the compressed code file from the second server and storing it in the preset cache space; The processing of the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video includes: The obtained compression code file is loaded to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video.

8. The method according to claim 1, characterized in that The step of processing the first video according to a preset compression method to obtain a second video includes: The first video is processed in a preset compression method through a compression thread to obtain a second video; wherein the compression thread is asynchronous with the main thread of the web page.

9. A video processing device, characterized in that: Applied to an electronic device, wherein a web page is deployed in the electronic device, the device comprises: A first judgment module is used to judge whether the file size of the first video to be uploaded is greater than a first threshold; wherein the first threshold represents the maximum file size of a single video allowed to be stored by the first server; a video processing module, configured to process the first video according to a preset compression method to obtain a second video if the file size of the first video is greater than the first threshold; wherein the file size of the second video is not greater than the first threshold; A video sending module, configured to send the second video to the first server, so that the first server receives and stores the second video; The video processing module comprises: A video processing submodule, configured to process the first video based on a preset compression algorithm and / or a pre-trained video compression network model to obtain a second video; wherein the preset compression algorithm is used to adjust preset attributes of the video; the preset attributes include at least one of a frame rate, a bit rate, and a resolution; and the video compression network model is used to compress motion information and / or residual information in the video; The device also includes: A second judgment module is used to judge whether the file size of the first video is greater than a second threshold before the first video is processed based on the preset compression algorithm and / or the pre-trained video compression network model to obtain the second video; wherein the second threshold represents the maximum file size of a single video allowed to be compressed by the preset compression algorithm; The video processing submodule comprises: a video segmentation unit, configured to segment the first video to obtain a plurality of first video segments when the file size of the first video is greater than the second threshold, wherein the file size of any first video segment is not greater than the second threshold; A video segment compression unit, configured to compress each first video segment based on the preset compression algorithm to obtain a second video segment corresponding to the first video segment; A video segment splicing unit, used for splicing the second video segments in the order of timestamps to obtain a second video; The video segment splicing unit is specifically used for: splicing the second video clips in the order of timestamps to obtain a third video; Determine whether the file size of the third video is greater than the first threshold; If the file size of the third video is greater than the first threshold, for each second video segment, input the second video segment into the video compression network model to obtain a fourth video segment corresponding to the second video segment; splice the fourth video segments in the order of timestamps to obtain the second video; Alternatively, if the file size of the third video is greater than the first threshold, the third video is input into the video compression network model to obtain the second video.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 8 when executing a program stored in a memory.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Mobile terminal photo compression uploading method and apparatus

    CN107395716A

  • Compression method and device of video storage space

    CN107734336A

  • Compression method and device and electronic equipment

    CN113836101A

  • End-to-end video compression method and device and computer readable storage medium

    CN114513670A