Video clip capture method, device and storage medium
By intercepting multiple candidate video clips from the video and using the machine learning model to score, the problem of video clip interception methods in the existing technology focusing on accuracy and ignoring information integrity is solved, achieving more accurate and complete video clip interception, and improving user experience.
Patent Information
- Application Number
- CN202110963211.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-20
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-08-20
AI Technical Summary
Existing video clip interception methods focus on accuracy and ignore information integrity, resulting in poor user experience.
By intercepting multiple candidate video clips from the video, using machine learning model scoring to determine the clip parameters corresponding to the maximum score value, the target video clip can be accurately intercepted.
The accuracy of the start and end moments of the target video clip is improved, making the intercepted video clip information more complete and improving the user experience.
Smart Images

Figure CN115708359B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing technology, and in particular to a method, device and storage medium for capturing video clips. Background Art
[0002] With the rapid development of network technology, a large number of videos have been generated, greatly enriching people's daily lives. However, due to time and other factors, users cannot watch the entire video, and people hope to quickly obtain the main content of the video by browsing some clips of the video (such as highlights) in a short time.
[0003] The video clips may be captured by capturing any one or more video clips in the video that meet the user's needs, for example, capturing wonderful video clips from the video.
[0004] However, in the related art, the video clip capture method usually focuses on the accuracy of the video clip capture content, that is, ensuring that the captured video clip contains the target video clip required by the user, but lacks attention to the information integrity of the video clip, resulting in a poor user experience. Summary of the invention
[0005] The present invention provides a method, device and storage medium for capturing video clips.
[0006] According to a first aspect of an embodiment of the present disclosure, a method for capturing a video clip is provided, comprising:
[0007] Extracting a plurality of candidate video segments from the video; wherein at least one of the starting time and the ending time of different candidate video segments is different;
[0008] Inputting the plurality of candidate video segments into a machine learning model to obtain a score value representing whether the interception of the plurality of candidate video segments meets the interception requirement;
[0009] Determine, according to the score values of the plurality of candidate video segments, a segment parameter of the candidate video segment corresponding to the maximum score value; wherein the segment parameter includes at least one of the start time, the end time and the segment length of the candidate video segment;
[0010] Based on the segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
[0011] Optionally, the candidate video segments include at least one of the following:
[0012] A first type of video clip, wherein the starting time of the first type of video clip is used to determine the starting time of the target video clip;
[0013] The second type of video clips, wherein the end time of the second type of video clips is used to determine the end time of the target video clip;
[0014] In the video, the playback time of the video frames included in the second-category video clips is later than the playback time of the video frames included in the first-category video clips.
[0015] Optionally, extracting a plurality of candidate video segments from the video includes:
[0016] Extracting an initial video segment from the video;
[0017] Determine a first candidate region from the video according to the starting time of the initial video segment, and extract a plurality of first-category video segments having different starting times from the first candidate region;
[0018] and / or,
[0019] According to the end time of the initial video segment, a second candidate area is determined from the video, and a plurality of second-category video segments with different end times are cut out from the second candidate area.
[0020] Optionally, determining a first candidate area from the first video according to a start time of the initial video segment includes:
[0021] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the first candidate region.
[0022] Optionally, determining a second candidate area from the first video according to the end time of the initial video segment includes:
[0023] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the second candidate region.
[0024] Optionally, inputting the multiple candidate video segments into a machine learning model to obtain a score value representing whether the interception of the multiple candidate video segments meets the interception requirement includes:
[0025] Extracting video features of the candidate video clips using a feature extraction module of a machine learning model;
[0026] The video features are input into a scoring module of the machine learning module to obtain a scoring value output by the scoring module that represents whether the interception of the multiple candidate video segments meets the interception requirements.
[0027] Optionally, the method further comprises:
[0028] Determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot;
[0029] When the video frames in the candidate video segment corresponding to the maximum score value come from different shots, the segment parameters of the candidate video segment are re-determined according to the critical video frames corresponding to the different shot switching times; the starting time of the re-determined candidate video segment corresponds to the critical video frame, or the ending time of the re-determined candidate video segment corresponds to the critical video frame;
[0030] The step of extracting a target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value includes:
[0031] Based on the adjusted segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
[0032] Optionally, before inputting the plurality of candidate video segments into the machine learning model, the method further comprises: obtaining a plurality of videos and annotation information of the plurality of videos; the annotation information at least comprises: annotated video segments in the videos and a start time and an end time of the annotated video segments;
[0033] Based on the annotation information of the multiple videos, preprocessing the multiple videos to obtain a training sample set of an initial model;
[0034] Inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements;
[0035] Determining a loss function value of the initial model based on the predicted score value of the video clip;
[0036] According to the loss function value of the initial model, the parameters to be trained of the initial model are adjusted to obtain a machine learning model.
[0037] Optionally, preprocessing the multiple videos based on the annotation information of the multiple videos to obtain a training sample set of an initial model includes:
[0038] According to the starting time of the labeled video segment, extracting a first type of labeled video segment from the video;
[0039] According to the end time of the labeled video segment, extracting the second type of labeled video segment from the video;
[0040] At least one third-category annotated video segment is randomly cut out from the video; wherein the playback time of the video frames included in the second-category annotated video segment is later than the playback time of the video frames included in the first-category annotated video segment; the third-category annotated video segment is a video segment in the video that does not overlap with the first-category annotated video segment and the second-category annotated video segment;
[0041] Select any one of the third-category labeled video segments from the plurality of the third-category labeled video segments, and combine it with the first-category labeled video segment and the second-category labeled video segment belonging to the same labeled video segment to obtain a video triplet of the labeled video segment;
[0042] Based on the video triplets of the plurality of labeled video clips, a training sample set of the initial model is obtained.
[0043] Optionally, the step of inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirement includes:
[0044] Using a feature extraction module in the initial model to extract video features of the first category of labeled video clips, video features of the second category of labeled video clips, and video features of the third category of labeled video clips;
[0045] The video features of the first category of labeled video clips, the video features of the second category of labeled video clips, and the video features of the third category of labeled video clips are respectively input into the scoring module of the initial model to obtain the predicted scoring values of the first category of labeled video clips, the predicted scoring values of the second category of labeled video clips, and the predicted scoring values of the third category of labeled video clips output by the scoring module.
[0046] Optionally, determining the loss function value of the initial model based on the predicted score value of the video clip includes:
[0047] Determining a first loss function value of the initial model based on a first prediction score value of the first category of labeled video segments, a first prediction score value of the second category of labeled video segments, and a first prediction score value of the third category of labeled video segments; wherein the first prediction score value is used to indicate the probability that a video segment contains a video frame at the start time of the labeled video segment;
[0048] Determining a second loss function value of the initial model based on the second predicted score value of the first category of labeled video segments, the second predicted score value of the second category of labeled video segments, and the second predicted score value of the third category of labeled video segments; wherein the second predicted score value is used to indicate the probability that the video segment contains the video frame at the end time of the labeled video segment;
[0049] The loss function value of the initial model is determined according to the first loss function value and the second loss function value.
[0050] Optionally, determining the first loss function value of the initial model based on the first predicted score value of the first category of labeled video segments, the first predicted score value of the second category of labeled video segments, and the first predicted score value of the third category of labeled video segments includes:
[0051] Determining a first ranking loss value between the first category of labeled video segments and the second category of labeled video segments based on a difference between a first predicted score value of the first category of labeled video segments and a first predicted score value of the second category of labeled video segments;
[0052] Determining a second ranking loss value between the first category of labeled video segments and the third category of labeled video segments based on a difference between the first prediction score value of the first category of labeled video segments and the first prediction score value of the third category of labeled video segments;
[0053] Determine a first loss function value of the initial model according to the sum of the first sorting loss value and the second sorting loss value.
[0054] Optionally, determining the second loss function value of the initial model based on the second predicted score value of the first category of labeled video clips, the second predicted score value of the second category of labeled video clips, and the second predicted score value of the third category of labeled video clips includes:
[0055] Determining a third ranking loss value between the second-category labeled video clip and the first-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the first-category labeled video clip;
[0056] Determining a fourth ranking loss value between the second-category labeled video clip and the third-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the third-category labeled video clip;
[0057] Determine a second loss function value of the initial model according to the sum of the third sorting loss value and the fourth sorting loss value.
[0058] According to a second aspect of an embodiment of the present disclosure, a device for capturing a video clip is provided, the device comprising:
[0059] A capture module, used to capture multiple candidate video segments from a video; wherein at least one of the starting time and the ending time of different candidate video segments is different;
[0060] A scoring module is used to input the multiple candidate video segments into a machine learning model to obtain a scoring value indicating whether the interception of the multiple candidate video segments meets the interception requirements; and determine the segment parameters of the candidate video segment corresponding to the maximum scoring value according to the scoring values of the multiple candidate video segments; wherein the segment parameters include at least one of the starting time, the ending time and the segment duration of the candidate video segment;
[0061] The capture module is further configured to capture a target video segment from the video based on segment parameters of the candidate video segment corresponding to the maximum score value.
[0062] According to a third aspect of an embodiment of the present disclosure, a device for capturing a video clip is provided, comprising:
[0063] processor;
[0064] a memory for storing processor-executable instructions;
[0065] Wherein, the processor is configured to: when executing the executable instructions, implement the steps in the method described in the first aspect of the embodiment of the present disclosure.
[0066] According to the fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When the instructions in the storage medium are executed by a processor of a video clip capture device, the video clip capture device is enabled to perform the steps in the method described in the first aspect of an embodiment of the present disclosure.
[0067] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0068] The video clip capture method provided by the embodiment of the present disclosure captures multiple candidate video clips with different starting moments and / or ending moments from a video, and scores the multiple candidate video clips using a machine learning model. The possibility that the video frames of the multiple candidate video clips contain the starting information / ending information of the target video clip is intuitively determined through the scoring values of the multiple candidate video clips. Thus, according to the scoring values of the multiple candidate video clips, a candidate video clip corresponding to the maximum scoring value is determined, and according to the clip parameters of the candidate video clip, the target video clip is captured from the video, thereby improving the accuracy of the starting moment and / or ending moment of the captured target video clip, making the information of the captured target video clip more complete, and improving the user experience.
[0069] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0071] Figure 1 The figure is a flow chart of a method for capturing video clips according to an embodiment of the present disclosure.
[0072] Figure 2 It is a flow chart of a training method for a machine learning model according to an embodiment of the present disclosure.
[0073] Figure 3 is a flowchart of a method for training a machine learning model according to this example.
[0074] Figure 4 A diagram of video clips from a training sample set provided for this example.
[0075] Figure 5 is a flowchart of a method for capturing video clips according to this example.
[0076] Figure 6 The figure is a schematic structural diagram of a device for capturing video clips according to an exemplary embodiment.
[0077] Figure 7 The figure is a block diagram of a device for capturing video clips according to an exemplary embodiment. DETAILED DESCRIPTION
[0078] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0079] The embodiment of the present disclosure provides a method for capturing a video clip. Figure 1 is a flow chart of a method for capturing video clips according to an embodiment of the present disclosure, such as Figure 1 As shown, the method comprises the following steps:
[0080] Step S101, extracting a plurality of candidate video segments from a video; wherein at least one of the starting time and the ending time of different candidate video segments is different;
[0081] Step S102, inputting the plurality of candidate video segments into a machine learning model to obtain a score indicating whether the cutouts of the plurality of candidate video segments meet the cutout requirements;
[0082] Step S103, determining the segment parameters of the candidate video segment corresponding to the maximum score value according to the score values of the multiple candidate video segments; wherein the segment parameters include at least one of the starting time, the ending time and the segment length of the candidate video segment;
[0083] Step S104: extracting a target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value.
[0084] The video clip capture method involved in the embodiment of the present disclosure can be applied to electronic devices; here, the electronic device includes devices such as terminals or servers, and the terminal can be a mobile phone, a tablet computer, a laptop computer, etc.; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers.
[0085] In step S101, the number of the candidate video segments may be determined according to the duration of the video; for videos of different durations, the number of candidate video segments captured from the video may be different.
[0086] In the embodiments of the present disclosure, multiple candidate video segments of preset lengths can be extracted from the video based on different starting moments or different ending moments; multiple candidate video segments of different lengths can also be extracted from the video based on the same starting moment or the same ending moment.
[0087] In some embodiments, a plurality of candidate video segments of preset duration may be captured from the video at equal time intervals according to preset time intervals. For example, candidate video segments of preset duration may be captured from the 0th second, the 2nd second, the 4th second, and so on of the video at intervals of 2 seconds until the video ends.
[0088] It should be noted that the video may be a video file that has been recorded or a video that is being recorded. The process of recording the video includes the process of acquiring a plurality of consecutive video frames, and the recorded video portion is composed of the above video frames.
[0089] In step S102, the captured multiple candidate video segments are respectively input into a pre-trained machine learning model, and the machine learning model can score the input candidate video segments according to the degree to which they meet the capture requirements.
[0090] Here, the interception requirement may be whether the video frame at the start time or the end time of the candidate video segment contains the start information or the end information of the target video segment. The target video segment may be set according to user needs. For example, if the target video segment is a basketball game video, the target video segment may be a slam dunk video segment, and the interception requirement may be whether the video frame at the start time of the candidate video segment contains the start information of the slam dunk operation (such as the take-off screen).
[0091] In step S103, the multiple candidate video segments are sorted according to the scoring values of the multiple candidate video segments output by the machine learning model, and the candidate video segment corresponding to the maximum scoring value is determined according to the sorting result; and the segment parameters of the candidate video segment are obtained.
[0092] It can be understood that, for different candidate video segments of the same video, the higher the score value output by the machine learning model, the higher the possibility or the higher the accuracy of the video frame at the start or end time of the candidate video segment containing the start information or end information of the target video segment.
[0093] Therefore, based on the scoring values of the multiple candidate video segments output by the machine learning model, the candidate video segment corresponding to the maximum scoring value can be determined; the video frame at the starting moment or the ending moment of the candidate video segment corresponding to the maximum scoring value has the highest possibility or higher accuracy of containing the starting information or the ending information of the target video segment.
[0094] According to the segment parameters of the candidate video segment corresponding to the maximum score value, segment parameters such as the start video frame and / or the end video frame of the target video segment can be determined.
[0095] In other embodiments, for the candidate video segment, the scoring value output by the machine learning model may include: a first scoring value and a second scoring value; wherein the first scoring value is used to represent the possibility that the video frame at the starting moment of the candidate video segment contains the starting information of the target video segment; and the second scoring value is used to represent the possibility that the video segment at the ending moment of the candidate video segment contains the ending information of the target video segment.
[0096] According to the first scoring values of the multiple candidate video segments output by the machine learning model, the multiple candidate video segments can be sorted, the candidate video segment corresponding to the maximum first scoring value can be determined, and the starting time of the candidate video segment corresponding to the maximum first scoring value can be obtained; according to the second scoring values of the multiple candidate video segments output by the machine learning model, the multiple candidate video segments can be sorted, the candidate video segment corresponding to the maximum second scoring value can be determined, and the ending time of the candidate video segment corresponding to the maximum second scoring value can be obtained.
[0097] In step S104, the segment parameters of the candidate video segment corresponding to the maximum score value are determined as the segment parameters of the target video segment, and the target video segment is cut out from the video based on the segment parameters.
[0098] In the disclosed embodiment, the target video segment may be extracted from the video according to the start time and / or end time of the candidate video segment corresponding to the maximum score value.
[0099] In some embodiments, the target video segment may be extracted from the video based on segment parameters of the candidate video segment corresponding to the maximum first score value and the candidate video segment corresponding to the maximum second score value.
[0100] The starting time of the candidate video segment corresponding to the maximum first scoring value can be determined as the starting time of the target video segment, and the ending time of the candidate video segment corresponding to the maximum second scoring value can be determined as the ending time of the target video segment, and the target video segment between the starting time and the ending time can be cut out from the video.
[0101] Optionally, the candidate video segments include at least one of the following:
[0102] A first type of video clip, wherein the starting time of the first type of video clip is used to determine the starting time of the target video clip;
[0103] The second type of video clips, wherein the end time of the second type of video clips is used to determine the end time of the target video clip;
[0104] In the video, the playback time of the video frames included in the second-category video clips is later than the playback time of the video frames included in the first-category video clips.
[0105] In the embodiment of the present disclosure, the first type of video segment may be a start candidate video segment including start information of the target video segment. The second type of video segment may be a stop candidate video segment including stop information of the target video segment.
[0106] It can be understood that, for the same target video segment, the first category of video segments can be the starting candidate video segment of the target video segment, and the second category of video segments can be the ending candidate video segment of the target video segment. Therefore, in the video, the playback time of the video frames contained in the first category of video segments is earlier than the playback time of the video frames contained in the second category of video segments.
[0107] The first category of video clips and / or the second category of videos are input into the machine learning model, and the first score value of the first category of video clips output by the machine learning model is higher than the second score value of the first category of video clips, and the second score value of the second category of video clips output by the machine learning model is higher than the first score value of the second category of video clips.
[0108] In the disclosed embodiment, the starting moments of different first-category video clips are different, and the ending moments of different second-category video clips are different. When intercepting video clips, multiple first-category video clips are intercepted from the video, and the multiple first-category video clips are input into a machine learning model to obtain first and second scoring values of the multiple first-category video clips output by the machine learning model; based on the first scoring value, the multiple first-category video clips are sorted, and according to the sorting result, the first-category video clip corresponding to the maximum first scoring value is determined; the starting moment of the first-category video clip corresponding to the maximum first scoring value is obtained, and the starting moment of the first-category video clip corresponding to the maximum first scoring value is the starting moment of the target video clip;
[0109] And / or, extract multiple second-category video clips from the video, input the multiple second-category video clips into a machine learning model, and obtain first scoring values and second scoring values of the multiple second-category video clips output by the machine learning model; sort the multiple second-category video clips based on the second scoring value, and determine the second-category video clip corresponding to the maximum second scoring value according to the sorting result; obtain the end time of the second-category video clip corresponding to the maximum second scoring value; the end time of the second-category video clip corresponding to the maximum second scoring value is the end time of the target video clip.
[0110] In some other embodiments of the present disclosure, the machine learning model includes: a first scoring module and a second scoring module arranged in parallel with the first scoring module;
[0111] The first scoring module is used to output a first scoring value indicating whether the first category of video clips meets the interception requirement according to the input first category of video clips;
[0112] The second scoring module is used to output a second scoring value indicating whether the second-category video segment meets the interception requirement based on the input second-category video segment.
[0113] By inputting the multiple first-category video clips into the first scoring module and the multiple second-category video clips into the second scoring module, a first scoring value output by the first scoring module representing whether the first-category video clips meet the interception requirements is obtained, and a second scoring value output by the second scoring module representing whether the second-category video clips meet the interception requirements is obtained; the starting time of the first-category video clip corresponding to the maximum first scoring value is determined as the starting time of the target video clip; and the ending time of the second-category video clip corresponding to the maximum second scoring value is determined as the ending time of the target video clip.
[0114] By setting up the first scoring module and the second scoring module in parallel, the first category of video clips and the second category of video clips are processed in parallel, thereby effectively improving the prediction efficiency of the machine learning module and shortening the prediction time.
[0115] In some other embodiments, the candidate video segments include: third category video segments;
[0116] The starting time of the third type of video segment is used to determine the starting time of the target video segment, and the ending time of the third type of video segment is used to determine the ending time of the target video segment.
[0117] In the embodiment of the present disclosure, the third type of video clips may be candidate video clips that include both the video frame at the start time of the target video clip and the video frame at the end time of the target video clip. At least one of the start time and the end time of different third type video clips is different.
[0118] A plurality of third-category video clips are cut out from the video, the plurality of third-category video clips are input into a machine learning model, scoring values of the third-category video clips are obtained, the plurality of third-category video clips are sorted based on the scoring values, and the third-category video clip corresponding to the maximum scoring value is determined according to the sorting result; the starting time and the ending time of the third-category video clip corresponding to the maximum scoring value are obtained; the starting time and the ending time of the third-category video clip corresponding to the maximum scoring value are the starting time and the ending time of the target video clip.
[0119] Optionally, extracting a plurality of candidate video segments from the video in step S101 includes:
[0120] Extracting an initial video segment from the video;
[0121] Determine a first candidate region from the video according to the starting time of the initial video segment, and extract a plurality of first-category video segments having different starting times from the first candidate region;
[0122] and / or,
[0123] According to the end time of the initial video segment, a second candidate area is determined from the video, and a plurality of second-category video segments with different end times are cut out from the second candidate area.
[0124] In the embodiment of the present disclosure, a video may be divided into a plurality of video segments, and the video frames included in the plurality of video segments may be analyzed respectively, and an initial video segment that meets the requirements may be determined according to the analysis results of the plurality of video segments.
[0125] It should be noted that a video capture algorithm can be used to capture one or more initial video segments that meet the requirements from the video. Here, the video capture algorithm can be determined according to actual needs and is not specifically limited in the embodiments of the present disclosure.
[0126] For example, if it is required to extract action clips contained in a video, a convolutional neural network can be used to perform action classification on the video frames contained in the multiple video clips, and the action clips contained in the video (i.e., the initial video clips) can be determined based on the action classification results of the multiple video clips.
[0127] For another example, if it is required to capture the wonderful clips in a video, features can be extracted from the multiple video clips, and the features of the multiple video clips are respectively input into a wonderful evaluation model to obtain wonderful score values of the multiple video clips. The multiple video clips are sorted based on their wonderful scores, and the video clip with the largest wonderful score is determined as the initial video clip.
[0128] It should be noted that the relevant video capture algorithms usually focus on improving the accuracy of video segment extraction, that is, ensuring that the extracted video segment contains the target video frame, but do not consider the accuracy of the start time and / or end time of the extracted video segment; this may result in the extracted video segment lacking start information and end information, or the extracted video segment containing too many irrelevant video frames before the start time or after the end time. Therefore, after the embodiment of the present disclosure extracts the initial video segment from the video, it is necessary to further determine whether the start information and end information of the initial video segment are complete.
[0129] By obtaining the starting time of the initial video segment, a first candidate region of a preset duration can be determined from the video based on the starting time of the initial video segment, and multiple first-category video segments can be intercepted from the first candidate region, wherein the starting times of the multiple first-category video segments are different.
[0130] By obtaining the end time of the initial video segment, a second candidate region of a preset duration can be determined from the video based on the end time of the initial video segment, and multiple second-category video segments can be intercepted from the first candidate region, wherein the end times of the multiple second-category video segments are different.
[0131] Here, the preset time length can be set according to actual needs. For example, the preset time length is 3 seconds.
[0132] The method of determining the first candidate region and the second candidate region can be set according to actual needs, for example, based on the time axis of the video, a video segment within a preset time range after the start time of the initial video segment is determined as the first candidate region. Alternatively, based on the time axis of the video, a video segment within a preset time range before the start time of the initial video segment is determined as the first candidate region.
[0133] It can be understood that the first candidate area is determined according to the starting time of the initial video clip, and the video frame at the starting time of the initial video clip is the video frame in the first candidate area. The second candidate area is determined according to the ending time of the initial video clip, and the video frame at the ending time of the initial video clip is the video frame in the second candidate area.
[0134] In the embodiment of the present disclosure, the number of first-category video segments intercepted from the first candidate area and the number of second-category video segments intercepted from the second candidate area can be preset. Here, the number of first-category video segments can be determined according to the duration corresponding to the first candidate area and the duration of the first-category video segments, and the number of second-category video segments can be determined according to the duration corresponding to the second candidate area and the duration of the second-category video segments.
[0135] For example, if the duration of the first candidate area and the second candidate area are both 20 seconds; the duration of the first category of video clips is 2 seconds; the duration of the second category of video clips is 4 seconds, in order to avoid omissions, the number of first category video clips captured from the first candidate area can be set to 10, and the number of second category video clips captured from the second candidate area can be set to 5.
[0136] In some embodiments of the present disclosure, multiple candidate video segments of preset length can be captured from the first candidate area based on a preset time interval; and / or multiple candidate video segments of preset length can be captured from the second candidate area based on a preset time interval.
[0137] Here, the preset duration and the preset time interval can be set according to actual needs, wherein the preset duration is shorter than the duration corresponding to the first candidate area / the second candidate area, and the preset time interval is shorter than the duration corresponding to the first candidate area / the second candidate area.
[0138] For example, the duration of the first candidate area is 3 seconds, the preset time interval is 0.1 second, and the duration of the first type of video clip is 1.5 seconds; 30 first type video clips can be extracted from the first candidate area from the 0th second, 0.1th second, 0.2th second, and so on.
[0139] In some embodiments of the present disclosure, the method further includes:
[0140] Determine a first candidate time according to the starting time of the initial video clip; the first candidate time is earlier than the starting time;
[0141] Determining a second candidate time according to the end time of the initial video clip; the second candidate time is later than the end time;
[0142] A plurality of video clips of the third category are extracted from a third candidate area formed by the first candidate moment and the second candidate moment.
[0143] Taking into account that the target video segment captured by the relevant video capture method lacks starting information and / or ending information, the embodiment of the present disclosure, after capturing the initial video segment from the video, determines a third candidate area from the video based on the starting time and ending time of the initial video segment, the video duration of the third candidate area being greater than the segment duration of the initial video segment, and captures multiple third-category video segments from the third candidate area.
[0144] It can be understood that the third candidate area is determined based on the start time and the end time of the initial video segment, and all video frames of the initial video segment are video frames within the third candidate area.
[0145] The duration between the first candidate moment and the start moment, and the duration between the second candidate moment and the end moment can be set according to actual needs. For example, if the start moment is the 5th second of the video, the first candidate moment can be determined as the 4th second of the video.
[0146] For example, an initial video clip can be obtained through an existing video capture method, and based on the start time and end time of the initial video clip, a video clip from 1.5 seconds before the start time to 1.5 seconds after the end time is determined as the third candidate area; and multiple third-category video clips are obtained from the third candidate area at preset time intervals.
[0147] Optionally, determining a first candidate area from the first video according to a start time of the initial video segment includes:
[0148] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the first candidate region.
[0149] In the embodiment of the present disclosure, the preset duration can be set according to actual needs and is not specifically limited here.
[0150] Since the target video segment obtained by the existing video capture method may lack the video frame containing the start information / end information, or contain too many irrelevant video frames before the start information / after the end information, the video frame containing the start information of the target video segment may be a video frame before the start time of the initial video segment, or may be a video frame after the start time of the initial video segment.
[0151] In order to ensure the accuracy of interception, the initial video clip is firstly intercepted from the video by the existing video interception method, the starting moment of the initial video clip is taken as the center moment of the first candidate area, and based on the center moment, a video area of a preset length is intercepted from the video as the first candidate area, so that the multiple first-category video clips intercepted from the first candidate area can be video clips before the starting moment of the initial video clip, or can also be video clips after the starting moment of the initial video clip; and the situation in which the starting moment of the intercepted target video clip is inaccurate due to the fact that the first candidate area corresponding to the multiple first-category video clips does not contain the video frame with the starting moment of the target video clip is reduced.
[0152] Optionally, determining a second candidate area from the first video according to the end time of the initial video segment includes:
[0153] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the second candidate region.
[0154] In the embodiment of the present disclosure, the preset duration can be set according to actual needs and is not specifically limited here.
[0155] Since the target video segment obtained by the existing video capture method may lack the video frame containing the start information / end information, or contain too many irrelevant video frames before the start information / after the end information, the video frame containing the end information of the target video segment may be the video frame before the end time of the initial video segment, or may be the video frame after the end time of the initial video segment.
[0156] In order to ensure the accuracy of the capture, the initial video clip is first captured from the video by the existing video capture method, the end time of the initial video clip is used as the center time of the second candidate area, and based on the center time, a video area of a preset length is captured from the video as the second candidate area, so that the multiple second-category video clips captured from the second candidate area can be video clips before the end time of the initial video clip, or can also be video clips after the end time of the initial video clip, thereby reducing the situation where the end time of the captured target video clip is inaccurate due to the second candidate areas corresponding to the multiple second-category video clips being video frames containing the end information of the target video clip.
[0157] Optionally, in step S102, the plurality of candidate video segments are input into a machine learning model to obtain a score value representing whether the interception of the plurality of candidate video segments meets the interception requirement, including:
[0158] Extracting video features of the candidate video clips using a feature extraction module of a machine learning model;
[0159] The video features are input into a scoring module of the machine learning module to obtain a scoring value output by the scoring module that represents whether the interception of the multiple candidate video segments meets the interception requirements.
[0160] In the embodiment of the present disclosure, the feature extraction module performs feature extraction processing on the candidate video segment to obtain video features representing the content of the candidate video segment. Here, the video features may be in vector form.
[0161] It should be noted that in the embodiments of the present disclosure, a feature extraction module in an existing video understanding network may be used to extract features from candidate video clips; for example, the feature extraction module may be a feature extraction layer in a machine learning model based on a finite state machine, or the feature extraction module may be a feature extraction layer in a three-dimensional convolutional neural network model, etc.
[0162] In some embodiments, a feature extraction module may be used to extract features from each video frame included in the candidate video segment to obtain image features of each video frame; and the image features of multiple video frames included in the candidate video segment may be fused into the video features of the candidate video segment.
[0163] Here, feature extraction is performed on each video frame in the candidate video segment to obtain image features of each video frame, and the image features corresponding to all video frames in the candidate video segment are fused into video features representing the content of the candidate video segment. The method for fusion to obtain the video features is not limited, and may be, for example, splicing, summing, or weighted summing.
[0164] After the feature extraction module extracts the video features of the candidate video segments from the candidate video segments, the video features of the candidate video segments are input into the scoring module, and the candidate video segments are scored by the scoring module to obtain the scoring value of each candidate video segment.
[0165] In the disclosed embodiment, the scoring module may score the candidate video segment according to the possibility that the video frame at the start time / end time of the candidate video segment contains the start information / end information of the target video segment. For multiple candidate video segments of the same target video segment, the higher the score value of the candidate video segment given by the scoring module, the higher the possibility that the video frame at the start time / end time of the candidate video segment contains the start information / end information of the target video segment. The relative size of the score values between the candidate video segments can represent the difference in the possibility that the video frames of the candidate video segments contain the start information / end information.
[0166] The candidate video segments can be sorted according to the obtained scoring values of each candidate video segment, so as to determine the candidate video segment corresponding to the maximum scoring value, and the starting time / ending time of the candidate video segment corresponding to the maximum scoring value is determined as the starting time / ending time of the target video segment; the scoring value can be used to intuitively distinguish the possibility that the video frames of each candidate video segment contain the starting information / ending information of the target video segment, which helps to quickly and accurately extract the complete target video segment required by the user.
[0167] In some embodiments of the present disclosure, the scoring value output by the scoring module includes: a first scoring value and a second scoring value; wherein the first scoring value is used to characterize the possibility that the video frame at the starting moment of the candidate video segment contains the starting information of the target video segment; and the second scoring value is used to characterize the possibility that the video segment at the ending moment of the candidate video segment contains the ending information of the target video segment.
[0168] According to the first scoring values of the multiple candidate video segments output by the machine learning model, the multiple candidate video segments can be sorted, the candidate video segment corresponding to the maximum first scoring value can be determined, and the starting time of the candidate video segment corresponding to the maximum first scoring value can be obtained; according to the second scoring values of the multiple candidate video segments output by the machine learning model, the multiple candidate video segments can be sorted, the candidate video segment corresponding to the maximum second scoring value can be determined, and the ending time of the candidate video segment corresponding to the maximum second scoring value can be obtained.
[0169] Optionally, the method further comprises:
[0170] Determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot;
[0171] When the video frames in the candidate video segment corresponding to the maximum score value come from different shots, the segment parameters of the candidate video segment are re-determined according to the critical video frames corresponding to the different shot switching times; the starting time of the re-determined candidate video segment corresponds to the critical video frame, or the ending time of the re-determined candidate video segment corresponds to the critical video frame;
[0172] The step of extracting a target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value includes:
[0173] Based on the adjusted segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
[0174] In the disclosed embodiment, it is possible to determine whether there is a shot boundary in the candidate video segment corresponding to the maximum score value by determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot.
[0175] Determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot may include:
[0176] Obtaining the sum of brightness of pixels in each video frame in the candidate video segment corresponding to the maximum score value;
[0177] Obtaining the difference in brightness between any two adjacent video frames in the candidate video segment;
[0178] According to the comparison result of the difference between the brightness sum of any two adjacent video frames and a preset threshold, it is determined whether the any two adjacent video frames are from the same shot.
[0179] In the embodiment of the present disclosure, if the difference in the sum of brightness between adjacent video frames is greater than a preset threshold, it is determined that the two adjacent video frames are from different shots.
[0180] It should be noted that other methods may be used to determine whether all the video frames in the candidate video segment come from the same shot. For example, color histogram or perceptual hashing methods may be used to determine whether all the video frames in the candidate video segment come from the same shot. The embodiments of the present disclosure do not limit this.
[0181] If all video frames in the candidate video segment corresponding to the maximum score value are from the same shot, the candidate video segment corresponding to the maximum score value does not contain too many other video frames before the start information or after the end information of the target video segment.
[0182] If all video frames of the candidate video segment corresponding to the maximum score value come from different shots, that is, the candidate video segment corresponding to the maximum score value contains too many other video frames before the start information or after the end information of the target video segment; the start time / end time of the candidate video segment can be adjusted so that the adjusted start time / end time of the candidate video segment is the critical video frame corresponding to the different shot switching times; thereby removing other video frames before the start information or after the end information of the target video segment in the candidate video segment.
[0183] Optionally, Figure 2 is a flow chart of a training method for a machine learning model according to an embodiment of the present disclosure, such as Figure 2 As shown, before inputting the plurality of candidate video segments into the machine learning model, the method further includes:
[0184] Step S201, obtaining a plurality of videos and annotation information of the plurality of videos; the annotation information at least includes: annotated video segments in the videos and the start time and the end time of the annotated video segments;
[0185] Step S202, preprocessing the multiple videos based on the annotation information of the multiple videos to obtain a training sample set of an initial model;
[0186] Step S203, inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements;
[0187] Step S204, determining a loss function value of the initial model based on the predicted score value of the video clip;
[0188] Step S205: According to the loss function value of the initial model, the parameters to be trained of the initial model are adjusted to obtain a machine learning model.
[0189] In the disclosed embodiment, in order to improve the accuracy of the machine learning model in scoring the candidate video clips, the machine learning model may be subjected to supervised learning, i.e., training, before the machine learning model is actually called.
[0190] The embodiment of the present disclosure may pre-process the multiple videos according to the acquired multiple videos and the annotation information of the multiple videos;
[0191] Here, the preprocessing may be to intercept the multiple videos according to the annotation information of the multiple videos to obtain multiple video clips and the annotation information of the multiple video clips; based on the multiple video clips and the annotation information of the multiple video clips, obtain a training sample set, so that the machine learning module can have sufficient training data for training.
[0192] During the training process of the initial model, the annotated video clips and the starting time and ending time of the annotated video clips are obtained according to the annotation information of the multiple video clips; a first video frame corresponding to the starting time and a second video frame corresponding to the ending time are obtained; the video clips in the training sample set are input into the initial network, and video features indicating the content of the video clip, video features indicating the content of the first video frame, and video features indicating the content of the second video frame are obtained; and a predicted score value of the video clip is determined according to feature differences between the video features corresponding to the video clip and the video features corresponding to the first video frame, and feature differences between the video features corresponding to the video clip and the video features corresponding to the second video frame.
[0193] In the embodiment of the present disclosure, a machine learning model can be obtained by judging whether the loss function value of the initial model satisfies the condition for stopping training. If the loss function value of the initial model does not meet the condition for stopping training, the parameters to be trained in the initial model are continuously optimized until the loss function value of the initial model meets the condition for stopping training.
[0194] Here, the training stop condition may be that the training reaches the number of iterations and / or the loss function of the initial model converges. The number of iterations may be determined according to the number of videos in the training sample set of the initial model and the size of the initial model, which is not specifically limited in the present disclosure.
[0195] Optionally, the step S202 of preprocessing the multiple videos based on the annotation information of the multiple videos to obtain a training sample set of an initial model includes:
[0196] According to the starting time of the labeled video segment, extracting a first type of labeled video segment from the video;
[0197] According to the end time of the labeled video segment, extracting the second type of labeled video segment from the video;
[0198] At least one third-category annotated video segment is randomly cut out from the video; wherein the playback time of the video frames included in the second-category annotated video segment is later than the playback time of the video frames included in the first-category annotated video segment; the third-category annotated video segment is a video segment in the video that does not overlap with the first-category annotated video segment and the second-category annotated video segment;
[0199] Select any one of the third-category labeled video segments from the plurality of the third-category labeled video segments, and combine it with the first-category labeled video segment and the second-category labeled video segment belonging to the same labeled video segment to obtain a video triplet of the labeled video segment;
[0200] Based on the video triplets of the plurality of labeled video clips, a training sample set of the initial model is obtained.
[0201] In the disclosed embodiment, the first category of annotated video clips may be starting video clips containing starting information of the annotated video clips; the second category of annotated video clips may be ending video clips containing ending information of the annotated video clips; the third category of annotated video clips may be non-annotated video clips in the video, or may be clips of the annotated video clips containing video frames at non-starting moments and video frames at non-ending moments; the third category of annotated video clips does not overlap with the first category of annotated video clips and the second category of annotated video clips.
[0202] It can be understood that since the third category of labeled video clips are non-overlapping clips with the first category of labeled video clips and the second category of labeled video clips, the content of the video frames of the third category of labeled video clips is different from the content of the video clips of the first category of labeled video clips and the content of the second category of labeled video clips; during the training process of the model, the initial model can distinguish different video clips based on the feature differences between the third category of labeled video clips and the first category of labeled video clips and the second category of labeled video clips.
[0203] In some embodiments, based on the annotation information of the video, the annotated video segment in the video and the starting time and ending time of the annotated video segment are determined; the starting time of the annotated video segment can be used as the central time, and a video segment of a preset length can be cut out from the video as a first type of annotated video segment (i.e., the starting video segment of the annotated video segment); the ending time of the annotated video segment can be used as the central time, and a video segment of a preset length can be cut out from the video as a second type of annotated video segment (i.e., the ending video segment of the annotated video segment).
[0204] In some other embodiments of the present disclosure, it is determined whether all video frames in the first-category labeled video segments are from the same shot; when the video frames in the first-category labeled video segments are from different shots, the starting time of the first-category labeled video segments is re-determined according to the critical video frames corresponding to the different shot switching times; wherein the re-determined starting time of the first-category labeled video segments corresponds to the critical video frame;
[0205] And / or, determine whether all the video frames in the second category of annotated video clips are from the same shot; when the video frames in the second category of annotated video clips are from different shots, redetermine the end time of the second category of annotated video clips according to the critical video frames corresponding to the different shot switching times; wherein the redetermined end time of the second category of annotated video clips corresponds to the critical video frame.
[0206] It can be understood that the embodiment of the present disclosure performs shot boundary detection on the first category of labeled video clips and the second category of labeled video clips obtained through preprocessing, reduces the number of video frames that contain too many start information or end information in the first category of labeled video clips and / or the second category of labeled video clips, improves the accuracy of the training sample set of the machine learning model, and thus ensures the accuracy of the machine learning model trained based on the training sample set.
[0207] In order to improve the accuracy of the machine learning model scoring, in the embodiment of the present disclosure, the first category of labeled video clips and the second category of labeled video clips corresponding to the same labeled video clip in the video can be obtained, and any one of the third category of labeled video clips is selected from the multiple third category of labeled video clips of the video, and the first category of labeled video clips, the second category of labeled video clips and the third category of labeled video clips are combined to form a video triplet of the labeled video clip; for example, the video triplet can be [first category labeled video clip, second category labeled video clip, third category labeled video clip].
[0208] It should be noted that, in order to facilitate the initial model to better distinguish the feature differences between the video features of different video clips in the same video and the first video features and / or the second video features of the identified video clips, the first category of labeled video clips and the second category of labeled video clips may be positive sample clips from the same labeled video clip in the same video, and the third category of labeled video clips may be negative sample clips in the same video; the initial model is trained using the positive sample clips and the negative sample clips, and the relative score value differences between the video clips are obtained based on the feature differences between the video features of different video clips and the first video features and / or the second video features of the identified video clip, which helps the initial model to distinguish different video clips.
[0209] Optionally, in step S203, the video clips in the training sample set are input into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements, including:
[0210] Using a feature extraction module in the initial model to extract video features of the first category of labeled video clips, video features of the second category of labeled video clips, and video features of the third category of labeled video clips;
[0211] The video features of the first category of labeled video clips, the video features of the second category of labeled video clips, and the video features of the third category of labeled video clips are respectively input into the scoring module of the initial model to obtain the predicted scoring values of the first category of labeled video clips, the predicted scoring values of the second category of labeled video clips, and the predicted scoring values of the third category of labeled video clips output by the scoring module.
[0212] In an embodiment of the present disclosure, the feature extraction module can extract video features for characterizing the content of the video clip from the video clip; the present disclosure does not limit the network structure of the feature extraction module; for example, the feature extraction module can be a feature extraction layer in a machine learning model based on a finite state machine, or the feature extraction module can be a feature extraction layer in a three-dimensional convolutional neural network model, etc.
[0213] The scoring module may determine the probability that the candidate video segment contains a video frame identifying a start time and / or an end time of the video segment based on the video features of the candidate video segment, and score the candidate video segment based on the probability.
[0214] Here, the scoring module may be a multi-layer perceptron neural network model. The number of hidden layers of the multi-layer perceptron may be set to 2 to 4. For example, if the dimension of the video feature of the video clip is N, the input dimension of the first fully connected layer of the multi-layer perceptron neural network model is N, and the output dimension of the last fully connected layer is 2.
[0215] Optionally, determining the loss function value of the initial model based on the predicted score value of the video clip in step S204 includes:
[0216] Determining a first loss function value of the initial model based on a first prediction score value of the first category of labeled video segments, a first prediction score value of the second category of labeled video segments, and a first prediction score value of the third category of labeled video segments; wherein the first prediction score value is used to indicate the probability that a video segment contains a video frame at the start time of the labeled video segment;
[0217] Determining a second loss function value of the initial model based on the second predicted score value of the first category of labeled video segments, the second predicted score value of the second category of labeled video segments, and the second predicted score value of the third category of labeled video segments; wherein the second predicted score value is used to indicate the probability that the video segment contains the video frame at the end time of the labeled video segment;
[0218] The loss function value of the initial model is determined according to the first loss function value and the second loss function value.
[0219] In the disclosed embodiment, the first loss function value may be the relative score value difference between the first predicted score value of the first category of annotated video clips and the first predicted score value of the second category of annotated video clips, and the first predicted score value of the third category of annotated video clips; that is, the feature difference between the video features of the first category of annotated video clips and the video features of the second category of annotated video clips, and the video features of the third category of annotated video clips.
[0220] The second loss function value may be the relative score value difference between the second predicted score value of the second category of annotated video clips and the second predicted score value of the first category of annotated video clips, and the second predicted score value of the third category of annotated video clips, that is, the feature difference between the video features of the second category of annotated video clips and the video features of the first category of annotated video clips, and the video features of the third category of annotated video clips.
[0221] The loss function value of the initial model may be determined based on the sum of the first loss function value and the second loss function value.
[0222] Optionally, determining the first loss function value of the initial model based on the first predicted score value of the first category of labeled video segments, the first predicted score value of the second category of labeled video segments, and the first predicted score value of the third category of labeled video segments includes:
[0223] Determining a first ranking loss value between the first category of labeled video segments and the second category of labeled video segments based on a difference between a first predicted score value of the first category of labeled video segments and a first predicted score value of the second category of labeled video segments;
[0224] Determining a second ranking loss value between the first category of labeled video segments and the third category of labeled video segments based on a difference between the first prediction score value of the first category of labeled video segments and the first prediction score value of the third category of labeled video segments;
[0225] Determine a first loss function value of the initial model according to the sum of the first sorting loss value and the second sorting loss value.
[0226] It can be understood that since the first loss function value is used to characterize the feature differences between the video features of the first category of labeled video clips (i.e., the clips containing the video frames corresponding to the starting time of the labeled video clips) and the video features of the second category of labeled video clips and the video features of the third category of labeled video clips; therefore, in the process of determining the first loss function value, the first category of labeled video clips are positive sample clips; the second category of labeled video clips and the third category of labeled video clips are negative sample clips; and the first loss function value of the initial model is obtained by determining the ranking loss between the positive sample clips and the negative sample clips.
[0227] Since the first category of labeled video clips, the second category of labeled video clips and the third category of labeled video clips are non-overlapping video clips in the video; by respectively determining the first ranking loss value between the first category of labeled video clips and the second category of labeled video clips, and the second ranking loss value between the first category of labeled video clips and the third category of labeled video clips, the differences between the first category of labeled video clips and the second category of labeled video clips and the third category of labeled video clips are determined, and based on the first loss function value obtained by the first ranking loss value and the second ranking loss value, the parameters to be trained of the initial model are optimized, so that the trained machine learning model can accurately distinguish the starting video clip of the target video clip from multiple candidate video clips.
[0228] Optionally, determining the second loss function value of the initial model based on the second predicted score value of the first category of labeled video clips, the second predicted score value of the second category of labeled video clips, and the second predicted score value of the third category of labeled video clips includes:
[0229] Determining a third ranking loss value between the second-category labeled video clip and the first-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the first-category labeled video clip;
[0230] Determining a fourth ranking loss value between the second-category labeled video clip and the third-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the third-category labeled video clip;
[0231] Determine a second loss function value of the initial model according to the sum of the third sorting loss value and the fourth sorting loss value.
[0232] It can be understood that since the second loss function value is used to characterize the feature differences between the video features of the second category of labeled video clips (i.e., the clips containing the video frames corresponding to the end time of the labeled video clips) and the video features of the first category of labeled video clips and the video features of the third category of labeled video clips; therefore, in the process of determining the second loss function value, the second category of labeled video clips are positive sample clips; the first category of labeled video clips and the third category of labeled video clips are negative sample clips; and the second loss function value of the initial model is obtained by determining the sorting loss between the positive sample clips and the negative sample clips.
[0233] Since the first category of labeled video clips, the second category of labeled video clips and the third category of labeled video clips are non-overlapping video clips in the video; by respectively determining the third ranking loss value between the second category of labeled video clips and the first category of labeled video clips, and the fourth ranking loss value between the second category of labeled video clips and the third category of labeled video clips, the differences between the first category of labeled video clips and the second category of labeled video clips and the third category of labeled video clips are determined, and based on the second loss function value obtained by the third ranking loss value and the fourth ranking loss value, the parameters to be trained of the initial model are optimized, so that the trained machine learning model can accurately distinguish the terminal video clip of the target video clip from multiple candidate video clips.
[0234] The present disclosure also provides the following embodiments:
[0235] Figure 3 is a flowchart of a training method for a machine learning model according to this example, such as Figure 3 As shown, the method includes:
[0236] Step S301, obtaining a plurality of videos and annotation information of the plurality of videos; the annotation information at least includes: annotated video segments in the videos and the start time and the end time of the annotated video segments;
[0237] In this example, a certain number of videos can be collected and the target video segments in the videos can be marked; for example, if the video segments to be extracted from the video are action video segments, all the action video segments in the video can be marked, and the start and end times of the action video segments can be marked. If the video segments to be extracted from the video are highlights, the highlights in the video can be marked, and the start and end times of the highlights can be marked.
[0238] It is understandable that in order to ensure the accuracy of the machine learning model, when annotating the training data of the machine learning model, it is necessary to ensure the accuracy of the start and end times of the annotated video clips.
[0239] Step S302: extracting a first type of annotated video segment from the video according to the start time of the annotated video segment; extracting a second type of annotated video segment from the video according to the end time of the annotated video segment; and arbitrarily extracting a plurality of third type of annotated video segments from the video;
[0240] Here, the playback time of the video frames included in the first category of labeled video clips is later than the playback time of the video frames included in the first category of labeled video clips; the third category of labeled video clips are: video clips in the video that do not overlap with the first category of labeled video clips and the second category of labeled video clips.
[0241] In this example, the first type of labeled video segments may be start video segments, and the second type of labeled video segments may be end video segments.
[0242] The starting time and ending time of the annotated video segment in the video can be obtained, and a video segment with a length equal to a preset duration can be cut from the video with the starting time as the center time as the starting video segment of the annotated video segment; and a video segment with a length equal to the preset duration can be cut from the video with the ending time as the center time as the ending video segment of the annotated video segment.
[0243] For example, based on the start and end times of each annotated video segment in each video, a 1.5-second video segment can be captured from the video with the start time as the center time as the start video segment of the annotated video segment; and a 1.5-second video segment can be captured from the video with the end time as the center time as the end video segment of the annotated video segment.
[0244] In this example, the third type of annotated video segments may be other video segments that are unrelated to the starting video segment and the ending video segment. Multiple video segments that have no intersection with the starting segment and the ending segment may be randomly intercepted from the video as other video segments.
[0245] Step S303, selecting any one of the third-category annotated video segments from the plurality of the third-category annotated video segments, and combining it with the first-category annotated video segments and the second-category annotated video segments belonging to the same annotated video segment, to obtain a video triplet of the annotated video segment; and obtaining a training sample set based on the video triplet of the plurality of the annotated video segments;
[0246] In this example, all the starting video segments, ending video segments and other video segments in the same video are arranged and combined to obtain a series of video triplets of [starting video segment, ending video segment, other video segments], and the set of video triplets of all training videos is used as the training sample set of the machine learning model.
[0247] For example, Figure 4 As shown, Figure 4A schematic diagram of a video clip in a training sample set provided for this example. Reference numeral 41 indicates the timeline of the video; reference numeral 42 indicates the annotated video clip in the video; reference numeral 42a indicates the starting moment of the annotated video clip; reference numeral 42b indicates the starting video clip of the annotated video clip; wherein the starting video clip is: a 1.5-second video clip cut with the starting moment as the center moment. Reference numeral 42c indicates the ending moment of the annotated video clip; reference numeral 42d indicates the ending video clip of the annotated video clip; wherein the ending video clip is: a 1.5-second video clip cut with the ending moment as the center moment. Reference numerals 43a, 43b, and 43c are respectively other video clips 1, other video clips 2, and other video clips 3 in the video that have no intersection with the starting video clip and the ending video clip.
[0248] Then, based on the starting video segment, the ending video segment and other video segments of the video, the obtained video triplet set can be arranged and combined as {[starting video segment, ending video segment, other video segment 1], [starting video segment, ending video segment, other video segment 2], [starting video segment, ending video segment, other video segment 2]}.
[0249] Step S304, inputting the video clips in the training sample set into the initial model, and using the feature extraction module in the initial model to extract the video features of the first category of labeled video clips, the video features of the second category of labeled video clips, and the video features of the third category of labeled video clips;
[0250] In this example, the video feature vectors of each video clip are extracted by a feature extraction module; here, the feature extraction module may be a feature extraction layer of a video understanding model in the related technology, for example, a feature extraction layer in a general video understanding network such as C3D, I3D and TSN.
[0251] Step S305, inputting the video features of the first category of annotated video clips, the video features of the second category of annotated video clips, and the video features of the third category of annotated video clips into the scoring module of the initial model respectively, and obtaining the first predicted scoring value and the second predicted scoring value of the first category of annotated video clips, the first predicted scoring value and the second predicted scoring value of the second category of annotated video clips, and the first predicted scoring value and the second predicted scoring value of the third category of annotated video clips output by the scoring module;
[0252] In this example, the input of the scoring module is a feature vector of the video clip, and the output is a first predicted scoring value and a second predicted scoring value of the video clip; here, the first predicted scoring value may be a predicted starting scoring value indicating whether the starting information of the video clip meets the interception requirements; the second predicted scoring value may be a predicted ending scoring value indicating whether the ending information of the video clip meets the interception requirements.
[0253] The initial model may be a multi-layer perceptron neural network model, and the scoring module may be a hidden layer in the multi-layer perceptron neural network model; here, the number of hidden layers may be 2-4; assuming that the dimension of the video feature vector input to the scoring module is N, the input dimension of the first fully connected layer in the multi-layer perceptron neural network model is N, and the output dimension of the last fully connected layer is 2.
[0254] By using the feature extraction module to extract video features from the three video clips of the video triplet [starting video clip, ending video clip and other video clips] in the training sample set, and inputting the video features of the three video clips into the scoring module respectively, the predicted starting score values and predicted ending score values of the three video clips are obtained.
[0255] Step S306, determining a first loss function value of the initial model based on the first predicted score value of the first category of labeled video clips, the first predicted score value of the second category of labeled video clips, and the first predicted score value of the third category of labeled video clips; determining a second loss function value of the initial model based on the second predicted score value of the first category of labeled video clips, the second predicted score value of the second category of labeled video clips, and the second predicted score value of the third category of labeled video clips; determining a loss function value of the initial model according to the first loss function value and the second loss function value;
[0256] In this example, the first loss function value may be a starting loss function value of the initial model, and the second loss function value may be a termination loss function value of the initial model.
[0257] The loss function of the initial model can be:
[0258] Loss=Loss begin +Loss end ;
[0259] Wherein, the Loss is the loss function value of the initial model, and the Loss begin is the initial loss function value of the initial model, the Loss end is the termination loss function value of the initial model.
[0260] In some embodiments, determining the first loss function value of the initial model includes:
[0261] Determining a first ranking loss value between the first category of labeled video segments and the second category of labeled video segments based on a difference between a first predicted score value of the first category of labeled video segments and a first predicted score value of the second category of labeled video segments;
[0262] Determining a second ranking loss value between the first category of labeled video segments and the third category of labeled video segments based on a difference between the first prediction score value of the first category of labeled video segments and the first prediction score value of the third category of labeled video segments;
[0263] Determine a first loss function value of the initial model according to the sum of the first sorting loss value and the second sorting loss value.
[0264] It can be understood that the first loss function value of the initial model (i.e., the starting loss function value) is calculated by the ranking loss values of the predicted starting score values of the starting video segment and the ending video segment, and the ranking loss values of the predicted starting score values of the starting video segment and other video segments.
[0265] Specifically, the first loss function value of the initial model may be:
[0266] Loss begin =loss begin (Video begin ,Video end )+loss begin (Video begin ,Video other );
[0267] Among them, the Loss begin is the first loss function value, the loss begin is the ranking loss value of the predicted starting score value between video clips; the Video begin is the starting video segment; the Video end To terminate a video segment, the Video other For other video clips.
[0268] The ranking loss value of the predicted starting score value may be:
[0269] loss begin (Video1, Video2) = max(0, 1-CNN begin (Video1)+CNN begin (Video2));
[0270] Among them, the CNN begin The predicted starting score value of the video clip output by the scoring model.
[0271] In some other embodiments, determining the second loss function value of the initial model includes:
[0272] Determining a third ranking loss value between the second-category labeled video clip and the first-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the first-category labeled video clip;
[0273] Determining a fourth ranking loss value between the second-category labeled video clip and the third-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the third-category labeled video clip;
[0274] Determine a second loss function value of the initial model according to the sum of the third sorting loss value and the fourth sorting loss value.
[0275] It can be understood that the second loss function value of the initial model (i.e., the termination loss function value) is calculated by the ranking loss values of the predicted termination score values of the termination video segment and the starting video segment, and the ranking loss values of the predicted termination score values of the termination video segment and other video segments.
[0276] Specifically, the second loss function value of the initial model may be:
[0277] Loss end =loss end (Video end ,Video begin )+loss end (Video end ,Video other );
[0278] Among them, the Loss end is the second loss function value, the loss end Ranking loss for the predicted termination scores between video clips.
[0279] The ranking loss value of the prediction termination score value may be:
[0280] loss end (Video1, Video2) = max(0, 1-CNN end (Video1)+CNN end (Video2));
[0281] Among them, the CNN end The predicted final score value of the video clip output by the scoring model.
[0282] Step S307, adjusting the parameters to be trained of the initial model according to the loss function value of the initial model to obtain a machine learning model;
[0283] In this example, the machine learning model can be obtained by judging whether the loss function value of the initial model meets the conditions for stopping training. If the loss function value does not meet the conditions for stopping training, the parameters to be trained of the initial model continue to be optimized until the loss function value of the initial model meets the conditions for stopping training.
[0284] Here, the training stop condition may be that the training reaches the number of iterations and / or the loss function converges. The number of iterations may be determined according to the number of video clips in the training sample set.
[0285] Figure 5 is a flow chart of a method for capturing video clips according to this example. Figure 5 As shown, the method includes:
[0286] Step S401, extracting an initial video segment from a video; extracting a plurality of candidate video segments from the video according to the starting time and / or ending time of the initial video segment; wherein at least one of the starting time and the ending time of different candidate video segments is different;
[0287] In this example, according to the starting time of the initial video segment, a first candidate area is determined from the video, and a plurality of first-category video segments with different starting times are cut out from the first candidate area; according to the ending time of the initial video segment, a second candidate area is determined from the video, and a plurality of second-category video segments with different ending times are cut out from the second candidate area;
[0288] It is understandable that, considering that the relevant video segment extraction method does not pay attention to the starting time and ending time of the video segment, resulting in inaccurate starting time and / or ending time of the extracted video segment, this example first extracts the initial video segment from the video through the above-mentioned video segment extraction method, and determines a first candidate area based on the starting time of the initial video segment, and cuts out multiple first-category video segments with different starting times (i.e., candidate starting video segments) in the first candidate area; determines a second candidate area based on the ending time of the initial video segment, and cuts out multiple second-category video segments with different ending times (i.e., candidate ending video segments) in the second candidate area.
[0289] For example, based on the start time and end time of the initial video clip, a first candidate area and a second candidate area are determined, and multiple start times are evenly selected in the first candidate area with a preset step size (for example, every 0.1 second), and based on the multiple start times, multiple first-category video clips are cut out; multiple end times are evenly selected in the second candidate area with a preset step size (for example, every 0.1 second), and based on the multiple end times, multiple second-category video clips are cut out.
[0290] In this example, determining a first candidate region from the video according to the starting time of the initial video segment includes:
[0291] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the first candidate region.
[0292] The determining of a second candidate region from the first video according to the termination time of the initial video segment includes:
[0293] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the second candidate region.
[0294] Exemplarily, based on the start and end times of the initial video clip, a 3-second video clip can be captured from the video with the start time as the center time as the first candidate area; and a 3-second video clip can be captured from the video with the end time as the center time as the second candidate area.
[0295] Step S402, inputting the multiple candidate video clips into a machine learning model, and using a feature extraction module of the machine learning model to extract video features of the candidate video clips; inputting the video features of the candidate video clips into a scoring module of the machine learning model, and obtaining a scoring value output by the scoring module that indicates whether the interception of the multiple candidate video clips meets the interception requirements;
[0296] In this example, by inputting multiple first-category video clips captured from the first candidate area and multiple second-category video clips captured from the second candidate area into the machine learning model, the scoring values of the first-category video clips and the scoring values of the second-category video clips output by the machine learning model can be obtained.
[0297] Step S403, determining the segment parameters of the candidate video segment corresponding to the maximum score value according to the score values of the multiple candidate video segments; and extracting the target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value;
[0298] In this example, based on the scoring values of the first category of video clips, the first category of video clips corresponding to the maximum scoring value is determined; the starting time of the initial video clip is adjusted to the starting time of the first category of video clips corresponding to the maximum scoring value; based on the scoring values of the second category of video clips, the second category of video clips corresponding to the maximum scoring value is determined; and the ending time of the initial video clip is adjusted to the ending time of the second category of video clips corresponding to the maximum scoring value, to obtain the target video clip.
[0299] Step S404, determining whether all the video frames in the candidate video segment corresponding to the maximum score value are from the same shot; when the video frames in the candidate video segment corresponding to the maximum score value are from different shots, re-determining the segment parameters of the candidate video segment according to the critical video frames corresponding to the different shot switching times; and adjusting the segment parameters of the target video segment according to the re-determined segment parameters of the candidate video segment.
[0300] In this example, re-determining the segment parameters of the candidate video segment includes:
[0301] The start time of the re-determined candidate video segment corresponds to the critical video frame, or the end time of the re-determined candidate video segment corresponds to the critical video frame.
[0302] It can be understood that after the target video segment is cut out from the video, shot boundary detection is performed on the first category of video segments corresponding to the maximum scoring value. If all video frames in the first category of video segments corresponding to the maximum scoring value are from different shots, that is, there is a shot boundary in the first category of video segments corresponding to the maximum scoring value, the starting time of the first category of video segments is adjusted to the critical video frame corresponding to the shot switching time.
[0303] Perform shot boundary detection on the second category video clip corresponding to the maximum scoring value. If all video frames in the second category video clip corresponding to the maximum scoring value are from different shots, that is, there is a shot boundary in the second category video clip corresponding to the maximum scoring value, adjust the end time of the second category video clip to the critical video frame corresponding to the shot switching time.
[0304] The start time and the end time of the target video segment are adjusted according to the adjusted start time of the first type of video segment and the adjusted end time of the second type of video segment.
[0305] The disclosed embodiment also provides a device for capturing video clips. Figure 6 is a schematic structural diagram of a device for capturing video clips according to an exemplary embodiment. Figure 6 As shown, the video clip capture device 100 includes:
[0306] The interception module 101 is used to intercept multiple candidate video segments from the video; wherein at least one of the starting time and the ending time of different candidate video segments is different;
[0307] The network scoring module 102 is used to input the multiple candidate video segments into the machine learning model to obtain a scoring value indicating whether the interception of the multiple candidate video segments meets the interception requirements; determine the segment parameters of the candidate video segment corresponding to the maximum scoring value according to the scoring values of the multiple candidate video segments; wherein the segment parameters include at least one of the starting time, the ending time and the segment duration of the candidate video segment;
[0308] The capture module 101 is further configured to capture a target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value.
[0309] Optionally, the candidate video segments include at least one of the following:
[0310] A first type of video clip, wherein the starting time of the first type of video clip is used to determine the starting time of the target video clip;
[0311] The second type of video clips, wherein the end time of the second type of video clips is used to determine the end time of the target video clip;
[0312] In the video, the playback time of the video frames included in the second-category video clips is later than the playback time of the video frames included in the first-category video clips.
[0313] Optionally, the interception module 101 is used to:
[0314] Extracting an initial video segment from the video;
[0315] Determine a first candidate region from the video according to the starting time of the initial video segment, and extract a plurality of first-category video segments having different starting times from the first candidate region;
[0316] and / or,
[0317] According to the end time of the initial video segment, a second candidate area is determined from the video, and a plurality of second-category video segments with different end times are cut out from the second candidate area.
[0318] Optionally, the interception module 101 is further used for:
[0319] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the first candidate region.
[0320] Optionally, the interception module 101 is further used for:
[0321] Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the second candidate region.
[0322] Optionally, the network scoring module 102 is used to:
[0323] Extracting video features of the candidate video clips using a feature extraction module of a machine learning model;
[0324] The video features are input into a scoring module of the machine learning module to obtain a scoring value output by the scoring module that represents whether the interception of the multiple candidate video segments meets the interception requirements.
[0325] Optionally, the device further includes: a detection module 103, configured to:
[0326] Determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot;
[0327] When the video frames in the candidate video segment corresponding to the maximum score value come from different shots, the segment parameters of the candidate video segment are re-determined according to the critical video frames corresponding to the different shot switching times; the starting time of the re-determined candidate video segment corresponds to the critical video frame, or the ending time of the re-determined candidate video segment corresponds to the critical video frame;
[0328] The interception module 101 is also used for:
[0329] Based on the adjusted segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
[0330] Optionally, the device further comprises: an acquisition module, configured to acquire a plurality of videos and annotation information of the plurality of videos; the annotation information at least comprises: an annotated video segment in the video and a start time and an end time of the annotated video segment;
[0331] A preprocessing module, used to preprocess the multiple videos based on the annotation information of the multiple videos to obtain a training sample set of an initial model;
[0332] A network training module, used for inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements;
[0333] A determination module is used to determine the loss function value of the initial model based on the predicted score value of the video clip; according to the loss function value of the initial model, the parameters to be trained of the initial model are adjusted to obtain a machine learning model.
[0334] Optionally, the preprocessing module is used to:
[0335] According to the starting time of the labeled video segment, extracting a first type of labeled video segment from the video;
[0336] According to the end time of the labeled video segment, extracting the second type of labeled video segment from the video;
[0337] At least one third-category annotated video segment is randomly cut out from the video; wherein the playback time of the video frames included in the second-category annotated video segment is later than the playback time of the video frames included in the first-category annotated video segment; the third-category annotated video segment is a video segment in the video that does not overlap with the first-category annotated video segment and the second-category annotated video segment;
[0338] Select any one of the third-category labeled video segments from the plurality of the third-category labeled video segments, and combine it with the first-category labeled video segment and the second-category labeled video segment belonging to the same labeled video segment to obtain a video triplet of the labeled video segment;
[0339] Based on the video triplets of the plurality of labeled video clips, a training sample set of the initial model is obtained.
[0340] Optionally, the network training module is used to:
[0341] Using a feature extraction module in the initial model to extract video features of the first category of labeled video clips, video features of the second category of labeled video clips, and video features of the third category of labeled video clips;
[0342] The video features of the first category of labeled video clips, the video features of the second category of labeled video clips, and the video features of the third category of labeled video clips are respectively input into the scoring module of the initial model to obtain the predicted scoring values of the first category of labeled video clips, the predicted scoring values of the second category of labeled video clips, and the predicted scoring values of the third category of labeled video clips output by the scoring module.
[0343] Optionally, the determining module is used to:
[0344] Determining a first loss function value of the initial model based on a first prediction score value of the first category of labeled video segments, a first prediction score value of the second category of labeled video segments, and a first prediction score value of the third category of labeled video segments; wherein the first prediction score value is used to indicate the probability that a video segment contains a video frame at the start time of the labeled video segment;
[0345] Determining a second loss function value of the initial model based on the second predicted score value of the first category of labeled video segments, the second predicted score value of the second category of labeled video segments, and the second predicted score value of the third category of labeled video segments; wherein the second predicted score value is used to indicate the probability that the video segment contains the video frame at the end time of the labeled video segment;
[0346] The loss function value of the initial model is determined according to the first loss function value and the second loss function value.
[0347] Optionally, the determining module is further used to:
[0348] Determining a first ranking loss value between the first category of labeled video segments and the second category of labeled video segments based on a difference between a first predicted score value of the first category of labeled video segments and a first predicted score value of the second category of labeled video segments;
[0349] Determining a second ranking loss value between the first category of labeled video segments and the third category of labeled video segments based on a difference between the first prediction score value of the first category of labeled video segments and the first prediction score value of the third category of labeled video segments;
[0350] Determine a first loss function value of the initial model according to the sum of the first sorting loss value and the second sorting loss value.
[0351] Optionally, the determining module is further used to:
[0352] Determining a third ranking loss value between the second-category labeled video clip and the first-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the first-category labeled video clip;
[0353] Determining a fourth ranking loss value between the second-category labeled video clip and the third-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the third-category labeled video clip;
[0354] A second loss function of the initial model is determined according to the sum of the third sorting loss value and the fourth sorting loss value.
[0355] 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 here.
[0356] Figure 7 8 is a block diagram of a video clip capture device according to an exemplary embodiment. For example, the device 800 may be a mobile phone, a mobile computer, etc.
[0357] Reference Figure 7 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0358] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0359] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0360] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0361] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0362] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0363] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0364] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0365] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0366] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0367] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0368] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0369] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for capturing a video clip, characterized in that: include: Extracting a plurality of candidate video segments from the video; wherein at least one of the starting time and the ending time of different candidate video segments is different; The multiple candidate video segments are input into a machine learning model to obtain a score value representing whether the interception of the multiple candidate video segments meets the interception requirements; the score value is at least used to indicate the possibility that the interception of the candidate video segments meets the interception requirements; wherein the starting time of the candidate video segments that meet the interception requirements includes the starting information of the target video segment, and / or the ending time of the candidate video segments that meet the interception requirements includes the ending information of the target video segment; Determine, according to the score values of the plurality of candidate video segments, a segment parameter of the candidate video segment corresponding to the maximum score value; wherein the segment parameter includes at least two of the start time, the end time, and the segment length of the candidate video segment; Based on the segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
2. The method according to claim 1, characterized in that The candidate video segments include at least one of the following: A first type of video clip, wherein the starting time of the first type of video clip is used to determine the starting time of the target video clip; The second type of video clips, wherein the end time of the second type of video clips is used to determine the end time of the target video clip; In the video, the playback time of the video frames included in the second-category video clips is later than the playback time of the video frames included in the first-category video clips.
3. The method according to claim 2, characterized in that The extracting a plurality of candidate video segments from the video includes: Extracting an initial video segment from the video; Determine a first candidate region from the video according to the starting time of the initial video segment, and extract a plurality of first-category video segments having different starting times from the first candidate region; and / or, According to the end time of the initial video segment, a second candidate area is determined from the video, and a plurality of second-category video segments with different end times are cut out from the second candidate area.
4. The method according to claim 3, characterized in that The step of determining a first candidate region from the video according to the starting time of the initial video segment includes: Taking the start time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the first candidate region.
5. The method according to claim 3, characterized in that: The step of determining a second candidate region from the video according to the termination time of the initial video segment includes: Taking the starting time of the initial video segment as the center time, a video region with a length equal to a preset duration is cut out from the video as the second candidate region.
6. The method according to claim 1, characterized in that The step of inputting the plurality of candidate video segments into a machine learning model to obtain a score indicating whether the interception of the plurality of candidate video segments meets the interception requirement includes: Extracting video features of the candidate video clips using a feature extraction module of a machine learning model; The video features are input into a scoring module of the machine learning model to obtain a scoring value output by the scoring module that represents whether the interception of the multiple candidate video segments meets the interception requirements.
7. The method according to claim 1, characterized in that The method further comprises: Determining whether all video frames in the candidate video segment corresponding to the maximum score value are from the same shot; When the video frames in the candidate video segment corresponding to the maximum score value come from different shots, the segment parameters of the candidate video segment are re-determined according to the critical video frames corresponding to the different shot switching times; the starting time of the re-determined candidate video segment corresponds to the critical video frame, or the ending time of the re-determined candidate video segment corresponds to the critical video frame; The extracting a target video segment from the video based on the segment parameters of the candidate video segment corresponding to the maximum score value includes: Based on the adjusted segment parameters of the candidate video segment corresponding to the maximum score value, a target video segment is captured from the video.
8. The method according to claim 1, characterized in that Before inputting the plurality of candidate video segments into the machine learning model, the method further includes: Acquire multiple videos and annotation information of the multiple videos; the annotation information at least includes: annotated video segments in the videos and the start time and end time of the annotated video segments; Based on the annotation information of the multiple videos, preprocessing the multiple videos to obtain a training sample set of an initial model; Inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements; Determining a loss function value of the initial model based on the predicted score value of the video clip; According to the loss function value of the initial model, the parameters to be trained of the initial network are adjusted to obtain a machine learning model.
9. The method according to claim 8, characterized in that The preprocessing of the multiple videos based on the annotation information of the multiple videos to obtain a training sample set of the initial model includes: According to the starting time of the labeled video segment, extracting a first type of labeled video segment from the video; According to the end time of the labeled video segment, extracting the second type of labeled video segment from the video; At least one third-category annotated video segment is randomly cut out from the video; wherein the playback time of the video frames included in the second-category annotated video segment is later than the playback time of the video frames included in the first-category annotated video segment; the third-category annotated video segment is a video segment in the video that does not overlap with the first-category annotated video segment and the second-category annotated video segment; Select any one of the third-category labeled video segments from the plurality of the third-category labeled video segments, and combine it with the first-category labeled video segment and the second-category labeled video segment belonging to the same labeled video segment to obtain a video triplet of the labeled video segment; Based on the video triplets of the plurality of labeled video clips, a training sample set of the initial model is obtained.
10. The method according to claim 9, characterized in that The step of inputting the video clips in the training sample set into the initial model to obtain a prediction score value representing whether the interception of the video clips meets the interception requirements includes: Using a feature extraction module in the initial model to extract video features of the first category of labeled video clips, video features of the second category of labeled video clips, and video features of the third category of labeled video clips; The video features of the first category of labeled video clips, the video features of the second category of labeled video clips, and the video features of the third category of labeled video clips are respectively input into the scoring module of the initial model to obtain the predicted scoring values of the first category of labeled video clips, the predicted scoring values of the second category of labeled video clips, and the predicted scoring values of the third category of labeled video clips output by the scoring module.
11. The method according to claim 10, characterized in that The step of determining the loss function value of the initial model based on the predicted score value of the video clip includes: Determining a first loss function value of the initial model based on a first prediction score value of the first category of labeled video segments, a first prediction score value of the second category of labeled video segments, and a first prediction score value of the third category of labeled video segments; wherein the first prediction score value is used to indicate the probability that a video segment contains a video frame at the start time of the labeled video segment; Determining a second loss function value of the initial model based on the second predicted score value of the first category of labeled video segments, the second predicted score value of the second category of labeled video segments, and the second predicted score value of the third category of labeled video segments; wherein the second predicted score value is used to indicate the probability that the video segment contains the video frame at the end time of the labeled video segment; The loss function value of the initial model is determined according to the first loss function value and the second loss function value.
12. The method according to claim 11, characterized in that The determining of the first loss function value of the initial model based on the first predicted score value of the first category of labeled video segments, the first predicted score value of the second category of labeled video segments, and the first predicted score value of the third category of labeled video segments includes: Determining a first ranking loss value between the first category of labeled video segments and the second category of labeled video segments based on a difference between a first predicted score value of the first category of labeled video segments and a first predicted score value of the second category of labeled video segments; Determining a second ranking loss value between the first category of labeled video segments and the third category of labeled video segments based on a difference between the first prediction score value of the first category of labeled video segments and the first prediction score value of the third category of labeled video segments; Determine a first loss function value of the initial model according to the sum of the first sorting loss value and the second sorting loss value.
13. The method according to claim 11, characterized in that The determining of the second loss function value of the initial model based on the second predicted score value of the first category of labeled video segments, the second predicted score value of the second category of labeled video segments, and the second predicted score value of the third category of labeled video segments includes: Determining a third ranking loss value between the second-category labeled video clip and the first-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the first-category labeled video clip; Determining a fourth ranking loss value between the second-category labeled video clip and the third-category labeled video clip based on a difference between the second predicted score value of the second-category labeled video clip and the second predicted score value of the third-category labeled video clip; Determine a second loss function value of the initial model according to the sum of the third sorting loss value and the fourth sorting loss value.
14. A video clip capture device, characterized in that: include: A capture module, used to capture multiple candidate video segments from a video; wherein at least one of the starting time and the ending time of different candidate video segments is different; A scoring module is used to input the multiple candidate video segments into a machine learning model to obtain a scoring value characterizing whether the interception of the multiple candidate video segments meets the interception requirements; determine the segment parameters of the candidate video segment corresponding to the maximum scoring value according to the scoring values of the multiple candidate video segments; wherein the segment parameters include at least two of the starting time, the ending time and the segment length of the candidate video segment; the scoring value is at least used to indicate the possibility that the interception of the candidate video segment meets the interception requirements; the starting time of the candidate video segment that meets the interception requirements includes the starting information of the target video segment, and / or the ending time of the candidate video segment that meets the interception requirements includes the ending information of the target video segment; The capture module is further configured to capture a target video segment from the video based on segment parameters of the candidate video segment corresponding to the maximum score value.
15. A video clip capture device, characterized in that: include: processor; a memory for storing executable instructions; The processor is configured to implement the video clip capture method according to any one of claims 1 to 13 when executing the executable instructions stored in the memory.
16. A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a video clip capture device, the video clip capture device is able to execute the video clip capture method according to any one of claims 1 to 13.
