Video generation method, electronic equipment and readable medium

Through the frame extraction method and adaptive configuration with preset intervals, the problem of deviation in video understanding in the prior art is solved, and the comprehensive and accurate understanding of video content and the display effect of one-click large-scale videos is improved.

CN119254906AActive Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410038433.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-10
Publication Date
2025-01-03
Estimated Expiration
2044-01-10

AI Technical Summary

Technical Problem

In the video editing process, when the video frames with fixed frames are drawn from front to back, the video understanding is deviated and the video content cannot be fully parsed, resulting in poor display of the generated one-click large videos.

Method used

Keyframe extraction method is used to extract frames with preset intervals. First, keyframes are extracted from a large span to achieve full range of video understanding, and then finely analyze them in key areas through small spans, combining historical frame extraction results and video analysis algorithm Adaptive configuration, optimize the number and duration of frame extraction to improve the accuracy and efficiency of video content.

Benefits of technology

It realizes a comprehensive and accurate understanding of video content, improves the display effect of generated one-click large-scale videos, balances user waiting time and hardware performance limitations, and improves the accuracy and efficiency of highlight clip recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254906A_ABST
    Figure CN119254906A_ABST
Patent Text Reader

Abstract

The invention provides a video generation method, electronic equipment and a readable medium, and the method comprises the steps: displaying a first interface which displays a thumbnail of a video and a first button; in response to the operation that a user selects at least one video on the first interface and clicks a first button, multiple first key frames are extracted from the video in a frame extraction mode at an interval of first preset duration, and pictures of the multiple first key frames are discontinuous; obtaining a highlight fragment of the video based on the plurality of first key frames; and synthesizing the highlight fragment and the special effect of the video to obtain a short video. The pictures of the plurality of first key frames are discontinuous, so that the plurality of first key frames are extracted in a large-span manner, the key frames can be extracted in a large range or a full range of the video, and the video content can be accurately and comprehensively understood based on the extracted video frames; and the video generated based on the key frame is ensured to have a good display effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and in particular to a video generation method, electronic equipment, computer program product, and computer-readable storage medium. Background Art

[0002] Electronic devices involve video editing in the process of implementing various functions. For example, when an electronic device generates a short video through the one-click blockbuster function, the electronic device needs to extract key frames from the video selected by the user. The electronic device uses key frames to represent a segment in the video to understand the content of the video segment.

[0003] The common way for electronic devices to extract key frames from videos is to extract video frames with a fixed number of frames in a scrolling manner from front to back. However, when using key frames extracted in this way to understand the video content, there are problems such as deviation in video understanding and inadequate analysis and summary of the video content, which leads to poor display effects of the one-click large-scale small video generated by key frames. Summary of the invention

[0004] The present application provides a video generation method, electronic device, computer program product and computer-readable storage medium, the purpose of which is to extract key frames that can more comprehensively and accurately represent the meaning of the video, so as to ensure that the video generated based on the key frames has a better display effect.

[0005] In order to achieve the above objectives, this application provides the following technical solutions:

[0006] In a first aspect, the present application provides a method for generating a video, including: displaying a first interface, the first interface displays a thumbnail of a video and a first button; in response to a user selecting at least one video on the first interface and clicking the first button, extracting a plurality of first key frames from the video in a frame extraction manner with a first preset time interval, wherein the images of the plurality of first key frames are discontinuous; obtaining a highlight segment of the video based on the plurality of first key frames; and synthesizing the highlight segment and special effects of the video to obtain a short video. In the scenario of the one-click blockbuster function, the first interface may refer to the interface of the one-click blockbuster function.

[0007] It can be seen from the above content that: multiple first key frames are extracted from the video in a frame extraction manner with an interval of a first preset time length. Since the images of the multiple first key frames are discontinuous, it means that the multiple first key frames are extracted in a large span manner, which can achieve the extraction of key frames in a large range or the entire range of the video, and then achieve accurate and comprehensive understanding of the video content based on the extracted video frames, ensuring that the video generated based on the key frames has a better display effect.

[0008] In a possible implementation, obtaining a highlight segment of a video based on a first key frame includes: obtaining a key area of ​​the video based on the first key frame; extracting a plurality of second key frames from the key area by using a frame extraction method with an interval of a second preset time length, wherein the second preset time length is less than the first preset time length, and the images of the plurality of second key frames are continuous; and obtaining a highlight segment in the key area based on the second key frame.

[0009] In the above possible implementation manner, the images of multiple second key frames are continuous, which means that the multiple second key frames are extracted in a small span manner. After a large-scale frame extraction for a quick overview in the first stage, and a small number of high-value areas are selected for continuous video segment analysis based on the analysis results of the first stage in the second stage, the performance is improved within the limited video analysis time and hardware performance limitations, and the recall rate of highlight segment recognition is improved.

[0010] In a possible implementation, before extracting multiple first key frames from a video in a frame sampling manner with an interval of a first preset duration, it also includes: configuring the frame sampling number and frame sampling duration of the first key frames; extracting multiple first key frames from the video in a frame sampling manner with an interval of the first preset duration, including: extracting the first key frames of the frame sampling number from the video within the frame sampling duration in a frame sampling manner with an interval of the first preset duration.

[0011] In a possible implementation, the number of frames extracted and the frame extraction duration of the first key frame are configured, including: based on the duration of the video, determining a first number of frames extracted and a second number of frames extracted for extracting the first key frame, the second number of frames extracted being greater than the first number of frames extracted; using a portion of the total duration of the video analysis as the frame extraction duration; when it is determined that the frame extraction duration is sufficient to extract the first number of key frames extracted from the video, and the extracted key frames do not exceed the second number of frames extracted, configuring the number of frames extracted for the first key frame to be the first number of frames extracted, and the frame extraction duration to be a portion of the total duration of the video analysis.

[0012] In the above possible implementation, based on the duration of the video, determining the first number of frames extracted and the second number of frames extracted for extracting the first key frame means that: the first number of frames extracted and the second number of frames extracted for extracting the first key frame are positively correlated with the duration of the video. When it is determined that the frame extraction duration is sufficient to extract the first number of frames from the video, and the extracted key frames do not exceed the second number of frames extracted, the number of frames extracted for the first key frame is configured to be the first number of frames extracted, and the frame extraction duration is a partial duration of the total video analysis duration, which can ensure that a reasonable first key frame is extracted from the video, and ensure that the frame extraction duration of the first key frame only occupies a portion of the total video analysis duration. In this way, the other part of the total video analysis duration can be used to perform a detailed analysis of the extracted first key frame to obtain a highlight segment of the video.

[0013] In a possible implementation method for extracting the first and second frame numbers of a first key frame, when a user selects a first video and a second video in a first interface, the first and second frame numbers of the first key frame are determined based on the duration of the video, and the second frame number is greater than the first frame number, including: determining the third and fourth frame numbers of the first key frame of the first video based on the duration of the first video, and determining the fifth and sixth frame numbers of the first key frame of the second video based on the duration of the second video, the fourth frame number is greater than the third frame number, and the sixth frame number is greater than the fifth frame number; determining the first frame number of the first key frame to be the sum of the third frame number and the fifth frame number, and determining the second frame number of the first key frame to be the sum of the fourth frame number and the sixth frame number.

[0014] In a possible implementation, the method further includes: when it is determined that the frame extraction time is insufficient to extract the first frame number of key frames from the first video and the second video, configuring the frame extraction number of the first key frame to be the fifth frame extraction number, and the frame extraction time is a portion of the total video analysis time; wherein, extracting the first key frame of the frame extraction number from the video within the frame extraction time in a frame extraction manner with a first preset time interval includes: extracting the first key frame of the fifth frame extraction number from the second video within the frame extraction time in a frame extraction manner with a first preset time interval; obtaining a highlight segment of the video based on multiple first key frames, including: obtaining a highlight segment of the second video based on the first key frame of the fifth frame extraction number extracted from the second video, and obtaining a highlight segment of the first video based on the first key frame in the historical frame extraction results of the first video.

[0015] In the above possible implementation, when it is determined that the frame extraction time is insufficient to extract the first number of key frames from the first video and the second video, the number of frames extracted for the first key frame is configured to be the fifth number of frames, and the frame extraction time is a portion of the total video analysis time. This reduces the number of frames required to be completed within the frame extraction time, and enables the extraction of the number of key frames within the frame extraction time even when the performance of the electronic device is poor. In addition, since the first video uses the first key frame in the historical frame extraction results to obtain the highlight segment of the first video, it is also ensured that the key frames in the first video participate in the generation of the small video, and ensures that the small video obtained is based on the first video and the second video.

[0016] In a possible implementation, after configuring the number of frames extracted from the first key frame to be the fifth number of frames, and the frame extraction time being a portion of the total video analysis time, it also includes: when it is determined that the frame extraction time is insufficient to extract the fifth number of key frames from the second video, increasing the frame extraction time to the first frame extraction time, wherein the first frame extraction time is sufficient to extract the fifth number of key frames from the second video; and configuring the frame extraction time to be the first frame extraction time.

[0017] In a possible implementation, after configuring the number of frames extracted from the first key frame to be the fifth number of frames, and the frame extraction duration being a portion of the total video analysis duration, it also includes: when it is determined that the frame extraction duration is not sufficient to extract the fifth number of key frames from the second video, configuring the frame extraction duration to be the total video analysis duration, and the total video analysis duration is sufficient to extract the fifth number of key frames from the second video, or is insufficient to extract the fifth number of key frames from the second video.

[0018] In a possible implementation, the method further includes: when it is determined that the frame extraction time is sufficient to extract a first number of key frames from the video, and the extracted key frames exceed a second number of key frames, reducing the frame extraction time to a second frame extraction time, wherein the second frame extraction time is sufficient to extract a first number of key frames from the video, and the number of key frames extracted is substantially the same as the second number of key frames; configuring the number of frame extractions of the first key frame to be the first number of frame extractions, and the frame extraction time is the second frame extraction time.

[0019] In a possible implementation, based on the length of the video, a first frame number and a second frame number for extracting a first key frame are determined, and after the second frame number is greater than the first frame number, the method further includes: when it is determined that historical frame extraction results of the video are stored in the electronic device and the video analysis algorithm capability of the electronic device has not been upgraded, the first frame number is updated based on the seventh frame number in the historical frame extraction results of the video, and the second frame number is updated based on the eighth frame number in the historical frame extraction results of the video; wherein the updated first frame number is less than the first frame number before the update, and the updated second frame number is less than the second frame number before the update.

[0020] In one possible implementation, the first frame number is updated based on the seventh frame number in the historical frame results of the video, and the second frame number is updated based on the eighth frame number in the historical frame results of the video, including: subtracting the product of the seventh frame number and the first weight from the first frame number, and subtracting the product of the eighth frame number and the second weight from the second frame number, and both the first weight and the second weight are less than 1.

[0021] In a second aspect, the present application provides an electronic device comprising: one or more processors, a memory, and a display screen; the memory and the display screen are coupled to the one or more processors, the memory is used to store a computer program, the computer program includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes a video generation method as provided in the first aspect and any one of the possible implementations.

[0022] In a third aspect, the present application provides a computer-readable storage medium for storing a computer program. When the computer program is executed, it is specifically used to implement a method for generating a video as provided in the first aspect and any one of the possible implementations.

[0023] In a fourth aspect, the present application provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the video generation method provided in the first aspect and any one of the possible implementation modes. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 A hardware structure diagram of an electronic device provided in an embodiment of the present application;

[0025] Figure 2 A software structure diagram of an electronic device provided in an embodiment of the present application;

[0026] Figure 3 A display diagram of a highlight segment of video 1 obtained in the video generation method provided in an embodiment of the present application;

[0027] Figure 4 A flowchart of a method for adjusting the frame extraction duration of key frames in a video generation method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to be used as limitations on the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context.

[0029] References to "some embodiments" and the like described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in some embodiments", "in other embodiments", etc. that appear at different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in another way.

[0030] The multiple involved in the embodiments of the present application means greater than or equal to two. It should be noted that in the description of the embodiments of the present application, the words "first", "second", etc. are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying an order.

[0031] The one-click blockbuster function or one-click movie function means that after the user selects a photo or video, he clicks the one-click blockbuster button (or the one-click movie button), and the electronic device automatically analyzes the user input material, selects the highlight clips, and combines the highlight clips with the special effects and background music configured by the electronic device to obtain a one-click blockbuster music short video (or simply a one-click blockbuster short video, a one-click blockbuster short video). Special effects refer to: special effects that can be supported by the material and added to the video frame to present special effects, such as animation effects such as snowflakes and fireworks, as well as filters, stickers, frames, etc. In some embodiments, special effects can also be referred to as styles or style themes.

[0032] When an electronic device analyzes user input materials and selects highlight clips, it is necessary to edit the video. The editing may include extracting key frames (also called representative frames, I frames, etc.) from the video to represent a clip in the video to understand the content of the video clip. Currently, the common way to extract key frames from a video is that the electronic device extracts video frames with a fixed number of frames in a scrolling manner from front to back. This frame extraction method belongs to the frame extraction method with a very small interval.

[0033] After studying the above-mentioned method of extracting key frames from videos, the inventor found that: in the process of understanding the video content based on the extracted video frames, there are problems such as video understanding deviation and inadequate analysis and summary of the video content. In addition, the key frames extracted by this method cannot accurately reflect the meaning of the video, which results in poor display effect of the one-click large-scale small video generated by the key frames.

[0034] The reason was found: in order to avoid users waiting for a long time for the electronic device to generate a one-click blockbuster video, the electronic device will configure a time limit for the generation of a one-click blockbuster video. The extraction of key frames from the video by the electronic device is a link in the generation of a one-click blockbuster video, and there is also a time limit requirement. The electronic device extracts key frames from the front to the back, and is restricted by the time limit, so it can only extract key frames from part of the content. Especially when the video is long, the electronic device can only extract key frames from a limited range of the video. The key frames extracted from the video within a limited range are one-sided or even biased in reflecting the overall meaning of the video, and cannot fully analyze the video and accurately understand the overall meaning of the video. Of course, the key frames extracted from part of the content of the video cannot accurately reflect the meaning of the video.

[0035] In order to balance the user's waiting time and the comprehensive understanding of the video, the embodiment of the present application provides a method for generating a video. The method can be applied to electronic devices such as mobile phones, tablet computers, personal digital assistants (PDAs), desktops, laptops, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, and wearable devices.

[0036] Take mobile phones as an example. Figure 1 This is an example of the composition of an electronic device provided in an embodiment of the present application. Figure 1 As shown, the electronic device 100 may include a processor 110 , an internal memory 120 , a camera 130 , a display screen 140 , and the like.

[0037] It should be understood that in order to facilitate understanding of the embodiments of the present application, Figure 1 The electronic device 100 shown in the figure only includes some components related to the video frame extraction method provided in the embodiment of the present application. Figure 1 The electronic device 100 shown may have more or fewer components. That is, Figure 1 The electronic device 100 shown does not constitute a specific limitation on the electronic device provided in the embodiment of the present application.

[0038] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a graphics processing unit (GPU), an image signal processor (ISP), and a video codec. The processor 110 may also be provided with a memory for storing instructions and data.

[0039] The internal memory 120 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 120. In some embodiments, the internal memory 120 stores instructions for a method for generating a video. The processor 110 can execute the instructions stored in the internal memory 120 to enable the electronic device to extract key frames that can more comprehensively and accurately refer to the meaning of the video, so as to ensure that the video generated based on the key frames has a better display effect.

[0040] The electronic device 100 can realize the shooting function through the ISP, the camera 130, the video codec, the GPU, the display screen 140, and the application processor, etc. The electronic device 100 can realize the display function through the GPU, the display screen 140, and the application processor, etc.

[0041] The following is an introduction to the software structure of electronic devices, which can be understood as the layered architecture of the operating system of the electronic device. The operating system of the electronic device runs on the hardware components of the electronic device and can be: iOS operating system, Android open source operating system, Windows operating system, etc.

[0042] The embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device.

[0043] Figure 2 It is a software structure block diagram of the electronic device according to an embodiment of the present application.

[0044] The layered architecture divides the software into several layers, and the layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into two layers, namely, the application layer and the application framework layer from top to bottom. Under the two-layer architecture, other layers and hardware layers may also be included. The hardware layer includes the hardware components of the electronic device, such as Figure 1 Hardware components on display.

[0045] The application layer may include multiple applications. For example, Figure 2 Two applications, photo gallery and video editing, were shown.

[0046] In some embodiments, the gallery application is used to display videos and images stored in the electronic device. The gallery application can call the video editing application to run based on user operations. During the running of the video editing application, the display screen jumps from displaying the gallery application interface to displaying the video editing application interface.

[0047] In some embodiments, the electronic device implements the one-click blockbuster function through a video editing application. Exemplarily, the gallery application displays images and videos saved by the electronic device, the user long presses an image or video, the display screen displays the one-click blockbuster function interface, and displays a one-click blockbuster button on the interface, the user selects the video material and image material to generate a one-click blockbuster small video, clicks the one-click blockbuster button, the electronic device calls the video editing application to run, automatically analyzes the user input material, selects the highlight clips, and combines the highlight clips with the special effects and background music configured by the electronic device to obtain a one-click blockbuster small video.

[0048] In some embodiments, Figure 2 As shown, the video editing application includes three functional modules: material analysis, highlight clip editing and splicing, and film-like film effect synthesis. Material analysis is used to analyze the video material and image material selected by the user to generate a one-click large and small video. The results of material analysis can be provided to the lower-level modules. Highlight clip editing and splicing is used to edit and splice highlight clips based on the timestamps of the highlight clips provided by the lower-level modules. The lower-level modules mentioned here can refer to Figure 2 The functions of the displayed media processing platform can be found in the following content. The movie-like film effect synthesis is used to synthesize the highlight clips and the special effects and background music configured by the electronic equipment to obtain a small video with one click.

[0049] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. For example, Figure 2 The application framework layer shown may include a media processing middle platform for providing an application programming interface and a programming framework for video editing applications.

[0050] In some embodiments, the media processing center is used to first perform a large-span I-frame extraction operation on the video material, to achieve I-frame extraction over a large range or even the entire range of the video material, and then quickly overview the video through the extracted I-frames to identify the rough area (or key area) where the highlight segment of the video material is located. The media processing center is also used to perform a detailed analysis of the key area to determine the precise position, range, and highlight features (such as highlight actions, postures, and expressions) of the highlight segments of the video material, and report the precise position, range, and highlight features (such as highlight actions, postures, and expressions) of the highlight segments of the determined video material to the video editing application.

[0051] The following combination Figure 3, the electronic device obtains the highlight fragment of the video material selected by the user during the process of generating a one-click large and small video by the electronic device. It can be known that the media processing middle platform of the electronic device application framework layer obtains the highlight fragment of the video material selected by the user.

[0052] For example, Figure 3 As shown, the video material selected by the user includes video 1 and video 2. First of all, it should be noted that when the user selects multiple video materials, the electronic device splices the multiple video materials into a long video for I frame extraction analysis. After the electronic device extracts the I frame analysis, the number of I frame extractions for each video material can be obtained. In some embodiments, the electronic device uniformly plans the number of I frame extractions allocated to each video material based on the total duration of the video analysis and the specifications and length of the input video material.

[0053] After the electronic device performs I-frame extraction analysis to obtain the number of I-frame extractions for each video material, the electronic device extracts key frames corresponding to the number of I-frame extractions from each video material. The electronic device can infer the theme of the video material through a theme analysis algorithm based on the extracted key frames. In this way, the electronic device can obtain a special effects template based on the theme of the video material. The electronic device can also compare the picture similarities between key frames based on the extracted key frames, preliminarily obtain similar picture groupings, and then obtain the storyboard position of each video material, that is, the timestamp of the image indicating the storyboard.

[0054] Taking Video 1 as an example, the following describes in detail the process of the electronic device obtaining the highlight segment of Video 1 based on the I frame extracted from Video 1. The electronic device obtains the highlight segment of Video 2 in the same way, which will not be described in detail.

[0055] After the electronic device obtains the number of I-frame extractions of video 1, the electronic device performs the frame extraction link of the first round of fast preview operation, that is, extracts I-frames, i.e., key frames, of the number of I-frame extractions from video 1 by extracting video frames in a large span. Extracting video frames in a large span can be understood as the electronic device extracting video frames at intervals of several seconds, and the extracted video frames are not continuous. In this way, the electronic device can ensure that key frames are extracted in a large range or the entire range of video 1, and then accurately and comprehensively understand the video content based on the extracted video frames.

[0056] Moreover, after the electronic device accurately and comprehensively understands the video content based on the key frames extracted from a large range or the entire range of video 1, the theme of video 1 inferred by the electronic device is also accurate, and a special effects template that better matches the theme of video 1 can be obtained, ensuring a better display effect of large and small videos with one click.

[0057] In some embodiments, the electronic device further groups the extracted key frames based on the similarity of the images to obtain similar picture groups, such as Figure 3 As shown, the first two key frames extracted are similar picture group 1, the third to fifth key frames extracted are similar picture group 2, and the sixth and seventh key frames extracted are similar picture group 3.

[0058] In some embodiments, a similar picture group obtained by the electronic device is a storyboard obtained by rough analysis. Figure 3 As shown, the electronic device obtains three storyboards of video 1 based on similar picture grouping 1, similar picture grouping 2 and similar picture grouping 3.

[0059] In other embodiments, the electronic device obtains the key area corresponding to the video material based on each similar picture group of the video material and the content and picture quality evaluation of the key frame. The key area is a candidate area for performing a second round of fine analysis to obtain a highlight segment.

[0060] In some embodiments, the electronic device may determine a similar picture group with wonderful content among multiple similar picture groups based on the content of the key frames in each similar picture group. Based on the first and last images in the similar picture group with wonderful content, the electronic device selects a video clip from a period of time before the timestamp of the first image to a period of time after the timestamp of the last image as the key area corresponding to the video material. Alternatively, the electronic device may also obtain the key area corresponding to the video material based on the high-scoring images in the similar picture group with wonderful content. In some embodiments, the electronic device determines a high-scoring image in a similar picture group based on a video analysis algorithm. The electronic device evaluates the image quality of the image in the similar picture group based on the video analysis algorithm to obtain the score of the image, and the electronic device uses the image with a high score as a high-scoring image. There may be multiple video analysis algorithms, and the electronic device comprehensively evaluates the image based on the score of each video analysis algorithm, and uses the image with a high comprehensive score as a high-scoring image.

[0061] The electronic device also performs a second round of detailed analysis on the key areas, that is, the electronic device extracts frames in a small span from the key areas, such as extracting 10 frames per second. Since the key frame intervals of the small span frame extraction are very small, it can be basically understood as extracting continuous video clips. The electronic device analyzes the extracted video frames to obtain the actual position of the highlight clips in the key areas.

[0062] In some embodiments, when the electronic device extracts frames in small spans in key areas, it may also be based on the following principles: extract less in areas with similar content and more in areas with changed content; extract less in areas with low quality and more appropriately in areas with high quality.

[0063] In the video generation method provided in the embodiment of the present application, the related technology for analyzing continuous video clips is not used as the main direction, but the key frames are extracted from the video material. The main reason is that:

[0064] 1. The inventors found that the speed of video analysis is a key experience indicator and a manifestation of competitiveness;

[0065] 2. The video decoding and video analysis capabilities of electronic devices are limited and cannot support the analysis of large-scale continuous video clips;

[0066] 3. Reserve support for multiple rounds of progressive analysis capabilities for subsequent gallery application analysis scenarios.

[0067] In addition, after a large-scale frame sampling for a quick overview in the first stage, and a small number of high-value areas selected for continuous video segment analysis based on the analysis results of the first stage in the second stage, it is possible to improve performance within the limited analysis time and hardware performance limitations and increase the accuracy of highlight segment recognition.

[0068] The following introduces the process of adaptively configuring the frame extraction duration of key frames in the video generation method provided in the embodiment of the present application.

[0069] like Figure 4 As shown, the method for adaptively configuring the frame extraction duration of the key frame includes:

[0070] S401, calculating the basic frame number of key frames based on the duration of the video material.

[0071] The basic number of extracted frames of the key frames of the video material can be understood as the minimum number of key frames extracted from the video material to participate in the generation of a one-click large or small video.

[0072] In some embodiments, the user selects only one video material in the interface of the one-click blockbuster function displayed in the gallery application, and the electronic device can calculate the basic number of key frames based on the duration of the video material. In other embodiments, the user selects multiple video materials in the interface of the one-click blockbuster function displayed in the gallery application, and the electronic device needs to calculate the basic number of key frames of the video material based on the duration of the video material for each video material selected by the user. The sum of the basic number of key frames of multiple video materials is used as the basic number of key frames of the long video composed of multiple video materials.

[0073] In some embodiments, the basic number of frames to be extracted for calculating key frames based on the duration of the video material must meet the following rules:

[0074] 1. Extract at least one key frame for a video material; when the duration of the video material is greater than or equal to 3 seconds, extract 2 key frames.

[0075] 2. When the duration of a video material reaches 5 seconds, one more key frame will be added until it reaches 30 seconds, that is, a total of 8 key frames will be added.

[0076] 3. If the duration of the video material is longer than 30 seconds, for the duration of the video content after 30 seconds, one more key frame will be drawn for every 10 seconds until 90 seconds, that is, a total of 14 key frames will be drawn.

[0077] It should be noted that in order to ensure a more accurate video theme, the key frames of the video material must not be less than 5. Among them, when the user selects only one video material, the basic number of key frames of the video material calculated according to the above three rules is less than 5, then the basic number of key frames is adjusted to 5.

[0078] When the video material selected by the user is any one from 2 to 4, the total number of basic frame extractions of key frames of multiple video materials calculated according to the above three rules is less than 5, and for each video material with less than 2 key frames, the basic frame extraction number is adjusted to 2. If the total number of basic frame extractions after adjustment still does not reach 5, then the video material with the longest duration among the video materials with a basic frame extraction number of 2 is adjusted to a basic frame extraction number of 3.

[0079] S402: Calculate the maximum number of key frames to be extracted based on the duration of the video material.

[0080] The maximum number of key frames extracted from a video material can be understood as the maximum number of key frames extracted from the video material that participate in the generation of a one-click large or small video.

[0081] In some embodiments, the user selects only one video material in the interface of the one-click blockbuster function displayed in the gallery application, and the electronic device can calculate the maximum number of key frame extractions based on the duration of the video material. In other embodiments, the user selects multiple video materials in the interface of the one-click blockbuster function displayed in the gallery application, and the electronic device needs to calculate the maximum number of key frame extractions of the video material based on the duration of the video material for each video material selected by the user. The sum of the maximum number of key frame extractions of multiple video materials is used as the maximum number of key frame extractions of the long video composed of multiple video materials.

[0082] In some embodiments, the maximum number of frames extracted based on the duration of the video material is calculated to meet the following rules:

[0083] 1. Extract at least one key frame for a video material; when the duration of the video material is greater than or equal to 2 seconds, extract 2 key frames.

[0084] 2. When the duration of a video material reaches 3 seconds, one more key frame is added until it reaches 30 seconds, that is, a total of 12 key frames are added.

[0085] 3. If the duration of the video material is longer than 30 seconds, for the duration of the video content after 30 seconds, one more key frame will be drawn for every 10 seconds until 120 seconds, that is, a total of 21 key frames will be drawn.

[0086] It should be noted that the maximum number of key frame extractions of the video material must also meet the requirements for obtaining a more accurate video theme as mentioned above.

[0087] S403: Determine whether historical frame extraction results of the video material are stored, and whether the historical video analysis algorithm capability is equal to the current video analysis algorithm capability.

[0088] The historical frame extraction results of the video material include: the historical basic frame extraction number and the historical maximum frame extraction number of the key frames of the video material; it can also include the analysis results of the key frames extracted from the video material, such as the content of the key frames and the picture quality evaluation results.

[0089] Before the user selects one or more video materials to generate a one-click large-scale short video, the user may have performed an operation of generating a one-click large-scale short video based on the video materials selected this time. For the operation of generating a one-click large-scale short video input by the user in the past, the electronic device can record the basic frame extraction number and the maximum frame extraction number of the key frames of the video material selected by the user, and can also record the analysis results of the key frames extracted from the video material. The electronic device can determine whether the historical frame extraction results of the video material are stored by reading the historical record table.

[0090] Based on the video analysis algorithm, the electronic device performs content analysis and picture quality analysis on the key frames extracted from the video material to obtain analysis results, which are then used to make decisions on the key frames required to generate a one-click blockbuster video.

[0091] As the operating system and video editing application of the electronic device are updated, the video analysis algorithm configured in the electronic device may also be updated. Generally, after the video analysis algorithm is updated, its processing capability or stability is enhanced. After the video analysis algorithm is updated, the video analysis algorithm before the update is called the historical video analysis algorithm, and the video analysis algorithm after the update is called the current video analysis algorithm.

[0092] In some embodiments, the electronic device compares the historical video analysis algorithm with the current video analysis algorithm and determines that the number of the current video analysis algorithm is greater than the number of the historical video analysis algorithms, that is, the electronic device has more functions that can be executed based on the current video analysis algorithm, and then the electronic device determines that the historical video analysis algorithm capability is lower than the current video analysis algorithm capability. For example: there are 3 historical video analysis algorithms, and the electronic device can analyze the extracted key frames in the clarity dimension, aesthetic dimension, and face recognition dimension based on the 3 historical video analysis algorithms. The analysis results determine whether the key frames are used to generate a one-click blockbuster video. The current video analysis algorithm has added the function of recognizing pet faces. The current video analysis algorithm includes 4 algorithms, that is, the electronic device can determine whether the extracted key frames are used to generate a one-click blockbuster video in the clarity dimension, aesthetic dimension, face recognition dimension, and pet face recognition dimension based on the 4 historical video analysis algorithms.

[0093] In other embodiments, the electronic device determines that the functions performed by the current video analysis algorithm and the historical video analysis algorithm are the same, but the accuracy of the execution result of the current video analysis algorithm is higher than the accuracy of the execution result of the historical video analysis algorithm. The electronic device then determines that the capability of the historical video analysis algorithm is not equal to the capability of the current video analysis algorithm, that is, it is lower than the capability of the current video analysis algorithm.

[0094] If the electronic device determines that historical frame extraction results of video materials are stored and the historical video analysis algorithm capability is equal to the current video analysis algorithm capability, step S404 is executed, and then step S405 and subsequent steps are executed; otherwise, step S405 and subsequent steps are directly executed.

[0095] S404, updating the basic frame extraction number to the basic frame extraction number - the historical basic frame extraction number × 0.7, and updating the maximum frame extraction number to the maximum frame extraction number - the historical maximum frame extraction number × 0.7.

[0096] For the video material selected by the user this time, the electronic device stores the historical frame extraction results of the video material, and the historical video analysis algorithm capability is equal to the current video analysis algorithm capability, which means that the video analysis algorithm has not been upgraded to update the capability, and the historical frame extraction results obtained by the historical video analysis algorithm for the video material can be used in the process of generating a one-click large-scale small video this time. Therefore, the electronic device can reduce the basic frame extraction number of the key frames of the video material obtained in step S401 and the maximum frame extraction number of the key frames of the video material obtained in step S402 to save frame extraction time and analysis time for the extracted key frames.

[0097] The electronic device may subtract the historical basic frame extraction number from the basic frame extraction number to obtain the updated basic frame extraction number. Similarly, the electronic device may subtract the historical maximum frame extraction number from the maximum frame extraction number to obtain the updated maximum frame extraction number. Considering that the historical basic frame extraction number and the historical maximum frame extraction number in the historical frame extraction results may be smaller, the electronic device multiplies the historical basic frame extraction number and the historical maximum frame extraction number by a constant less than 1, and 0.7 is an example of the constant. The electronic device subtracts the historical basic frame extraction number multiplied by the constant from the basic frame extraction number to obtain the updated basic frame extraction number. Similarly, the electronic device subtracts the historical maximum frame extraction number multiplied by the constant from the maximum frame extraction number to obtain the updated maximum frame extraction number.

[0098] For the video material selected by the user this time, the electronic device does not store the historical frame extraction results of the video material, and the electronic device selects the basic frame extraction number and the maximum frame extraction number obtained in step S401 and step S402 to perform the following steps. In addition, after the electronic device executes the one-key blockbuster function this time, the frame extraction results of the video material selected by the user this time can be stored.

[0099] Alternatively, for the video material selected by the user this time, the electronic device stores the historical frame extraction results of the video material, but determines that the historical video analysis algorithm capability is not equal to the current video analysis algorithm capability, which means that the video analysis algorithm has been upgraded, the capability has been improved, and the historical frame extraction results are not suitable for executing the one-key blockbuster function this time. Therefore, the electronic device uses the basic frame extraction number and the maximum frame extraction number obtained in step S401 and step S402 to perform the following steps. In addition, after the electronic device executes the one-key blockbuster function this time, for the video material selected by the user this time, its historical frame extraction results can be updated based on the frame extraction results of this execution of the one-key blockbuster function.

[0100] It should be noted that the historical frame extraction results obtained by the historical video analysis algorithm for the video material are used in the process of generating a one-click large and small video this time, which means that the electronic device obtains the first round of frame extraction time and the number of frames of the video material selected by the user based on the configuration method of the frame extraction time provided in this embodiment, and based on the frame extraction time, the electronic device extracts key frames that meet the number of frames in the video material selected by the user. Afterwards, the electronic device performs content analysis and picture quality analysis on the extracted key frames through the video analysis algorithm to obtain the analysis results of the key frames. The electronic device comprehensively evaluates the analysis results of the key frames in the historical frame extraction results and the analysis results of the key frames extracted this time, and decides on the theme corresponding to the video material and the highlight segment of the video material (by first deciding on the key area of ​​the video material, and then deciding on the highlight segment in the key area).

[0101] In some embodiments, step S403 and step S404 may not be performed.

[0102] S405: The frame extraction duration of the key frame is configured to be 30% of the total video analysis duration.

[0103] The key frame extraction duration refers to the time taken to extract the basic number of key frames from the video material. In some embodiments, the user selects a video material, and the key frame extraction duration refers to the time taken to extract the basic number of key frames from the video material. In other embodiments, the user selects multiple video materials, and the key frame extraction duration refers to the time taken to extract the basic number of key frames from the long video composed of multiple video materials. The basic total number of key frames is the sum of the basic number of key frames of multiple video materials.

[0104] Normally, the time it takes to extract key frames from video material only accounts for a small part of the overall time it takes for an electronic device to generate a one-click blockbuster or small video. Ignoring the time it takes for the electronic device to download special effects templates and the time it takes to synthesize highlight clips, images, special effects, and background music in the video material, the overall time it takes for an electronic device to generate a one-click blockbuster or small video can be understood as the total time it takes for video analysis. It can also usually refer to the time it takes for a user to select video material or image material, click on the one-click blockbuster or small video, and wait for the electronic device to generate and display the one-click blockbuster or small video.

[0105] Because the frame extraction time of extracting key frames from video materials only accounts for a small part of the overall time consumed by the electronic device to generate a one-click large-scale small video, the electronic device usually configures the frame extraction time of extracting key frames from video materials to be less than 50% of the total video analysis time. For example, the frame extraction time of extracting key frames from video materials is configured to be 30% of the total video analysis time. In this way, the electronic device can leave a larger part of the total video analysis time to perform subsequent detailed analysis.

[0106] In some embodiments, the electronic device may determine the total duration of the video analysis based on the amount of video material selected by the user and the duration of the video material. The determination rule is: the greater the total duration of the video material selected by the user, the greater the total duration of the video analysis. Of course, in order to prevent the user from waiting too long, the total duration of the video analysis is configured with a maximum value, and the total duration of the video analysis determined by the electronic device shall not exceed the maximum value.

[0107] S406: Determine whether 30% of the total video analysis duration is insufficient to extract key frames of a basic frame extraction quantity.

[0108] As described in step S405, 30% of the total duration of video analysis is the duration of key frame extraction, and the developers hope that the electronic device can complete the extraction of the basic number of key frames within this duration. However, in actual situations, when the performance of the electronic device is not good enough, the electronic device may not be able to extract the basic number of key frames within 30% of the total duration of video analysis. Based on this, the electronic device makes a pre-judgment based on step S406: whether the electronic device is insufficient to extract the basic number of key frames within 30% of the total duration of video analysis.

[0109] In some embodiments, the electronic device determines whether 30% of the total video analysis duration is insufficient to extract the key frames of the basic frame extraction quantity in the following manner:

[0110] Based on its own performance, the electronic device obtains an estimated number of key frames extracted within 30% of the total video analysis time. The electronic device compares the estimated number with the basic frame extraction number. When the estimated number is greater than the basic frame extraction number, it is determined that the electronic device is sufficient to extract key frames of the basic frame extraction number within 30% of the total video analysis time; otherwise, it is determined that the electronic device is insufficient to extract key frames of the basic frame extraction number within 30% of the total video analysis time.

[0111] When the user selects multiple video materials, the basic frame extraction number in this step refers to the sum of the basic frame extraction numbers of key frames of the multiple video materials.

[0112] If the electronic device determines that 30% of the total video analysis duration is insufficient to extract the key frames of the basic frame extraction quantity, step S407 is executed; otherwise, step S410 is executed.

[0113] S407: When it is determined that the capability of the historical video analysis algorithm is lower than that of the current video analysis algorithm, the first video material is not analyzed, and the electronic device stores the historical frame extraction results of the first video material.

[0114] When the electronic device determines that 30% of the total video analysis duration is insufficient to extract key frames of the basic frame extraction quantity, it indicates that the performance of the electronic device is insufficient to support the extraction of key frames of the basic frame extraction quantity within 30% of the total video analysis duration. In this way, it is necessary to reduce the number of key frames extracted by the electronic device within 30% of the total video analysis duration. Based on this, the electronic device searches for the video material that stores historical frame extraction results from the video material selected by the user this time, which is called the first video material; when the electronic device determines that the corresponding historical video analysis algorithm capability of the first video material is lower than the current video analysis algorithm capability, it is configured not to analyze the first video material.

[0115] In some embodiments, for a first video material that is configured not to be analyzed, the electronic device may reuse the historical frame extraction results of the first video material without extracting key frames from the first video material and executing a subsequent key frame analysis process.

[0116] In other embodiments, the electronic device should also configure the first video material to not be analyzed according to the following rules.

[0117] 1. For video material configured not to be analyzed, the historical frame extraction results stored in the electronic device may indicate that the electronic device has completed the key frame analysis process for the key frames of the basic frame extraction quantity obtained in step S401 for the video material.

[0118] Exemplarily, for a video material, the last time the electronic device executed the one-click large and small video function, 10 key frames were extracted from the video material, and the subsequent key frame analysis process was performed on the 10 key frames. The electronic device once again executes the one-click large and small video function based on the video material. During the process of the electronic device executing the one-click large and small video function this time, the basic number of extracted frames obtained through step S401 is 8. In this way, the electronic device determines that the 8 key frames have completed the key frame analysis process before based on the historical frame extraction results of the video material, and therefore, the video material can be configured not to be analyzed.

[0119] On the contrary, when the electronic device executes the one-key large movie and small video function once, 3 key frames are extracted from the video material, and the subsequent key frame analysis process is performed for the 3 key frames. During the electronic device's execution of the one-key large movie and small video function this time, the basic number of extracted frames obtained through step S401 is 8. In this way, the electronic device determines that the 8 key frames have not completed the key frame analysis process before based on the historical frame extraction results of the video material. Therefore, the video material cannot be configured to not be analyzed.

[0120] 2. In the first video material that meets 1, the electronic device randomly selects the first video material and configures it not to be analyzed.

[0121] The purpose of using the random selection method is to avoid a specific selection method such as giving priority to the one with more analyzed frames, which results in some video materials always being configured not to be analyzed and their historical frame extraction results not being updated for a long time.

[0122] 3. The electronic device selects one or more first video materials and configures them not to be analyzed until any one of the following conditions is met:

[0123] (1) 30% of the total video analysis duration is sufficient to complete the basic frame extraction of the remaining video material; the remaining video material refers to: the remaining video material in the video material selected by the user excluding the first video material configured not to be analyzed.

[0124] (2) The total number of remaining video materials has been reduced to 50% of the original number (rounded up), or the first video material that satisfies 1 has been reduced to only 1 remaining; the original number refers to the number of video materials selected by the user.

[0125] The purpose of setting condition (2) is to avoid the situation where all or too much video material is not analyzed, resulting in the historical frame extraction results of the video material not being updated.

[0126] The manner in which the electronic device determines whether the capability of the historical video analysis algorithm is lower than the capability of the current video analysis algorithm can be found in the above-mentioned step S403, which will not be described again here.

[0127] S408: Determine whether 30% of the total video analysis duration is insufficient to extract key frames of a basic frame extraction quantity.

[0128] After the electronic device executes step S407, it executes step S408 again to determine whether the 30% time of the total video analysis duration is insufficient to extract key frames of the basic frame extraction quantity. In some embodiments, the electronic device compares the estimated number of key frames extracted within 30% of the total video analysis duration with the key frames of the basic frame extraction quantity. When the estimated number of key frames extracted within 30% of the total video analysis duration is less than the key frames of the basic frame extraction quantity, it means that the 30% time of the total video analysis duration is insufficient to extract the key frames of the basic frame extraction quantity. The basic frame extraction quantity of this step refers to the sum of the basic frame extraction quantities of the remaining video materials, and the remaining video materials refer to: the remaining video materials in the video materials selected by the user excluding the first video materials configured not to be analyzed.

[0129] If the electronic device determines that 30% of the total video analysis time is insufficient to extract the key frames of the basic frame extraction quantity, step S409 is executed; otherwise, step S410 is executed.

[0130] S409: Increase the key frame extraction time until the time requirement for extracting the key frames of the basic frame extraction quantity is met or until the total video analysis time is reached.

[0131] After the electronic device reduces the number of key frames extracted within 30% of the total video analysis time through step S407, the electronic device determines through step S408 that the 30% of the total video analysis time is not enough to extract the basic number of key frames, and the electronic device can increase the key frame extraction time to test whether it can achieve the goal of extracting the basic number of key frames within 30% of the total video analysis time. The basic number of frames extracted in this step also refers to the sum of the basic number of frames extracted for the remaining video materials, and the remaining video materials refer to: the remaining video materials in the video materials selected by the user except the first video material configured not to be analyzed.

[0132] It can be known from step S404 that the electronic device initially configures the frame extraction time of the key frame to be 30% of the total video analysis time. On this basis, the electronic device gradually increases the frame extraction time of the key frame, and based on the increased frame extraction time of the key frame, the electronic device determines whether it can extract the key frames of the basic frame extraction number. When the electronic device determines that the key frames of the basic frame extraction number can be extracted, the electronic device stops increasing the frame extraction time of the key frame, otherwise it continues to increase the frame extraction time of the key frame until the increased frame extraction time of the key frame meets the time-consuming requirement for extracting the key frames of the basic frame extraction number.

[0133] The electronic device continuously increases the key frame extraction time until the key frame extraction time reaches the total video analysis time. If the total video analysis time is still insufficient for the electronic device to extract the basic number of key frames, the electronic device no longer increases the key frame extraction time and configures the key frame extraction time to the total video analysis time.

[0134] It should be noted that the frame extraction time of the electronic device configured with the key frame is the total video analysis time, which means that after the electronic device extracts the key frame from the video material and obtains the key area of ​​the video material with the key frame, the electronic device does not have extra time to analyze the highlight segment from the key area, and the electronic device directly obtains the highlight segment based on the key frame of the video material. The possible problems are:

[0135] 1. The electronic device directly obtains the highlight clip based on the key frames of the video material. Due to the lack of the step of analyzing the highlight clip from the key area, it may not be able to extract the highlight action image from the video material to form the highlight clip. For example, the highlight action image is an image indicating the highest point in the video material of a person jumping, and an image indicating the brightest smile in the video material of a person playing.

[0136] 2. When electronic devices directly obtain highlight clips based on key frames of video materials, some images may have poor quality. For example, the picture quality of key frames extracted from video materials is very good, but the picture quality of some video frames in a period of time before and after the key frames is very poor. In this way, the highlight clips obtained based on the key frames and the video frames in a period of time before and after them have poor image quality. Another example is that the picture quality of key frames extracted from video materials is very poor, but the picture quality of the middle clip between the front and rear key frames is very good. The image of the middle clip cannot be used as the image in the highlight clip, which also leads to poor image quality in the highlight clip.

[0137] The inventor found that problem 1 in the electronic device's one-click movie and video function does not have an essential impact on the one-click movie and video function. Compared with the related art that only extracts key frames from a small range of videos, the impact of this problem is minimal. The electronic device uses the key frames extracted by the embodiment of the present application to basically indicate the overall meaning of the video material, balancing the user's waiting time and the comprehensive understanding of the video. In addition, the inventor also found that the probability of problem 2 occurring is relatively low. The reason for this is that with the development of shooting technology, the video shot by the electronic device can basically guarantee that the picture quality of the video frame is good, so the probability of problem 2 occurring is very low.

[0138] It should also be noted that when the electronic device increases the key frame extraction time to the total video analysis time, or increases it to meet the time requirement for extracting the basic number of key frames, the electronic device uses the increased key frame extraction time to perform the operation of extracting key frames from the video material, that is, the time consumed by the electronic device to extract key frames from the video material is the increased key frame extraction time.

[0139] In the process of extracting key frames from multiple video materials based on the total video analysis duration, the electronic device obtains the actual number of frames extracted for each video material based on the proportional relationship between the number of key frames extracted from the total video analysis duration and the basic number of frames extracted from multiple video materials obtained in step S401, and the electronic device extracts key frames from the video material according to the actual number of frames extracted from each video material.

[0140] S410: Determine whether the maximum number of key frames extracted exceeds 30% of the total video analysis time.

[0141] In actual situations, the electronic device has good performance, and is able to extract the basic number of key frames within 30% of the total video analysis time, and even has some capacity left. Based on this, the electronic device executes step S410.

[0142] Alternatively, after the electronic device reduces the number of key frames extracted within 30% of the total video analysis duration through step S407, the electronic device then determines through step S408 that 30% of the total video analysis duration is sufficient to extract the basic number of key frames, and based on this, the electronic device also executes step S410.

[0143] In some embodiments, the electronic device compares the estimated number of key frames extracted within 30% of the total video analysis time with the maximum number of extracted frames. When the estimated number is greater than the maximum number of extracted frames, it is determined that the electronic device has exceeded the maximum number of extracted key frames within 30% of the total video analysis time; otherwise, it has not exceeded the maximum number.

[0144] If the electronic device determines that the number of key frames extracted exceeds the maximum number of frames extracted within 30% of the total video analysis time, step S411 is executed. If the electronic device determines that the number of key frames extracted within 30% of the total video analysis time does not exceed the maximum number of frames extracted, the electronic device performs an operation of extracting key frames from the video material, and the time consumed for extracting key frames is 30% of the total video analysis time.

[0145] S411, reducing the key frame extraction time until the time requirement for extracting the key frames with the maximum number of extracted frames is just met.

[0146] If the electronic device determines that the number of key frames extracted within 30% of the total video analysis time exceeds the maximum number of extracted frames, it means that the time consumed by the electronic device to extract the key frames of the basic number of extracted frames from the video material is less than 30% of the total video analysis time. In this way, the electronic device can reduce the extraction time of the key frames to avoid wasting time.

[0147] In some embodiments, the electronic device gradually reduces the frame extraction time of the key frame based on the frame extraction time of the key frame, and based on the frame extraction time of the key frame after the reduction, the electronic device determines whether the key frame extraction exceeds the maximum number of frame extractions. When the electronic device determines that the key frame extraction exceeds the maximum number of frame extractions, the electronic device continues to reduce the frame extraction time of the key frame until the reduced frame extraction time of the key frame just meets the time requirement for extracting the maximum number of frame extractions.

[0148] It should be noted that the electronic device uses the reduced key frame extraction time to perform the operation of extracting key frames from the video material, that is, the time consumed by the electronic device to extract key frames from the video material is the reduced key frame extraction time.

[0149] Another embodiment of the present application further provides a computer-readable storage medium, which stores instructions, and when the computer-readable storage medium is executed on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

[0150] The computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0151] Another embodiment of the present application further provides a computer program product including instructions. When the computer program product is run on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

Claims

1. A method for generating a video, characterized in that: include: Displaying a first interface, wherein the first interface displays a thumbnail of the video and a first button; In response to a user selecting at least one video on the first interface and clicking the first button, a plurality of first key frames are extracted from the video in a frame extraction manner with a first preset time interval, and the images of the plurality of first key frames are discontinuous; Obtain a highlight segment of the video based on the plurality of first key frames; The highlight segments and special effects of the video are synthesized to obtain a short video.

2. The method for generating a video according to claim 1, characterized in that: Obtaining a highlight segment of the video based on the first key frame includes: Based on the first key frame, obtaining a key area of ​​the video; Extracting a plurality of second key frames from the key area by using a frame extraction method with intervals of a second preset time length, wherein the second preset time length is shorter than the first preset time length, and the images of the plurality of second key frames are continuous; Based on the second key frame, a highlight segment in the key area is obtained.

3. The method for generating a video according to claim 1 or 2, characterized in that: Before extracting a plurality of first key frames from the video in a frame extraction manner at intervals of a first preset time length, the method further includes: Configure the number of frames and duration of the first key frame; The step of extracting a plurality of first key frames from the video in a frame extraction manner at intervals of a first preset time length comprises: The first key frames of the number of frames extracted are extracted from the video within the frame extraction time period in a frame extraction manner with an interval of a first preset time period.

4. The method for generating a video according to claim 3, characterized in that: The step of configuring the number of frames extracted and the duration of the frames extracted of the first key frame includes: Determine, based on the duration of the video, a first number of extracted frames and a second number of extracted frames for extracting a first key frame, wherein the second number of extracted frames is greater than the first number of extracted frames; Using a portion of the total duration of video analysis as the frame extraction duration; When it is determined that the frame extraction duration is sufficient to extract the first number of key frames from the video, and the extracted key frames do not exceed the second number of key frames, the number of frames extracted for the first key frames is configured to be the first number of frames, and the frame extraction duration is a partial duration of the total video analysis duration.

5. The method for generating a video according to claim 4, characterized in that: When the user selects the first video and the second video in the first interface, determining a first number of extracted frames and a second number of extracted frames for extracting the first key frame based on the duration of the video, wherein the second number of extracted frames is greater than the first number of extracted frames, includes: Determine a third number of extracted frames and a fourth number of extracted frames for extracting a first key frame of the first video based on the duration of the first video, and determine a fifth number of extracted frames and a sixth number of extracted frames for extracting a first key frame of the second video based on the duration of the second video, wherein the fourth number of extracted frames is greater than the third number of extracted frames, and the sixth number of extracted frames is greater than the fifth number of extracted frames; Determine the first frame number extracted from the first key frame as the sum of the third frame number and the fifth frame number, and determine the second frame number extracted from the first key frame as the sum of the fourth frame number and the sixth frame number.

6. The method for generating a video according to claim 5, characterized in that: The method further comprises: When it is determined that the frame extraction time is insufficient to extract the first number of key frames from the first video and the second video, configure the number of frames extracted from the first key frame to be the fifth number of frames extracted, and the frame extraction time is a partial time of the total video analysis time; The method of extracting the first key frames of the number of frames from the video within the frame extraction time interval by using the frame extraction method at intervals of the first preset time interval includes: extracting the first key frames of the fifth number of frames from the second video within the frame extraction time interval by using the frame extraction method at intervals of the first preset time interval; The method of obtaining the highlight segment of the video based on multiple first key frames includes: obtaining the highlight segment of the second video based on the first key frame of the fifth frame number extracted from the second video, and obtaining the highlight segment of the first video based on the first key frame in the historical frame extraction results of the first video.

7. The method for generating a video according to claim 6, characterized in that: After the number of frames extracted by configuring the first key frame is the fifth number of frames extracted, and the frame extraction duration is a portion of the total duration of the video analysis, the method further includes: When it is determined that the frame extraction time is insufficient to extract the fifth number of key frames from the second video, increase the frame extraction time to a first frame extraction time, wherein the first frame extraction time is sufficient to extract the fifth number of key frames from the second video; The frame extraction duration is configured as the first frame extraction duration.

8. The method for generating a video according to claim 6, characterized in that: After the number of frames extracted by configuring the first key frame is the fifth number of frames extracted, and the frame extraction duration is a portion of the total duration of the video analysis, the method further includes: When it is determined that the frame extraction time is not enough to extract the fifth number of key frames from the second video, the frame extraction time is configured to be the total video analysis time, and the total video analysis time is enough to extract the fifth number of key frames from the second video, or is not enough to extract the fifth number of key frames from the second video.

9. The method for generating a video according to claim 4, characterized in that: Also includes: When it is determined that the frame extraction time is sufficient to extract the first number of key frames from the video, and the extracted key frames exceed the second number of key frames, reducing the frame extraction time to a second frame extraction time, wherein the second frame extraction time is sufficient to extract the first number of key frames from the video, and the number of the extracted key frames is substantially the same as the second number of key frames; The number of frames extracted of the first key frame is configured to be the first number of frames extracted, and the frame extraction duration is configured to be the second frame extraction duration.

10. The method for generating a video according to claim 4, characterized in that: The step of determining a first number of extracted frames and a second number of extracted frames for extracting a first key frame based on the duration of the video, wherein the second number of extracted frames is greater than the first number of extracted frames, further comprising: When it is determined that the electronic device stores historical frame extraction results of the video and the video analysis algorithm capability of the electronic device has not been upgraded, the first frame extraction number is updated based on the seventh frame extraction number in the historical frame extraction results of the video, and the second frame extraction number is updated based on the eighth frame extraction number in the historical frame extraction results of the video; wherein the updated first frame extraction number is less than the first frame extraction number before the update, and the updated second frame extraction number is less than the second frame extraction number before the update.

11. The method for generating a video according to claim 10, characterized in that: The updating of the first number of frames based on the seventh number of frames extracted in the historical frame extraction results of the video, and the updating of the second number of frames based on the eighth number of frames extracted in the historical frame extraction results of the video, comprises: The product of the seventh number of extracted frames and a first weight is subtracted from the first number of extracted frames, and the product of the eighth number of extracted frames and a second weight is subtracted from the second number of extracted frames, and both the first weight and the second weight are less than 1.

12. An electronic device, characterized in that: include: one or more processors, memory, and display screens; The memory and the display screen are coupled to the one or more processors, the memory is used to store a computer program, the computer program includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the video generation method as described in any one of claims 1 to 11.

13. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed, is specifically used to implement the video generation method as described in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Identifying key frames using group sparsity analysis

    CN104508682A

  • Image processing method and device and electronic equipment

    CN111681170A

  • Multimedia resource detection method and device, terminal and storage medium

    CN114079804A

  • Video editing method, device and equipment, computer readable storage medium and product

    CN115278355A

  • Video processing method and device, equipment and storage medium

    CN115766977A