Short video generation method and device, electronic equipment and storage medium
By generating and converting statement blocks, the problems of complex sentences and unstable video quality in automated video generation technology are solved, and fast and personalized short video generation is achieved, which improves video production efficiency and maintainability.
Patent Information
- Application Number
- CN202411251420.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-07
- Publication Date
- 2024-12-10
AI Technical Summary
The existing automated video generation technology faces the problems of complex sentences and unstable video quality, which cannot meet market demand.
By obtaining the content to be produced by the user input, generating the initial statement block according to the predefined class, and calling the conversion statement to convert it into the target statement block, executing the target statement block in response to the video generation instruction, generating short video files, realizing the fully automated process, and reducing the Difficulty of manual intervention and debugging.
It realizes the rapid generation of personalized short videos, improves video production efficiency and maintainability, meets user needs and reduces the difficulty of video production.
Smart Images

Figure CN119110138A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video production technology, and in particular to a short video generation method, device, electronic device and storage medium. Background Art
[0002] With the development of the Internet and the popularization of social media platforms, the demand for short videos has shown a significant increase. In order to meet the market demand for short videos, video production technology is also constantly being updated.
[0003] Traditional video production technology relies too much on manual production. For example, video editing, special effects design, audio synthesis and other processes need to be completed manually by professional video editors. This manual production method not only requires a lot of manpower and time, but the quality of manually produced short videos cannot be guaranteed.
[0004] In order to improve the efficiency of video production, relevant video production technologies have gradually introduced automated video generation technology, attempting to reduce human intervention and complete the entire process of video generation through automated means.
[0005] However, current automated video generation technology still faces many challenges. For example, the sentences used for automatic generation are relatively complex and difficult to debug, or the quality of automatically generated videos is unstable, which makes it unable to meet market demand. Summary of the invention
[0006] The present application provides a short video generation method, device, electronic device and storage medium to solve or partially solve the problem of how to quickly generate videos while improving the maintainability of the video generation process.
[0007] The first aspect of the present application provides a short video generation method, comprising: Get the content to be produced input by the user; Generate at least one initial sentence block according to the content to be produced and the predefined class; Calling a conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block; In response to the video generation instruction, at least one of the target statement blocks is executed to generate a short video file.
[0008] In one example, generating at least one initial sentence block according to the material to be produced and the predefined class includes: Dividing the content to be produced into a plurality of materials to be produced according to the types of the predefined categories; Extracting parameters to be produced from the material to be produced according to the attributes of the predefined class; The parameters to be produced are automatically filled into corresponding attributes as attribute values to generate the initial statement block.
[0009] In one example, extracting the parameters to be produced from the material to be produced according to the attributes of the predefined class includes: Acquire the attributes of the predefined class, where the attributes are used to describe the display style and display position of the material to be produced; Extracting at least one parameter to be produced corresponding to the display style and / or display position from the material to be produced; The parameters to be produced include at least one or more of path information, size information, shape information and color information corresponding to the display style; and / or the parameters to be produced include at least coordinate information corresponding to the display position.
[0010] In one example, calling a conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block includes: Calling a conversion statement corresponding to the initial statement block; Acquire a statement block template associated with the conversion statement, wherein the statement block template includes a plurality of placeholders, each placeholder corresponding to an attribute value; The target statement block is generated by replacing the placeholder of the statement block template with the attribute value of the initial statement block.
[0011] In one example, generating the target sentence block includes: Performing complexity analysis on the content to be produced input by the user to obtain the content complexity of the content to be produced; A sentence processing method corresponding to the content complexity is determined, and a target sentence block matching the sentence processing method is generated.
[0012] In one example, the sentence processing method includes the number of the target sentence blocks, and the step of responding to the video generation instruction, executing at least one of the target sentence blocks, and generating a short video file includes: In response to the video generation instruction, detecting the number of the target sentence blocks; If the number of the target sentence blocks is equal to the preset number, the target sentence blocks are directly executed to generate and output the short video file.
[0013] In one example, the method further comprises: If the number of the target sentence blocks is greater than the preset number, executing the plurality of target sentence blocks respectively to obtain video clips corresponding to the target sentence blocks; The multiple video clips are spliced together through a video merging function to generate and output the short video file.
[0014] A second aspect of the present application provides a short video generation device, comprising: A data acquisition module is used to acquire the content to be produced input by the user; An initial sentence block generating module, used to generate at least one initial sentence block according to the content to be produced and the predefined class; A target statement block conversion module, used to call a conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block; The short video generation module is used to execute at least one of the target statement blocks in response to the video generation instruction to generate a short video file.
[0015] A third aspect of the present application provides an electronic device, including: Processor; and The memory stores executable codes thereon, and when the executable codes are executed by the processor, the processor is caused to execute the method as described above.
[0016] A fourth aspect of the present application provides a computer-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor is caused to execute the method as described above.
[0017] The technical solution provided by this application may have the following beneficial effects: In an embodiment of the present application, the content to be produced is obtained from the user input, at least one initial statement block is generated according to the content to be produced and a predefined class, a conversion statement corresponding to the initial statement block is called, the initial statement block is converted into a target statement block, and in response to a video generation instruction, at least one target statement block is executed to generate a short video file.
[0018] Compared with the related art, the technical solution of the present application can not only generate short video files based on the content to be produced input by the user, realize personalized video production and meet user needs, but also can convert at least one initial sentence block into a target sentence block by combining predefined classes and conversion statements, realize the fully automated process from user input to generating target sentence blocks, and reduce the difficulty of video production. At the same time, when it is necessary to debug or modify the sentence block, the specific part can be adjusted in a targeted manner, thereby improving the efficiency and maintainability of short video production while reducing manual intervention.
[0019] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above and other objects, features and advantages of the present application will become more apparent by describing in more detail the exemplary embodiments of the present application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the present application.
[0021] Figure 1 It is a flowchart of a short video generation method shown in an embodiment of the present application; Figure 2 is another flow chart of a short video generation method shown in an embodiment of the present application; Figure 3 It is a schematic diagram of the principle of quickly generating a short video according to an embodiment of the present application; Figure 4 is a structural schematic diagram of a short video generation device shown in an embodiment of the present application; Figure 5 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0023] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0024] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0025] As an open source multimedia processing tool, FFmpeg provides powerful video and audio processing functions. It supports audio and video decoding, encoding, transcoding, editing, synthesis and other operations in multiple formats, and provides a rich command line interface suitable for various multimedia development scenarios.
[0026] Although FFmpeg is powerful, it is not easy to use FFmpeg to generate complex animation effects. The main reasons are: First, FFmpeg's syntax is complex: FFmpeg uses a command line interface, and its command syntax is relatively complex, requiring users to have a certain technical background and understanding ability. If the video involves complex operations such as multiple filters and special effects, it is difficult for inexperienced users to independently complete the writing and debugging of FFmpeg commands.
[0027] Second, FFmpeg has difficulty implementing complex special effects: when a video involves complex operations such as multiple filters and special effects, even experienced users need to write lengthy and complex commands, resulting in inefficient video generation.
[0028] Third, FFmpeg is difficult to debug and maintain: In FFmpeg, videos are often generated through a series of parameters and commands. If the generated video effect does not meet user expectations, it is difficult to troubleshoot and debug.
[0029] Based on the above reasons, in the process of automatically generating videos, if FFmpeg is used directly to automatically generate videos, problems such as debugging difficulties and low efficiency may easily occur.
[0030] In response to the above problems, an embodiment of the present application provides a short video generation method, which can quickly generate short videos while improving the maintainability of the short video generation process.
[0031] The technical solution of the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0032] Figure 1 is a flow chart of a short video generation method shown in an embodiment of the present application. Figure 1 , the method comprises at least the following steps: Step 101, obtaining the content to be produced input by the user.
[0033] In an embodiment of the present application, a user can log in to a video production system, which provides controls and an area for uploading materials. The user can upload the content to be produced through touch, drag and drop, selection and other operations in the relevant video production interface, and can also manually enter the content to be produced directly in the video production interface.
[0034] Among them, the content to be produced refers to the information that the user expects to present in the short video file, which at least includes audio, subtitles, text effects, images, transition effects and other information.
[0035] Step 102: Generate at least one initial sentence block according to the content to be produced and the predefined class.
[0036] In the embodiment of the present application, after the video production system receives the content to be produced, it can use the predefined class to process the content to be produced, thereby generating at least one initial sentence block.
[0037] Among them, the predefined class refers to a set of classes or templates defined in advance in order to simplify and standardize input parameters during the video production process. The predefined class includes various properties and configuration options required for video production and is used to describe different types of elements and special effects.
[0038] In this application, the predefined classes may include text class, image class, subtitle class, animation class and merged video class. Different classes have different corresponding attributes and different uses.
[0039] The initial statement block refers to the statement block generated after the input parameters are extracted from the content to be produced and filled into the predefined class. The initial statement block is an intermediate step in video production and needs to be converted to generate the target statement block.
[0040] Step 103: Call the conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block.
[0041] In the embodiment of the present application, after the initial statement block is obtained, the conversion statement corresponding to the initial statement block can be called, so as to convert different initial statement blocks into corresponding target statement blocks in a targeted manner.
[0042] The conversion statement refers to a statement or rule that converts the initial statement block into a final format suitable for the FFmpeg command. The conversion statement can be used to extract the attribute values in the initial statement block and combine it with the FFmpeg command to generate a target statement block.
[0043] The target statement block refers to the final FFmpeg command fragment after the conversion statement processing, which can be directly applied to the FFmpeg command line to achieve a specific effect or processing. The target statement block contains the parameters and configuration required for actual execution. By executing the target statement block, the video production and processing can be completed.
[0044] Step 104, in response to the video generation instruction, execute at least one target statement block to generate a short video file.
[0045] In an embodiment of the present application, when a user requests to generate a video in a video production system, or the video production system automatically triggers the generation of a video, a video generation instruction can be triggered to execute at least one target statement block and quickly generate a short video file.
[0046] Among them, the video generation instruction refers to the command or operation used to start and execute the video generation process. The video generation instruction is usually issued by a user or a system, and its purpose is to trigger the video production system to execute the FFmpeg command to generate the final short video file.
[0047] In an embodiment of the present application, the content to be produced is obtained from the user input, at least one initial statement block is generated according to the content to be produced and a predefined class, a conversion statement corresponding to the initial statement block is called, the initial statement block is converted into a target statement block, and in response to a video generation instruction, at least one target statement block is executed to generate a short video file.
[0048] Compared with the related art, the technical solution of the present application can not only generate short video files based on the content to be produced input by the user, realize personalized video production and meet user needs, but also can convert at least one initial sentence block into a target sentence block by combining predefined classes and conversion statements, realize the fully automated process from user input to generating target sentence blocks, and reduce the difficulty of video production. At the same time, when it is necessary to debug or modify the sentence block, the specific part can be adjusted in a targeted manner, thereby improving the efficiency and maintainability of short video production while reducing manual intervention.
[0049] Figure 2 It is a flow chart of a short video generation method shown in another embodiment of the present application. Figure 2 relatively Figure 1 The technical solution of the embodiment of the present application is described in more detail. The method may include the following steps: Step 201, obtaining the content to be produced input by the user.
[0050] In an embodiment of the present application, the video production system can collect the content to be produced input by the user in real time.
[0051] As an example, the video production system is connected to a video production platform in communication. The video production platform provides an interface for interacting with users. Users can submit video production requests, configure video content, preview results, etc. through the interactive interface.
[0052] In actual use, users can directly upload the prepared content to be produced to the video production system on the video production platform.
[0053] As another example, users can also input the content to be produced in real time on the video production platform, for example, enter text in the text input box provided by the video production platform, and select text-related parameters through the text setting option, upload multiple pictures in the image upload area provided by the video production platform, and select image-related parameters through the image setting option, select background music in the audio selection control provided by the video production platform, and set parameters related to the background music, set animation effects in the animation setting option provided by the video production platform, etc.
[0054] Step 202: Divide the content to be produced into a plurality of materials to be produced according to the types of predefined categories.
[0055] In an embodiment of the present application, various classes are set in advance in the video production system, such as text class, image class, subtitle class, animation class and merged video class. Since different classes process different objects, it is necessary to divide the content to be produced into different materials to be produced according to the type of predefined classes.
[0056] As an optional example of the present application, the materials to be produced can be mainly divided into: texts to be produced corresponding to the text class, images to be produced corresponding to the image class, subtitles to be produced corresponding to the subtitle class, animations to be produced corresponding to the animation class, and video clips to be produced corresponding to the merged video class.
[0057] Step 203: extracting parameters to be produced from the material to be produced according to the attributes of the predefined class.
[0058] In the embodiment of the present application, the attributes of the predefined class may be acquired first, and then at least one parameter to be produced corresponding to the display style and / or display position may be extracted from the material to be produced.
[0059] Among them, the attributes of the predefined class are used to describe the display style and display position of the material to be produced (such as text, image, animation, etc.).
[0060] Display style refers to the appearance and effect of the material in the video, including visual elements such as font path, font, color, size, transparency, rotation angle, etc. The display style determines the visual performance of the material in the video.
[0061] The display position refers to the specific coordinates or area of the material in the video canvas. The display position determines the layout position of the material in the video.
[0062] The parameters to be produced extracted from the material to be produced include at least one or more of path information, size information, shape information and color information corresponding to the display style, and / or the parameters to be produced include at least coordinate information corresponding to the display position.
[0063] As an example, assuming that the predefined class is a text class, the text, text coordinates, font path, font size, font color and other production parameters are extracted from the text to be produced.
[0064] As another example, assuming that the predefined class is an image class, image path, image coordinates, image size, and other production parameters are extracted from the image to be produced.
[0065] As another example, assuming that the predefined class is a subtitle class, the subtitle address is extracted from the subtitle to be produced and waits for the production parameter.
[0066] As another example, assuming that the preset definition class is an animation class, the animation position, animation shape, and animation color waiting for production parameters are extracted from the animation to be produced.
[0067] Step 204 , automatically filling the parameters to be produced into the corresponding attributes as attribute values to generate an initial statement block.
[0068] In an embodiment of the present application, the video production system can automatically fill the parameters to be produced as attribute values into the corresponding attributes, thereby generating an initial sentence block.
[0069] In this step, filling the parameters to be produced as attribute values into the attributes of the predefined class is actually a process of generating a configuration file, so that the configuration file can contain descriptions of elements such as text, sound, animation, etc., and support users to flexibly adjust parameters to generate a short video that meets the expected effect.
[0070] As an example, suppose the structure of the literal class is: classMoivieText{ text: string, x:int, y:int, font_path: string, font_size:int, font_color: string, } Then, you can fill the "text" attribute with text as the attribute value, fill the "x" attribute with the text horizontal coordinate as the attribute value, fill the "y" attribute with the text vertical coordinate as the attribute value, fill the "font_path" attribute with font path as the attribute value, fill the "font_size" attribute with font size as the attribute value, and fill the "font_color" attribute with font color as the attribute value, thereby generating an initial statement block for the text class.
[0071] As another example, suppose the structure of the image class is: class MovieImage { x:int, y:int, img_path: string, width:int, height:int } Then, the image horizontal coordinate can be used as the attribute value to fill in the "x" attribute, the image vertical coordinate can be used as the attribute value to fill in the "y" attribute, the image path can be used as the attribute value to fill in the "img_path" attribute, the image width can be used as the attribute value to fill in the "width" attribute, and the image height can be used as the attribute value to fill in the "height" attribute, thereby generating an initial statement block for the image class.
[0072] As another example, suppose the structure of the subtitle class is: classMovieSrt { srt_path:string } Then, the subtitle address or subtitle path can be filled into the "srt_path" attribute as the attribute value, thereby generating an initial statement block for the subtitle class.
[0073] As another example, animation is mainly achieved through dynamic changes in attributes such as position, shape, and color. During the video production process, by setting the time variable t, various attributes of the material can be dynamically adjusted, thereby creating different animation effects by changing the color attributes of MovieImage (image class) or MovieText (text class), or adjusting their coordinate position, height, width, etc. in the picture, and then generating an initial sentence block for the subtitle class.
[0074] For example, the dynamic change of position: x = sin(t) changes the properties of the object x through time t.
[0075] Dynamic change of color: color=color=#2B2D30 (color value).
[0076] Dynamic changes of shape: w=sin(t)*200,h=sin(t)*200, where w and h are the width and height parameters of the object.
[0077] Step 205: Call the conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block.
[0078] In the embodiment of the present application, after obtaining different initial statement blocks, the conversion statement corresponding to the initial statement block is called to convert the initial statement block into a target statement block.
[0079] As an optional example of the present application, a conversion statement corresponding to the initial statement block is called to obtain a statement block template associated with the conversion statement. The statement block template includes several placeholders, each placeholder corresponds to an attribute value, and a target statement block is generated by replacing the placeholders of the statement block template with the attribute values of the initial statement block.
[0080] As an example, different predefined classes correspond to different statement block templates, and the placeholders corresponding to the attribute values are also different.
[0081] Initial statement block for text class: The statement block template can adopt "drawtext=fontfile=${font path}.ttf:text={text}:x=(w-text_w) / 2:y=(h-text_h) / 2:fontsize={font size}:fontcolor={font color}". After replacing the placeholders in the statement block template with the attribute values in the text class, the target statement block is generated.
[0082] Initial block for the image class: The statement block template may adopt “[0:v][1:v]overlay=x={x}:y={y}:w={width}:h={height}”, and after replacing the placeholders in the statement block template with the attribute values in the image class, a target statement block is generated.
[0083] Initial block for subtitles: The statement block template can use "-vf ass={srt_path.ass file}" to replace the placeholders in the statement block template with the attribute values in the subtitle class to generate the target statement block.
[0084] After the conversion statement processing, the target statement block that conforms to the FFmpeg syntax can be obtained. On the one hand, in actual use, if it is found that a part of the video needs to be debugged or modified, the corresponding statement block can be quickly located and the data can be adjusted accurately. On the other hand, by automatically generating FFmpeg commands, the difficulty of video production can be greatly reduced.
[0085] In addition, in the process of generating the target sentence block, the complexity of the content to be produced input by the user can be further analyzed to obtain the content complexity of the content to be produced, determine the sentence processing method corresponding to the content complexity, and generate a target sentence block matching the sentence processing method.
[0086] The statement processing method includes generating the number of target statement blocks and converting the syntax of FFmpeg commands.
[0087] If the complexity of the content to be produced is high, it is necessary to generate multiple target statement blocks so that the target statement blocks can be executed separately to generate multiple video clips, and then output short video files through splicing processing.
[0088] If the complexity of the content to be produced is low, a target statement block can be generated, and the target statement block can be directly executed to generate a short video file.
[0089] Suppose a user wants to make a video that includes multiple animation effects, text display, and picture scrolling. If these elements are directly synthesized, the synthesis process may be very time-consuming and complicated. On the contrary, if a small video clip corresponding to each element is generated separately (such as the display of each text segment, the scrolling of each picture, and the independent effect of each animation), and then all the clips are spliced into a complete video, the entire synthesis process will be more efficient and easier to control.
[0090] When the video production system analyzes and determines that the complexity of the content to be produced is high, it is known that the video synthesis time and system computing resources may increase significantly. At this time, the video production system will consider segmenting the content to be produced. For example, it first synthesizes several video clips, and then uses the video merging function in the merged video class to splice the several video clips into a final short video file, thereby improving video generation efficiency.
[0091] As an example, the process of the video production system performing complexity analysis on the content to be produced input by the user may include: ① Analyze the length and format of the text to be produced. If the text is long or contains complex formats (such as multiple fonts, colors, animation effects), it means that the content to be produced is relatively complex. ② Analyze the image resolution or filter type of the image to be produced. If the image to be produced contains a large number of high-resolution pictures or requires complex filters and special effects, it means that the content to be produced is relatively complex.
[0092] ③Analyze the number of subtitles and animation effects. If there are a large number of subtitles and animation effects, it means that the content to be produced is more complex.
[0093] As another example, the video production system can also quantify the complexity, such as formulating corresponding evaluation standards for each type of material to be produced, and using a scoring system for calculation. If the score is greater than a preset threshold, the complexity is judged to be too high, and if the score is less than or equal to the preset threshold, the complexity is judged to be low.
[0094] Step 206, in response to the video generation instruction, execute at least one target statement block to generate a short video file.
[0095] As an optional example of the present application, in response to a video generation instruction, the number of target sentence blocks is detected, and the preset number can be set to 1.
[0096] If the number of target statement blocks is equal to the preset number, the target statement blocks are directly executed to generate and output a short video file.
[0097] If the number of target sentence blocks is greater than the preset number, multiple target sentence blocks are executed separately to obtain video clips corresponding to the target sentence blocks, and the multiple video clips are spliced through the video merging function to generate and output a short video file.
[0098] As an example, if the analysis results show that the user input content is complex, you can first generate independent video clips for text, images, subtitles, animations, etc. After processing each clip separately, it will be output as an intermediate video file (such as multiple short video clips), and finally spliced into a finished video, thereby improving overall efficiency and shortening synthesis time by breaking down complex tasks into simpler small units.
[0099] The specific steps for implementing segment processing include: First, the corresponding FFmpeg commands are generated using the attribute values and predefined classes of each element. These commands are used to combine various elements into smaller video units.
[0100] For text-based elements, a video segment showing the specific text is generated.
[0101] For image elements, a video clip showing a specific image is generated.
[0102] For animation or subtitle elements, a video clip with corresponding animation effect or subtitle effect is generated.
[0103] Second, depending on the complexity of each video segment, you can choose to process multiple segments in parallel (simultaneously) or sequentially (one after the other). This step aims to reduce the overall processing time and computing resource usage.
[0104] Next, create a video list file, and list the file paths of all generated small video units one by one into a list file (eg file_list.txt).
[0105] Finally, concatenate the video units: Use FFmpeg's concat command to concatenate these small video units into a complete video file.
[0106] The merged video class can be: classMovieConcat{ file_list:string } Convert to ffmpeg syntax ffmpeg -f concat -i file_list.txtfinal.mp4 The file_list.txt file format is as follows file 001.MP4 file 002.MP4 ... file N.MP4 In order to enable those skilled in the art to better understand the technical solution of the embodiment of the present invention, an example is given below, and reference is made to Figure 3 The schematic diagram of the principle of quickly generating a short video is shown to illustrate the embodiment of the present invention.
[0107] Step S31, define text: including text, x coordinate, y coordinate, font_path font path, font_size font size, font_color color.
[0108] classMoivieText{ text: string, x :int, y:int, font_path: string, font_size:int, font_color: string, } Convert to ffmpeg syntax "drawtext=fontfile=${font path}.ttf:text={text}:x=(w-text_w) / 2:y=(h-text_h) / 2:fontsize={font size}:fontcolor={font color}" Step S32, define the image: including x coordinate, y coordinate, img_path image path, width, and height.
[0109] class MovieImage { x:int, y:int, img_path: string, width:int, height:int } Convert to ffmpeg syntax "[0:v][1:v]overlay =x={x}:y={y}:w={width}:h={height}" Step S33, define subtitles: srt_path subtitle address.
[0110] classMovieSrt { srt_path:string } Convert to ffmpeg syntax -vf ass={srt_path.ass file} Step S34, define animation: animation changes with position, shape, color, etc.
[0111] Change the color of MovieImage and MovieText according to time t, or change the x-coordinate and y-coordinate to achieve animation effects.
[0112] Step S35, video merging: If the synthesized video is very complex and the synthesis steps need to be simplified, you can first synthesize small videos and then splice multiple videos into the final finished video.
[0113] classMovieConcat{ file_list:string } Convert to ffmpeg syntax ffmpeg -f concat -i file_list.txtfinal.mp4 The file_list.txt file format is as follows file 001.MP4 file 002.MP4 ... file N.MP4 It should be noted that the embodiments of the present application include but are not limited to the above examples. It is understandable that under the guidance of the ideas of the embodiments of the present application, technical personnel in this field can make settings according to actual conditions, and the present application does not limit this.
[0114] In an embodiment of the present application, the content to be produced input by the user is obtained, the content to be produced is divided into a plurality of materials to be produced according to the types of predefined classes, parameters to be produced are extracted from the materials to be produced according to the attributes of the predefined classes, the parameters to be produced are automatically filled into the corresponding attributes as attribute values, an initial statement block is generated, a conversion statement corresponding to the initial statement block is called, the initial statement block is converted into a target statement block, and in response to a video generation instruction, at least one target statement block is executed to generate a short video file.
[0115] Compared with the related technologies, the technical solution of this application has at least the following advantages: A. This application can generate short video files based on the content to be produced input by the user, realize personalized video production, and meet user needs.
[0116] B. This application is stored in the form of "statement blocks", and the content of the statement blocks is concise. When the statement blocks need to be debugged or modified, users (such as technicians) can quickly locate the corresponding statement blocks. The statement blocks are easy to adjust and highly maintainable.
[0117] C. This application can realize automatic generation of short videos, reduce the difficulty of short video production, and can flexibly adjust the strategy of generating short videos in a timely manner according to the complexity of the data input by the user, thereby improving the efficiency of short video generation.
[0118] Corresponding to the aforementioned application function implementation method embodiment, the present application also provides a short video generation device, an electronic device and corresponding embodiments.
[0119] Figure 4 is a schematic diagram of the structure of a short video generation device shown in an embodiment of the present application. Figure 4 , the device comprises at least the following modules: The data acquisition module 401 is used to acquire the content to be produced input by the user; An initial sentence block generating module 402, used to generate at least one initial sentence block according to the content to be produced and the predefined class; The target statement block conversion module 403 is used to call the conversion statement corresponding to the initial statement block to convert the initial statement block into the target statement block; The short video generation module 404 is used to execute at least one target statement block in response to the video generation instruction to generate a short video file.
[0120] As an optional example of the present application, the initial sentence block generation module 402 includes: The content to be produced splitting submodule is used to divide the content to be produced into multiple materials to be produced according to the types of predefined categories; The submodule for extracting parameters to be produced is used to extract parameters to be produced from the materials to be produced according to the attributes of the predefined classes; The initial statement block generation submodule is used to automatically fill the parameters to be made as attribute values into the corresponding attributes to generate the initial statement block.
[0121] As an optional example of the present application, the parameter extraction submodule to be produced is used for: Get the attributes of the predefined class, which are used to describe the display style and display position of the material to be produced; Extracting at least one parameter to be produced corresponding to the display style and / or display position from the material to be produced; The parameters to be produced include at least one or more of path information, size information, shape information and color information corresponding to the display style; and / or the parameters to be produced include at least coordinate information corresponding to the display position.
[0122] As an optional example of the present application, the target sentence block conversion module 403 includes: A conversion statement calling submodule is used to call the conversion statement corresponding to the initial statement block; A statement block template acquisition submodule is used to acquire a statement block template associated with a conversion statement, wherein the statement block template includes a plurality of placeholders, each placeholder corresponding to an attribute value; The target statement block generation submodule is used to generate a target statement block by replacing the placeholder of the statement block template with the attribute value of the initial statement block.
[0123] As an optional example of the present application, the target statement block generation submodule is used to: Performing complexity analysis on the content to be produced input by the user to obtain the content complexity of the content to be produced; A sentence processing method corresponding to the content complexity is determined, and a target sentence block matching the sentence processing method is generated.
[0124] As an optional example of the present application, the sentence processing method includes the number of target sentence blocks, and the short video generation module 404 is used to: In response to the video generation instruction, detecting the number of target sentence blocks; If the number of target statement blocks is equal to the preset number, the target statement blocks are directly executed to generate and output a short video file.
[0125] As an optional example of the present application, the short video generation module 404 is used to: If the number of target sentence blocks is greater than a preset number, executing the multiple target sentence blocks respectively to obtain video clips corresponding to the target sentence blocks; Multiple video clips are spliced together through the video merging function to generate and output short video files.
[0126] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated again here.
[0127] Figure 5 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present application.
[0128] See also Figure 5 , the electronic device 500 includes a memory 510 and a processor 520 .
[0129] The processor 520 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0130] The memory 510 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 520 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at runtime. In addition, the memory 510 may include any combination of computer-readable storage media, including various types of semiconductor storage chips (such as DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 510 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0131] The memory 510 stores executable codes, and when the executable codes are processed by the processor 520 , the processor 520 can execute part or all of the methods described above.
[0132] In addition, the method according to the present application may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present application.
[0133] Alternatively, the present application can also be implemented as a computer-readable storage medium (or non-transitory machine-readable storage medium or machine-readable storage medium) on which executable code (or computer program or computer instruction code) is stored. When the executable code (or computer program or computer instruction code) is executed by a processor of an electronic device (or server, etc.), the processor executes part or all of the steps of the above-mentioned method according to the present application.
[0134] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A short video generation method, characterized in that: include: Get the content to be produced input by the user; Generate at least one initial sentence block according to the content to be produced and the predefined class; Calling a conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block; In response to the video generation instruction, at least one of the target statement blocks is executed to generate a short video file.
2. The method according to claim 1, characterized in that The step of generating at least one initial sentence block according to the material to be produced and the predefined class includes: Dividing the content to be produced into a plurality of materials to be produced according to the types of the predefined categories; Extracting parameters to be produced from the material to be produced according to the attributes of the predefined class; The parameters to be produced are automatically filled into corresponding attributes as attribute values to generate the initial statement block.
3. The method according to claim 2, characterized in that The step of extracting the parameters to be produced from the material to be produced according to the attributes of the predefined class includes: Acquire the attributes of the predefined class, where the attributes are used to describe the display style and display position of the material to be produced; Extracting at least one parameter to be produced corresponding to the display style and / or display position from the material to be produced; The parameters to be produced include at least one or more of path information, size information, shape information and color information corresponding to the display style; and / or the parameters to be produced include at least coordinate information corresponding to the display position.
4. The method according to claim 1, characterized in that: The calling of the conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block includes: Calling a conversion statement corresponding to the initial statement block; Acquire a statement block template associated with the conversion statement, wherein the statement block template includes a plurality of placeholders, each placeholder corresponding to an attribute value; The target statement block is generated by replacing the placeholder of the statement block template with the attribute value of the initial statement block.
5. The method according to claim 4, characterized in that The generating the target sentence block comprises: Performing complexity analysis on the content to be produced input by the user to obtain the content complexity of the content to be produced; A sentence processing method corresponding to the content complexity is determined, and a target sentence block matching the sentence processing method is generated.
6. The method according to claim 5, characterized in that The sentence processing method includes the number of the target sentence blocks, and the responding to the video generation instruction, executing at least one of the target sentence blocks, and generating a short video file, includes: In response to the video generation instruction, detecting the number of the target sentence blocks; If the number of the target sentence blocks is equal to the preset number, the target sentence blocks are directly executed to generate and output the short video file.
7. The method according to claim 6, characterized in that The method further comprises: If the number of the target sentence blocks is greater than the preset number, executing the plurality of target sentence blocks respectively to obtain video clips corresponding to the target sentence blocks; The multiple video clips are spliced together through a video merging function to generate and output the short video file.
8. A short video generation device, characterized in that: include: A data acquisition module is used to acquire the content to be produced input by the user; An initial sentence block generating module, used to generate at least one initial sentence block according to the content to be produced and the predefined class; A target statement block conversion module, used to call a conversion statement corresponding to the initial statement block to convert the initial statement block into a target statement block; The short video generation module is used to execute at least one of the target statement blocks in response to the video generation instruction to generate a short video file.
9. An electronic device, characterized in that: include: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the method according to any one of claims 1 to 7.
