GIF generation method and device, equipment and storage medium
By parsing and converting video files, dividing and extracting video frame images, and drawing watermarks on them, finally synthesizing and generating GIF files, the existing video to GIF technology is solved, and a more efficient and secure GIF image display is achieved.
Patent Information
- Application Number
- CN202411878437.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-25
AI Technical Summary
The existing video to GIF technology is less efficient, has poor security, and lacks a complete solution or npm plug-in to realize the need for video to GIF images.
By analyzing the track information of the video file to be processed based on the video parsing library, the total video time is determined, and the video file is converted into multiple consecutive video frame images. Then, based on the preset time and interval, the video frame image is divided and extracted, and a watermark is drawn on the video frame image using the preset text drawing tool, and finally synthesize and generate a GIF file.
Improve the efficiency and security of video to GIF technology, allowing GIF diagrams to display component functions more safely and efficiently.
Smart Images

Figure CN119893230A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a GIF generation method, device, equipment and storage medium. Background Art
[0002] With the development of Internet technology, in order to make code easier to reuse, reusable functions will be componentized in component-based development.
[0003] In order to allow developers to find and use different components quickly and easily, the related technology can display component functions through GIF images. However, the existing video to GIF technology is inefficient and has poor security, and there is no complete solution or npm plug-in that can realize the demand for video to GIF images. Therefore, how to better generate GIF images so that GIF images can display component functions more safely and efficiently has become a technical problem that needs to be solved. Summary of the invention
[0004] The present invention provides a GIF generation method, device, equipment and storage medium, which are used to solve the problems of low efficiency and poor security of video to GIF technology in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a GIF generation method, the method comprising:
[0006] Parsing the track information of the video file to be processed based on the video parsing library, determining the total duration of the video, and converting the video file to be processed into a plurality of continuous video frame images;
[0007] Based on the total duration of the video and the preset duration, the plurality of continuous video frame images are divided to obtain video frame image groups corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous;
[0008] For each video frame image group, extracting a plurality of target video frame images from the video frame image group based on a preset interval;
[0009] Based on a preset text drawing tool, after drawing a watermark at a preset watermark position of each target video frame image, each target video frame image after drawing the watermark in each video frame image group is synthesized to generate a GIF file.
[0010] In some optional implementations, converting the to-be-processed video file into a plurality of continuous video frame images includes:
[0011] Decomposing the to-be-processed video file into target to-be-processed video files by a video encoding tool, wherein the target to-be-processed video file includes video data of a plurality of continuous video frame images;
[0012] The target video file to be processed is converted into a plurality of continuous video frame images by a video decoding tool.
[0013] In some optional implementations, the step of drawing a watermark at a preset watermark position on each target video frame image based on a preset text drawing tool includes:
[0014] For each target video frame image, determining a preset watermark position of the target video frame image;
[0015] Creating a text box at the preset watermark position based on the preset text drawing tool, and filling in the text box based on the preset watermark naming method;
[0016] The filled text box is used as the watermark of the target video frame image.
[0017] In some optional implementations, a plurality of preset watermark positions are included, and the plurality of preset watermark positions are arranged at preset distances;
[0018] The preset watermark position is set obliquely relative to the horizontal direction;
[0019] The preset watermark naming method is a combination of user code and user name.
[0020] In some optional implementations, after synthesizing each target video frame image after drawing a watermark in each video frame image group to generate a GIF file, the method further includes:
[0021] After uploading the generated GIF file to the object storage service OSS server, the uniform resource locator URL of the GIF file sent by the OSS server is received, so that the user can obtain the GIF file based on the URL.
[0022] In a second aspect, an embodiment of the present application provides a GIF generation device, the device comprising:
[0023] A track information analysis module, used to analyze the track information of the video file to be processed based on the video analysis library, determine the total duration of the video, and convert the video file to be processed into a plurality of continuous video frame images;
[0024] A video frame image generation module, configured to divide the plurality of continuous video frame images based on the total duration of the video and a preset duration to obtain a video frame image group corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous;
[0025] The GIF generation module is used to extract multiple target video frame images from each video frame image group based on a preset interval; based on a preset text drawing tool, after drawing a watermark at a preset watermark position of each target video frame image, each target video frame image after drawing a watermark in each video frame image group is synthesized to generate a GIF file.
[0026] In some optional implementation manners, the track information parsing module is specifically used to:
[0027] Decomposing the to-be-processed video file into target to-be-processed video files by a video encoding tool, wherein the target to-be-processed video file includes video data of a plurality of continuous video frame images;
[0028] The target video file to be processed is converted into a plurality of continuous video frame images by a video decoding tool.
[0029] In some optional implementation manners, the GIF generation module is specifically used for:
[0030] For each target video frame image, determining a preset watermark position of the target video frame image;
[0031] Creating a text box at the preset watermark position based on the preset text drawing tool, and filling in the text box based on the preset watermark naming method;
[0032] The filled text box is used as the watermark of the target video frame image.
[0033] In some optional implementations, the GIF generation module includes a plurality of preset watermark positions, and the plurality of preset watermark positions are set at preset distances;
[0034] The preset watermark position is set obliquely relative to the horizontal direction;
[0035] The preset watermark naming method is a combination of user code and user name.
[0036] In some optional implementation manners, the GIF generation module is further used to:
[0037] After uploading the generated GIF file to the object storage service OSS server, the uniform resource locator URL of the GIF file sent by the OSS server is received, so that the user can obtain the GIF file based on the URL.
[0038] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any method described in the first aspect when executing the computer program.
[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, and when the computer program is executed by a processor, the steps of any method described in the first aspect are implemented.
[0040] The beneficial effects of the present invention are as follows:
[0041] The embodiment of the present application provides a GIF generation method, device, equipment and storage medium, which analyzes the track information of the video file to be processed based on the video analysis library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, divides the multiple continuous video frame images to obtain a video frame image group corresponding to each preset duration, wherein the multiple video frames in the video frame image group are continuous; for each video frame image group, based on the preset interval, extracts multiple target video frame images from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, synthesizes each target video frame image after drawing the watermark in each video frame image group to generate a GIF file. Thereby improving the efficiency and security of the video to GIF technology, and then more safely and efficiently displaying the component functions through GIF images. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0043] Figure 1 An application scenario of a GIF generation method provided in an embodiment of the present application;
[0044] Figure 2 A flowchart of a GIF generation method provided in an embodiment of the present application;
[0045] Figure 3 A flowchart of another GIF generation method provided in an embodiment of the present application;
[0046] Figure 4 A structural diagram of a GIF generation device provided for the implementation of this application;
[0047] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] The following is an explanation of some technical terms involved in this application:
[0050] (1) npm (Node Package Manager): is a module that encapsulates code and related resources to implement specific functions so that developers can share and reuse code in projects.
[0051] (2) GIF (Graphics Interchange Format): It is an image file format used to store dynamic images or static images. GIF can contain multiple frames of images and form an animation effect by displaying them frame by frame.
[0052] (3) URL (Uniform Resource Locator): is an address used to identify and locate resources on the Internet.
[0053] It should be noted that the terms "including" and "having" and their variations involved in the documents of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0054] The application scenarios described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems. In the description of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more.
[0055] The word “exemplary” is used hereinafter to mean “serving as an example, example, or illustration.” Any embodiment described as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0056] With the development of Internet technology, in order to make code reuse easier, component-based development will process reusable functions into components. In order to allow developers to find and use different components quickly and easily, in related technologies, component functions can be displayed through GIF images. However, the existing video to GIF technology is inefficient and has poor security, and there is no complete solution or npm plug-in that can meet the needs of video to GIF images.
[0057] Therefore, how to better generate GIF images so that they can display component functions more safely and efficiently has become a technical problem that needs to be solved.
[0058] To solve this problem, the embodiment of the present application provides a GIF generation method, device, equipment and storage medium. The GIF generation method analyzes the track information of the video file to be processed based on the video analysis library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, multiple continuous video frame images are divided to obtain video frame image groups corresponding to each preset duration; for each video frame image group, based on the preset interval, multiple target video frame images are extracted from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, each target video frame image after drawing the watermark in each video frame image group is synthesized to generate a GIF file. Thereby improving the efficiency and security of the video to GIF technology, and then more safely and efficiently displaying the component functions through GIF images.
[0059] 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. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0060] Figure 1 The application scenario of a GIF generation method provided by an embodiment of the present application is shown. Figure 1 As shown, the server 100 is connected to the terminal device through the network 101 for communication, wherein the network 101 may be but not limited to a local area network, a metropolitan area network or a wide area network, etc., and the number of terminal devices connected to the server 100 may be multiple, for example, the terminal device may include a terminal device 110 of a developer in componentized development, and may also include a terminal device 111 of a user of a target website, etc. The terminal device may be a portable device (e.g., a mobile phone, a tablet computer, etc.), or a computer, a smart screen or a personal computer (PC, Personal Computer), etc.
[0061] The server 100 may be an application-level server storing multiple applications. The server 100 may be any device having networking function and providing data processing capability. For example, the server 100 may be a cloud server or a server set consisting of one or more servers.
[0062] Figure 1 The application scenario is only an example of an application scenario for implementing the embodiment of the present application. The embodiment of the present application is not limited to the above Figure 1 The application scenario described.
[0063] Based on the above Figure 1 Based on the application scenarios shown and the introduction to the above-mentioned related technologies, an embodiment of the present application provides a GIF generation method. Figure 2 A schematic diagram of a GIF generation method provided in an embodiment of the present application is shown, and the specific steps are as follows:
[0064] S201, parsing the track information of the video file to be processed based on the video parsing library, determining the total duration of the video, and converting the video file to be processed into a plurality of continuous video frame images;
[0065] As an example, after obtaining the video file to be processed, the track information of the video file to be processed is parsed based on the video parsing library to determine the total duration and the total number of frames of the video file to be processed, and then the number of frames per second of the video file to be processed is determined based on the total duration and the total number of frames of the video file to be processed, wherein the unit of the determined total duration of the video file to be processed is seconds.
[0066] Specifically, the number of frames per second of the video file to be processed = the total number of frames of the video file to be processed / the total duration of the video file to be processed. For example, if the video file A to be processed is parsed by the video parsing library, the total duration of the video file A to be processed is determined to be 15 seconds, and the total number of frames of the video file A to be processed is 250 frames, then the calculated number of frames per second of the video file to be processed = 250 frames / 15 seconds = 25 frames / second.
[0067] It should be noted that the video parsing library may be mp4box.js, which is used to extract video track information and audio track information of the video file to be processed.
[0068] As an example, the present application decomposes the video file to be processed into target video files to be processed through a video encoding tool, and converts the target video file to be processed into multiple continuous video frame images through a video decoding tool, thereby converting the video file to be processed into multiple continuous video frame images.
[0069] Exemplarily, the video encoding tool may be EncodeVideoChunk, and the video decoding tool may be VideoDecoder. The video encoding tool EncodeVideoChunk is used to encode the video file to be processed, so as to determine the video data of each frame of the video file to be processed, that is, to obtain the target video file to be processed, wherein the target video file to be processed includes video data of multiple continuous video frame images.
[0070] The video decoding tool VideoDecoder is used to decode video data into image frames. In the present application, it is used to decode video data of multiple consecutive video frame images into multiple consecutive video frame images.
[0071] S202, dividing a plurality of continuous video frame images based on the total video duration and the preset duration to obtain a video frame image group corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous;
[0072] As an example, when the preset duration is 1 second, multiple continuous video frame images can be divided based on the total video duration and the preset duration of 1 second to obtain a video frame image group corresponding to each preset duration of 1 second. Multiple continuous video frame images can also be divided based on the number of frames per second and the total number of frames of the video file to be processed to obtain a video frame image group corresponding to each preset duration of 1 second.
[0073] As another example, when the preset duration is 2 seconds, multiple continuous video frame images can be divided based on the total video duration and the preset duration of 2 seconds to obtain video frame image groups corresponding to each preset duration of 2 seconds. For example, if the total video duration is 20 seconds and the preset duration is 2 seconds, 10 video frame image groups corresponding to the preset duration of 2 seconds are obtained. It should be noted that the preferred embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application.
[0074] S203, for each video frame image group, extracting a plurality of target video frame images from the video frame image group based on a preset interval;
[0075] As an example, the preset interval is pre-set. If the preset interval is not set, a plurality of target video frame images are extracted from the video frame image group based on a default interval.
[0076] Exemplarily, for example, if 5 video frame image groups are obtained based on the video file to be processed, each video frame image group includes 10 video frame images, and taking the preset interval of 2 as an example, 4 target video frame images are extracted from each video frame image group, and 20 target video frame images are extracted based on the video file to be processed.
[0077] For example, if 5 video frame image groups are obtained based on the video file to be processed, each video frame image group includes 10 video frame images, and no preset interval is set, and the default interval is 3, then 3 target video frame images are extracted from each video frame image group based on the default interval, and 15 target video frame images are extracted based on the video file to be processed.
[0078] S204, after drawing a watermark at a preset watermark position of each target video frame image based on a preset text drawing tool, synthesize each target video frame image after drawing the watermark in each video frame image group to generate a GIF file.
[0079] The embodiment of the present application provides a GIF generation method, which analyzes the track information of the video file to be processed based on the video analysis library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, divides the multiple continuous video frame images to obtain a video frame image group corresponding to each preset duration, wherein the multiple video frames in the video frame image group are continuous; for each video frame image group, based on the preset interval, extracts multiple target video frame images from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, synthesizes each target video frame image after drawing the watermark in each video frame image group to generate a GIF file. This improves the efficiency and security of the video to GIF technology, and further displays the component functions more safely and efficiently through GIF images.
[0080] As an example, Figure 3 As shown, it is a flow chart of another GIF generation method provided in an embodiment of the present application, which draws a watermark at a preset watermark position on each target video frame image based on a preset text drawing tool, including the following steps:
[0081] S301, for each target video frame image, determining a preset watermark position of the target video frame image;
[0082] S302, creating a text box at a preset watermark position based on a preset text drawing tool, and filling in the text box based on a preset watermark naming method;
[0083] S303: Use the filled text box as the watermark of the target video frame image.
[0084] As an example, the target video frame image in the present application may include multiple preset watermark positions, and the multiple preset watermark positions are set at preset distances; the preset watermark positions are set tilted relative to the horizontal direction; the preset watermark naming method is a combination of user code and user name.
[0085] Exemplarily, the preset text drawing tool may be fillText on Canvas, wherein Canvas (Chinese translation: off-screen) is used to edit or modify an image, and fillTex (Chinese translation: fill text) is used to add text content.
[0086] In a specific embodiment, for each target video frame image, multiple preset watermark positions of the target video frame image are determined, taking the default preset watermark position as an example, wherein the default preset watermark position is spaced at a preset distance and is tilted relative to the horizontal direction; a text box is created at the preset watermark position based on fillText, and the text box is filled based on a preset watermark naming method, taking the default preset watermark naming method as an example, the default preset watermark naming method is a combination of a user code and a user name. For example, if the user code is "A1234" and the user name is "Wang Wu", the default preset watermark naming method can be "A1234 Wang Wu". Finally, the filled-in text box is used as the watermark of the target video frame image. It should be noted that the preset watermark position and the preset watermark naming method can be preset by the user, and the preferred embodiment described here is only used to illustrate and explain the present application, and is not used to limit the present application.
[0087] In a possible implementation manner, after synthesizing each target video frame image after drawing a watermark in each video frame image group to generate a GIF file, it also includes: after uploading the generated GIF file to an object storage service OSS server, receiving the uniform resource locator URL of the GIF file sent by the OSS server, so that the user can obtain the GIF file based on the URL.
[0088] As an example, each target video frame image after drawing a watermark in each video frame image group is synthesized to generate a GIF file, and then a completion signal of the GIF file generation is obtained based on the gif.on('finished', function(blob){}) method, and the blob (Binary Large Object) data stream of the GIF file is obtained, wherein the blob data stream represents the binary data of the GIF file. After uploading the blob data stream of the GIF file to the OSS server, the uniform resource locator URL of the GIF file sent by the OSS server is received, so that the user can obtain the GIF file based on the URL. The OSS server is an object storage service based on cloud computing, and each object has a unique URL corresponding to it, so that it is used to obtain GIF files based on the URL, thereby improving the efficiency and security of component development.
[0089] It should be noted that the synthesis of each target video frame image after drawing a watermark in each video frame image group can be based on the gif.addFrame method, wherein the gif.addFrame method is used to add each target video frame image after drawing a watermark to the GIF file to be generated, thereby synthesizing the GIF file.
[0090] In a possible implementation, the present application encapsulates the relevant codes of the GIF generation method into an NPM (Node Package Manager) plug-in, and deploys the NPM plug-in to the internal package management platform. Developers or other authorized users can upload the video file to be processed by accessing or referencing the plug-in, thereby obtaining the converted GIF file address, improving the efficiency and security of the video to GIF technology, and then more safely and efficiently displaying the component functions through GIF images, and improving the reusability of related functions and the convenience of development.
[0091] Based on the same inventive concept, the embodiment of the present application also provides a GIF generation device, which has similar principles to the above-mentioned GIF generation method, and the repeated parts will not be repeated.
[0092] like Figure 4 As shown, it is a structural schematic diagram of a GIF generation device provided for the implementation of this application, and the device includes:
[0093] Track information analysis module 401, used to analyze the track information of the video file to be processed based on the video analysis library, determine the total duration of the video, and convert the video file to be processed into multiple continuous video frame images;
[0094] The video frame image generation module 402 is used to divide a plurality of continuous video frame images based on the total video duration and the preset duration to obtain a video frame image group corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous;
[0095] The GIF generation module 403 is used to extract multiple target video frame images from the video frame image group based on a preset interval for each video frame image group; based on a preset text drawing tool, after drawing a watermark at a preset watermark position of each target video frame image, each target video frame image after drawing the watermark in each video frame image group is synthesized to generate a GIF file.
[0096] The embodiment of the present application provides a GIF generation method and device, which parses the track information of the video file to be processed based on the video parsing library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, divides the multiple continuous video frame images to obtain a video frame image group corresponding to each preset duration, wherein the multiple video frames in the video frame image group are continuous; for each video frame image group, based on the preset interval, extracts multiple target video frame images from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, synthesizes each target video frame image after drawing the watermark in each video frame image group to generate a GIF file. This improves the efficiency and security of the video to GIF technology, and further displays the component functions more safely and efficiently through GIF images.
[0097] In some optional implementation manners, the track information parsing module 401 is specifically used for:
[0098] Decomposing the to-be-processed video file into target to-be-processed video files by a video encoding tool, wherein the target to-be-processed video file includes video data of a plurality of continuous video frame images;
[0099] The target video file to be processed is converted into a plurality of continuous video frame images by a video decoding tool.
[0100] In some optional implementation manners, the GIF generation module 403 is specifically used for:
[0101] For each target video frame image, determining a preset watermark position of the target video frame image;
[0102] Creating a text box at the preset watermark position based on the preset text drawing tool, and filling in the text box based on the preset watermark naming method;
[0103] The filled text box is used as the watermark of the target video frame image.
[0104] In some optional implementations, the GIF generation module 403 includes a plurality of preset watermark positions, and the plurality of preset watermark positions are set at preset distances;
[0105] The preset watermark position is set obliquely relative to the horizontal direction;
[0106] The preset watermark naming method is a combination of user code and user name.
[0107] In some optional implementation manners, the GIF generation module 403 is further used for:
[0108] After uploading the generated GIF file to the object storage service OSS server, the uniform resource locator URL of the GIF file sent by the OSS server is received, so that the user can obtain the GIF file based on the URL.
[0109] Based on the same inventive concept, the embodiment of the present application also provides an electronic device, which is similar in principle to the above-mentioned GIF generation method and device, and the repeated parts are not repeated. Figure 5 , which is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0110] The electronic device includes a memory 501, a processor 502, and a computer program stored in the memory 501 and executable on the processor 502. When the processor 502 executes the computer program, the steps of any method described in a GIF generation method are implemented.
[0111] The memory 501 is used to store computer programs executed by the processor 502. The memory 501 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0112] The memory 501 may be a volatile memory, such as a random-access memory (RAM); the memory 501 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 501 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 501 may be a combination of the above memories.
[0113] The processor 502 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 502 is used to implement the GIF generation method in the above embodiment when calling the computer program stored in the memory 501 .
[0114] The specific connection medium between the memory 501 and the processor 502 is not limited in the embodiment of the present application. Figure 5 In the embodiment, the memory 501 and the processor 502 are connected via a bus 503. The bus 503 is connected to the processor 502 via a bus 503. Figure 5 The connections between other components are shown in bold lines, and are not intended to be limiting. Bus 503 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 It is represented by only one thick line, but it does not mean that there is only one bus or one type of bus.
[0115] The embodiment of the present application provides a GIF generation method, device and equipment, which parses the track information of the video file to be processed based on the video parsing library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, divides the multiple continuous video frame images to obtain a video frame image group corresponding to each preset duration, wherein the multiple video frames in the video frame image group are continuous; for each video frame image group, based on the preset interval, extracts multiple target video frame images from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, synthesizes each target video frame image after drawing the watermark in each video frame image group to generate a GIF file. Thereby improving the efficiency and security of the video to GIF technology, and further displaying the component functions more safely and efficiently through GIF images.
[0116] Based on the same inventive concept, the embodiment of the present application also provides a computer-readable storage medium, which is similar in principle to the above-mentioned GIF generation method, device and electronic device, and the repeated parts are not repeated. When the computer program is executed by the processor, the steps of any method described in a GIF generation method are implemented.
[0117] The embodiment of the present application provides a GIF generation method, device, equipment and storage medium, which analyzes the track information of the video file to be processed based on the video analysis library, determines the total duration of the video, and converts the video file to be processed into multiple continuous video frame images; based on the total duration of the video and the preset duration, divides the multiple continuous video frame images to obtain a video frame image group corresponding to each preset duration, wherein the multiple video frames in the video frame image group are continuous; for each video frame image group, based on the preset interval, extracts multiple target video frame images from the video frame image group; based on the preset text drawing tool, after drawing a watermark at the preset watermark position of each target video frame image, synthesizes each target video frame image after drawing the watermark in each video frame image group to generate a GIF file. Thereby improving the efficiency and security of the video to GIF technology, and then more safely and efficiently displaying the component functions through GIF images.
[0118] The present application is described above with reference to the block diagrams and / or flow charts showing the methods, devices (systems) and / or computer program products according to the embodiments of the present application. It should be understood that a block of the block diagram and / or flow chart diagram and a combination of blocks of the block diagram and / or flow chart 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 and / or other programmable data processing device to produce a machine, so that the instructions executed by the computer processor and / or other programmable data processing device create a method for implementing the functions / actions specified in the block diagram and / or flow chart block.
[0119] Accordingly, the present application may also be implemented with hardware and / or software (including firmware, resident software, microcode, etc.). Furthermore, the present application may take the form of a computer program product on a computer-usable or computer-readable storage medium, which has a computer-usable or computer-readable program code implemented in the medium, for use by an instruction execution system or in conjunction with an instruction execution system. In the context of the present application, a computer-usable or computer-readable medium may be any medium that may contain, store, communicate, transmit, or convey a program for use by an instruction execution system, device, or apparatus, or in conjunction with an instruction execution system, device, or apparatus.
[0120] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A GIF generation method, characterized in that: The method comprises: Parsing the track information of the video file to be processed based on the video parsing library, determining the total duration of the video, and converting the video file to be processed into a plurality of continuous video frame images; Based on the total duration of the video and the preset duration, the plurality of continuous video frame images are divided to obtain video frame image groups corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous; For each video frame image group, extracting a plurality of target video frame images from the video frame image group based on a preset interval; Based on a preset text drawing tool, after drawing a watermark at a preset watermark position of each target video frame image, each target video frame image after drawing the watermark in each video frame image group is synthesized to generate a GIF file.
2. The method according to claim 1, characterized in that The step of converting the to-be-processed video file into a plurality of continuous video frame images comprises: Decomposing the to-be-processed video file into target to-be-processed video files by a video encoding tool, wherein the target to-be-processed video file includes video data of a plurality of continuous video frame images; The target video file to be processed is converted into a plurality of continuous video frame images by a video decoding tool.
3. The method according to claim 1, characterized in that Drawing a watermark at a preset watermark position on each target video frame image based on a preset text drawing tool includes: For each target video frame image, determining a preset watermark position of the target video frame image; Creating a text box at the preset watermark position based on the preset text drawing tool, and filling in the text box based on the preset watermark naming method; The filled text box is used as the watermark of the target video frame image.
4. The method according to claim 3, characterized in that comprising a plurality of preset watermark positions, wherein the plurality of preset watermark positions are arranged at preset distances; The preset watermark position is set obliquely relative to the horizontal direction; The preset watermark naming method is a combination of user code and user name.
5. The method according to any one of claims 1 to 4, characterized in that: After synthesizing each target video frame image after drawing a watermark in each video frame image group to generate a GIF file, the method further includes: After uploading the generated GIF file to the object storage service OSS server, the uniform resource locator URL of the GIF file sent by the OSS server is received, so that the user can obtain the GIF file based on the URL.
6. A GIF generation device, characterized in that: The device comprises: A track information analysis module, used to analyze the track information of the video file to be processed based on the video analysis library, determine the total duration of the video, and convert the video file to be processed into a plurality of continuous video frame images; A video frame image generation module, configured to divide the plurality of continuous video frame images based on the total duration of the video and a preset duration to obtain a video frame image group corresponding to each preset duration, wherein the plurality of video frames in the video frame image group are continuous; The GIF generation module is used to extract multiple target video frame images from each video frame image group based on a preset interval; based on a preset text drawing tool, after drawing a watermark at a preset watermark position of each target video frame image, each target video frame image after drawing a watermark in each video frame image group is synthesized to generate a GIF file.
7. The device according to claim 6, characterized in that The track information analysis module is specifically used for: Decomposing the to-be-processed video file into target to-be-processed video files by a video encoding tool, wherein the target to-be-processed video file includes video data of a plurality of continuous video frame images; The target video file to be processed is converted into a plurality of continuous video frame images by a video decoding tool.
8. The device according to claim 6, characterized in that The GIF generation module is specifically used for: For each target video frame image, determining a preset watermark position of the target video frame image; Creating a text box at the preset watermark position based on the preset text drawing tool, and filling in the text box based on the preset watermark naming method; The filled text box is used as the watermark of the target video frame image.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.