Video frame alignment method and device

By dividing videos into fragment groups of different scenes and matching them based on scene alignment conditions and similarity, the problem of low efficiency of video frame alignment in the existing technology is solved, achieving more efficient frame alignment and video quality improvement.

CN114640852BActive Publication Date: 2024-08-23HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210277549.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-21
Publication Date
2024-08-23
Estimated Expiration
2042-03-21

AI Technical Summary

Technical Problem

Existing video frame alignment methods are inefficient and computationally intensive, and cannot effectively solve the problem of inconsistent start time points of video frames.

Method used

By dividing the video into fragment groups of different scenes, and matching them according to scene alignment conditions and similarity, the frame alignment points are determined, the amount of calculation is reduced, and the efficiency is improved.

Benefits of technology

It achieves more efficient video frame alignment, reduces the amount of calculation, and improves the quality and efficiency of video playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114640852B
    Figure CN114640852B
Patent Text Reader

Abstract

The present invention discloses a video frame alignment method and device, which can be performed by splitting two videos into two scene segment groups; determining a first pair of scene segments A1 and scene segment B1 that meet the scene alignment condition from the two scene segment groups; starting from A1 and B1, sequentially pairing the scene segments in the two scene segment groups in pairs; determining the similarity of each pair of scene segments; if the number of scene segments with a similarity greater than a preset similarity is greater than a preset number threshold, determining the first number of frames that are continuously overlapped between the first N frames of A1 and the first M frames of B1, and determining the second number of frames that are continuously overlapped between the first N frames of B1 and the first M frames of A1; if the first number of frames is greater than the second number of frames, aligning the first frame of A1 with the image of the corresponding frame in B1; if it is less than, aligning the first frame of B1 with the image of the corresponding frame in A1. The present invention has less calculation amount for frame alignment and higher efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of video, and in particular to a video frame alignment method and device. Background Art

[0002] With the rapid development of Internet technology, people's demand for video content is increasing. In order to provide users with higher-quality video content, there are certain requirements for video quality. There are many factors that affect video quality, and ensuring that video frames are aligned and start playing at the same time point is an important way to improve video quality.

[0003] Normally, the starting time points of videos may be inconsistent or even have large deviations. The commonly used video frame alignment method will match the image pixel content of each frame one by one from the starting position of the video in the two sets of videos to be aligned, so as to determine whether they are the same frame, and then realize the frame alignment operation. This method has a very large amount of calculation and is very slow, which is inefficient. Summary of the invention

[0004] In view of the above problems, the present invention provides a video frame alignment method and device that overcome the above problems or at least partially solve the above problems.

[0005] In a first aspect, a video frame alignment method includes:

[0006] Splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, respectively, wherein the first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video;

[0007] Determine a first pair of scene segments A1 and scene segments B1 that meet a scene alignment condition from the first scene segment group and the second scene segment group, wherein the scene alignment condition is that a time difference obtained by subtracting the playing time of the two scene segments is less than a preset time threshold, and A1 is from the first scene segment group, and B1 is from the second scene segment group;

[0008] Starting from A1 and B1, pairing each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence;

[0009] For any pair of the scene segments, the following steps are performed: determining the similarity between the two corresponding scene segments;

[0010] If the number of scene segments whose similarity is greater than a preset similarity is greater than a preset number threshold, determining a first number of frames that are continuously overlapped between the first N frames of images of A1 and the first M frames of images of B1, and determining a second number of frames that are continuously overlapped between the first N frames of images of B1 and the first M frames of images of A1, wherein both N and M are integers greater than 0;

[0011] If the first frame number is greater than the second frame number, aligning the first frame image of A1 with the image of the corresponding frame in B1;

[0012] If the second frame number is greater than the first frame number, the first frame image of B1 is aligned with the image of the corresponding frame in A1.

[0013] In combination with the first aspect, in some optional implementations, splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, respectively, includes:

[0014] Scene recognition is performed on the first video and the second video respectively, and according to corresponding results of the scene recognition, the first video and the second video are respectively divided into the first scene segment group and the second scene segment group.

[0015] In combination with the first aspect, in some optional implementations, determining a first pair of scene segments A1 and scene segments B1 that meet the scene alignment condition from the first scene segment group and the second scene segment group includes:

[0016] Calculating and obtaining the absolute value of the difference between the playing time of each scene segment of the second scene segment group and the playing time of the first scene segment of the first scene segment group;

[0017] Determine whether there is an absolute value less than the preset time threshold, and if so, determine the first scene segment of the first scene segment group as the A1 and determine the corresponding scene segment in the second scene segment group as the B1;

[0018] If there is no absolute value less than the preset time threshold, the absolute value of the difference between the playback duration of each scene segment of the second scene segment group and the playback duration of the second scene segment of the first scene segment group is calculated, and it is determined whether there is an absolute value less than the preset time threshold, and this cycle is repeated until the first pair of A1 and B1 is determined.

[0019] In combination with the previous embodiment, in some optional embodiments, after the cycle is repeated until the first pair of A1 and B1 is determined, the method further includes:

[0020] If the absolute values ​​of the differences between the playback durations of each scene segment of the second scene segment group and the playback durations of each scene segment of the first scene segment group are not less than the preset time threshold, the frame alignment of the first video and the second video is terminated.

[0021] In combination with the first aspect, in some optional implementations, starting from A1 and B1, pairing each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence, comprises:

[0022] Starting from A1 and B1, pair A1 and B1, pair the scene segment A2 arranged after A1 with the scene segment B2 arranged after B1, pair the scene segment A3 arranged after A2 with the scene segment B3 arranged after B2, and so on, in sequence, until all the scene segments of the first scene segment group are paired or until all the scene segments of the second scene segment group are paired.

[0023] In combination with the first aspect, in some optional implementations, the step of performing, for any pair of the scene segments: determining the similarity of the two corresponding scene segments, comprises:

[0024] For any pair of the scene segments, the following steps are performed: respectively acquiring intermediate frame images of the two scene segments;

[0025] The similarity is calculated by using a preset algorithm.

[0026] In combination with the first aspect, in some optional implementations, after performing the step of determining the similarity of the two corresponding scene segments for any pair of the scene segments, the method further includes:

[0027] If the number of scene segments with a similarity greater than a preset similarity is not greater than a preset number threshold, then deleting A1 and the scene segment arranged before A1, thereby obtaining a new first scene segment group;

[0028] The new first scene segment group is used as the first scene segment group described in the first implementation mode, and the method described in the first implementation mode is performed.

[0029] In combination with the first aspect, in some optional implementations, determining a first number of frames that continuously overlap between the first N frames of images of A1 and the first M frames of images of B1, and determining a second number of frames that continuously overlap between the first N frames of images of B1 and the first M frames of images of A1, includes:

[0030] Decode the first N frames of the A1 image into N pieces of A1 original data in YUV format, and decode the first M frames of the B1 image into M pieces of B1 original data in YUV format;

[0031] Compare the N pieces of A1 original data in YUV format with the M pieces of B1 original data in YUV format one by one, so as to determine the first frame number;

[0032] Decode the first N frames of images of B1 into N pieces of B1 original data in YUV format, and decode the first M frames of images of A1 into M pieces of A1 original data in YUV format;

[0033] The N pieces of B1 original data in YUV format are compared one by one with the M pieces of A1 original data in YUV format, so as to determine the second frame number.

[0034] In combination with the first aspect, in some optional implementations, the method further includes:

[0035] If the first number of frames is equal to the second number of frames and both are less than a preset frame number threshold, then increase M, and perform the first embodiment described in determining the first number of frames of continuous overlap between the first N frame images of A1 and the first M frame images of B1, and determining the second number of frames of continuous overlap between the first N frame images of B1 and the first M frame images of A1, as well as subsequent steps.

[0036] In a second aspect, a video frame alignment device includes: a splitting unit, a scene alignment unit, a scene pairing unit, a similarity determination unit, an overlapping frame number determination unit, a first frame alignment unit, and a second frame alignment unit;

[0037] The splitting unit is used to split the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, wherein the first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video;

[0038] The scene alignment unit is used to determine a first pair of scene segments A1 and scene segments B1 that meet a scene alignment condition from the first scene segment group and the second scene segment group, wherein the scene alignment condition is that a time difference obtained by subtracting the playing time of the two scene segments is less than a preset time threshold, and A1 is derived from the first scene segment group, and B1 is derived from the second scene segment group;

[0039] The scene pairing unit is used to pair each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence, starting from A1 and B1;

[0040] The similarity determination unit is used to perform, for any pair of the scene segments: determining the similarity of the corresponding two scene segments;

[0041] The overlapping frame number determining unit is used to determine a first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determine a second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, if the number of scene segments whose similarity is greater than a preset similarity is greater than a preset number threshold, wherein both N and M are integers greater than 0;

[0042] The first frame alignment unit is configured to align the first frame image of A1 with the image of the corresponding frame in B1 if the first frame number is greater than the second frame number;

[0043] The second frame alignment unit is configured to align the first frame image of B1 with the image of the corresponding frame in A1 if the second frame number is greater than the first frame number.

[0044] In a third aspect, a computer-readable storage medium stores a program, wherein the program, when executed by a processor, implements any of the above-mentioned video frame alignment methods.

[0045] In a fourth aspect, an electronic device comprises at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; and the processor is used to call program instructions in the memory to execute any of the video frame alignment methods described above.

[0046] By means of the above technical scheme, the video frame alignment method and device provided by the present invention can be achieved by splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, wherein the first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order of precedence in the corresponding video; a first pair of scene segments A1 and scene segments B1 that meet the scene alignment condition are determined from the first scene segment group and the second scene segment group, wherein the scene alignment condition is: the time difference obtained by subtracting the playback time of the two scene segments is less than a preset time threshold, and A1 comes from the first scene segment group, and B1 comes from the second scene segment group ; Starting from A1 and B1, pair each scene segment in the first scene segment group with each scene segment in the second scene segment group in turn; for any pair of the scene segments, perform: determine the similarity of the corresponding two scene segments; if the number of scene segments with a similarity greater than a preset similarity is greater than a preset number threshold, determine the first number of frames that overlap continuously between the first N frames of A1 and the first M frames of B1, and determine the second number of frames that overlap continuously between the first N frames of B1 and the first M frames of A1, wherein both N and M are integers greater than 0; if the first number of frames is greater than the second number of frames, align the first frame of A1 with the image of the corresponding frame in B1; if the second number of frames is greater than the first number of frames, align the first frame of B1 with the image of the corresponding frame in A1. It can be seen from this that the present invention can perform scene alignment first and then frame alignment, and frame alignment only calculates the similarity of the intermediate frame images, without calculating the similarity of each frame image, so the amount of calculation is small and the efficiency is high.

[0047] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0049] Figure 1 A flow chart of a video frame alignment method provided by the present invention is shown;

[0050] Figure 2 A flowchart of another video frame alignment method provided by the present invention is shown;

[0051] Figure 3 A schematic structural diagram of a video frame alignment device provided by the present invention is shown;

[0052] Figure 4 A structural schematic diagram of an electronic device provided by the present invention is shown. DETAILED DESCRIPTION

[0053] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0054] like Figure 1 As shown, the present invention provides a video frame alignment method, including: S100, S200, S300, S400, S500, S600 and S700;

[0055] S100, splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes;

[0056] The first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video;

[0057] Optionally, the first video and the second video mentioned in the present invention can be understood as two videos to be aligned. That is, the present invention can perform frame alignment on the first video and the second video, that is, determine the same starting frame image of the first video and the second video, and the present invention does not limit this.

[0058] Optionally, generally speaking, a video may involve different scenes, such as mountains, lakes, seas, homes, stores, and roads. Even more detailed divisions can be performed, such as a home can be further divided into different scenes such as a living room, kitchen, master bedroom, second bedroom, balcony, and bathroom. The present invention can split the first video and the second video into scene segments of multiple different scenes according to the same division criteria according to actual needs, and the present invention does not limit this.

[0059] For example, the first video is divided into a first scene segment group according to the division criteria of mountains, lakes, sea, home, store, and road. Similarly, the second video is divided into a second scene segment group according to the division criteria of mountains, lakes, sea, home, store, and road, so as to facilitate subsequent scene alignment, which is not limited in the present invention.

[0060] Of course, a scene clip can also refer to a group of shots, or multiple connected shots. For example, each transition in a video can correspond to a scene clip.

[0061] Optionally, for any video, the play order and play duration of each scene segment in the video are fixed. Therefore, when splitting into corresponding scene segment groups, each scene segment also needs to be arranged in sequence according to the play order to facilitate subsequent scene alignment and frame alignment to avoid confusion, and the present invention does not limit this.

[0062] Optionally, the present invention does not limit the process of identifying different scene segments and splitting them into different scene segments, and any feasible method belongs to the protection scope of the present invention. Figure 1 In some optional embodiments, the S100 includes:

[0063] Scene recognition is performed on the first video and the second video respectively, and according to corresponding results of the scene recognition, the first video and the second video are respectively divided into the first scene segment group and the second scene segment group.

[0064] Optionally, scene recognition may be shot-based scene recognition and segmentation, mainly based on segmentation at the image algorithm level, which is not limited in the present invention.

[0065] S200, determining a first pair of scene segments A1 and scene segments B1 that meet a scene alignment condition from the first scene segment group and the second scene segment group;

[0066] The scene alignment condition is as follows: the time difference obtained by subtracting the playing time of two scene segments is less than a preset time threshold, A1 is derived from the first scene segment group, and B1 is derived from the second scene segment group;

[0067] Optionally, as mentioned above, each scene segment of the first scene segment group and the second scene segment group is sorted according to the corresponding playback order. If the first video and the second video are two almost identical videos, only the starting frames for starting playback are inconsistent. Then the order of each scene segment of the first scene segment group and the second scene segment group should also be consistent. In this case, it is only necessary to find the first pair of scene segments that meet the scene alignment condition, and the subsequent scene segments are aligned one-to-one in sequence. For another example, if the first video includes the second video, that is, the second video is a segment of the first video. Even in this case, there is overlap between the first scene segment group and the second scene segment group, that is, the first scene segment group overlaps a part of the scene segments of the first scene segment group, but the order relationship between the overlapping scene segments is still consistent. In this case, it is still only necessary to find the first pair of scene segments that meet the scene alignment condition, and the subsequent scene segments are aligned one-to-one in sequence. Therefore, the present invention can determine the first pair of scene segments A1 and scene segments B1 that meet the scene alignment condition from the first scene segment group and the second scene segment group, and the present invention is not limited to this.

[0068] Optionally, as mentioned above, if it is the same video, the playing time of the same scene clip should also be consistent, and the difference will not be very large. Therefore, by subtracting the playing time of the scene clips of the same scene in the two videos, the difference in the playing time of the scene clips of the same scene in the two videos can be determined. If the difference is large, it means that the two scene clips may not be the same scene. If the difference is small, it means that the two scene clips may be the same scene. The present invention does not limit this.

[0069] Optionally, the present invention does not limit the method for determining the first pair of scene segments A1 and scene segments B1 that meet the scene alignment condition from the first scene segment group and the second scene segment group, and any feasible method belongs to the protection scope of the present invention. Figure 1 In the embodiment shown, in some optional embodiments, the S200 includes: step 1.1, step 1.2, step 1.3 and step 1.4;

[0070] Step 1.1, calculating and obtaining the absolute value of the difference between the playing time of each scene segment of the second scene segment group and the playing time of the first scene segment of the first scene segment group;

[0071] Optionally, the present invention can determine whether there is a scene segment satisfying the scene alignment condition in the second scene segment group based on the first scene segment group. That is, the present invention can first determine whether there is a scene segment in the second scene segment group that satisfies the scene alignment condition together with the first scene segment in the first scene segment group. Taking the first scene segment group including: A1, A2 and A3, and the second scene segment group including: B1, B2 and B3 as an example, the present invention can first calculate the first absolute value of the difference between the playback duration of A1 and B1. If the first absolute value is less than the preset time threshold, A1 and B1 are determined to be the first pair of scene segments that meet the scene alignment condition; if the first absolute value is not less than the preset time threshold, then the second absolute value of the difference between the playback duration of A1 and B2 is calculated. If the second absolute value is less than the preset time threshold, A1 and B2 are determined to be the first pair of scene segments that meet the scene alignment condition; if the second absolute value is not less than the preset time threshold, then the third absolute value of the difference between the playback duration of A1 and B3 is calculated, and so on, until the first pair of scene segments that meet the scene alignment condition is found. If the first pair of scene segments that meet the scene alignment condition is not found until the absolute value of the difference between all scene segments of the first scene segment group and all scene segments of the second scene segment group is calculated, it means that the first video and the second video have no repeated video segments, and the video frame alignment is terminated.

[0072] Step 1.2, determine whether there is an absolute value less than the preset time threshold, if so, execute step 1.3, otherwise execute step 1.4;

[0073] Step 1.3, determining the first scene segment of the first scene segment group as the A1 and determining the corresponding scene segment in the second scene segment group as the B1;

[0074] As described above, for example, if the first absolute value is less than a preset time threshold, A1 and B1 are determined to be the first pair of scene segments that meet the scene alignment condition. Optionally, in order to clearly describe the solution of the present invention, the present invention uses A1 and B1 to describe the first pair of scene segments that meet the scene alignment condition, but is not limited thereto.

[0075] Step 1.4, calculate the absolute value of the difference between the playback duration of each scene segment of the second scene segment group and the playback duration of the second scene segment of the first scene segment group, and determine whether there is an absolute value less than the preset time threshold, and repeat this cycle until the first pair of A1 and B1 is determined.

[0076] Optionally, as in the example described above, the present invention can calculate |A1-B1|, |A1-B2|, |A1-B3|, |A2-B1|, |A2-B2|, |A2-B3|, |A3-B1|, |A3-B2| and |A3-B3| in sequence, and each time the corresponding absolute value is calculated, first determine whether the current calculated absolute value is less than a preset time threshold. If not, calculate the next absolute value in the above order. The present invention is not limited to this.

[0077] In combination with the previous embodiment, in some optional embodiments, after the cycle is repeated until the first pair of A1 and B1 is determined, the method further includes:

[0078] If the absolute values ​​of the differences between the playback durations of each scene segment of the second scene segment group and the playback durations of each scene segment of the first scene segment group are not less than the preset time threshold, the frame alignment of the first video and the second video is terminated.

[0079] S300, starting from A1 and B1, pairing each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence;

[0080] Optionally, as mentioned above, after the first pair of scene segments that meet the scene alignment conditions are determined, the subsequent scene segments are aligned in pairs in sequence. That is, A1 and B1 are the first pair of scene segments that meet the scene alignment conditions, A2 and B2 are the second pair, A3 and B3 are the third pair, and so on. If the number of subsequent scene segments in the two scene segment groups is different, the redundant ones are discarded. For example, if the second scene segment group also includes B4 and B5, and the first scene segment group ends at A3 and there is no corresponding A4 and A5, then B4 and B5 are discarded this time and no pairing is performed. The present invention does not limit this.

[0081] That is, combined Figure 1 In some optional embodiments, the S300 includes:

[0082] Starting from A1 and B1, pair A1 and B1, pair the scene segment A2 arranged after A1 with the scene segment B2 arranged after B1, pair the scene segment A3 arranged after A2 with the scene segment B3 arranged after B2, and so on, in sequence, until all the scene segments of the first scene segment group are paired or until all the scene segments of the second scene segment group are paired.

[0083] S400, for any pair of the scene segments, executing: determining the similarity of the two corresponding scene segments;

[0084] Optionally, to perform scene alignment, it is necessary to determine whether the result of this matching is correct, that is, it is necessary to determine whether the two scene segments that match each other in S300 are from the same video. Therefore, it is necessary to calculate the corresponding similarity for each pair of scene segments.

[0085] Optionally, the present invention does not impose any specific restrictions on the process of calculating similarity, and any feasible method belongs to the protection scope of the present invention. Figure 1 In the embodiment shown, in some optional embodiments, the 400 includes: step 2.1 and step 2.2;

[0086] Step 2.1: for any pair of the scene segments, the following steps are performed: obtaining intermediate frame images of the two scene segments respectively;

[0087] Step 2.2: Calculate the similarity using a preset algorithm.

[0088] Optionally, the intermediate frame image in the present invention refers to the image of the intermediate frame of each scene segment. If the total number of frames of the scene segment is an even number, the images of the two intermediate frames are obtained, and if the total number of frames of the scene segment is an odd number, the image of the intermediate frame is obtained.

[0089] Optionally, the algorithm for calculating the similarity between two images is a well-known technique in the art, and the present invention will not describe it in detail. For details, please refer to the relevant description in the art.

[0090] S500, if the number of scene segments having a similarity greater than a preset similarity is greater than a preset number threshold, determining a first number of frames that are continuously overlapped between the first N frames of image A1 and the first M frames of image B1, and determining a second number of frames that are continuously overlapped between the first N frames of image B1 and the first M frames of image A1;

[0091] Wherein, both N and M are integers greater than 0;

[0092] Optionally, if the similarities of most of the mutually matching scene segments are greater than a preset similarity, it means that the current scene alignment is relatively accurate, and corresponding frame alignment can be performed next.

[0093] Optionally, in addition to determining whether the number is greater than a preset number threshold, the percentage can also be determined, that is, determining whether the percentage of scene segments with a similarity greater than a preset similarity to the mutually matching scene segments exceeds a preset percentage, which is not limited in the present invention.

[0094] Optionally, if the number of scene segments whose similarity is not greater than a preset similarity is greater than a preset number threshold, it means that the current scene alignment is not very accurate and needs to be realigned. Figure 1 In the embodiment shown, in some optional embodiments, after S400, the method further includes: step 3.1 and step 3.2;

[0095] Step 3.1: if the number of scene segments with a similarity greater than a preset similarity is not greater than a preset number threshold, then A1 and the scene segments arranged before A1 are deleted, thereby obtaining a new first scene segment group;

[0096] Step 3.2: Use the new first scene segment group as the first scene segment group described in the first implementation mode, and execute Figure 1 The method described.

[0097] Optionally, as mentioned above, after the first scene segment that meets the scene alignment condition is found, the subsequent scene segments are matched in sequence, so the present invention can slightly stagger the order, that is, the A1 and the scene segments arranged before the A1 are deleted, and the present invention is re-executed. By deleting individual scene segments and adjusting the matching order, accurate scene alignment can be achieved, and the present invention is not limited to this.

[0098] Optionally, as mentioned above, frame alignment is to determine the common playback start position of the two scene segments, that is, to determine the common start frame image. For example, the start time of scene segment A1 in the first video is the 1st second of the 8th minute, and the start time of scene segment B1 in the second video is the 5th second of the 8th minute. Obviously, the start time of scene segment B1 is later than the start time of scene segment A1, so the start frame images of scene segments A1 and scene segments B1 at the 5th second of the 8th minute can be determined, and the present invention is not limited to this.

[0099] Specifically, the present invention determines which scene segment has a later start time by comparing the images of the previous N frames. Therefore, the present invention can determine the first frame number and the second frame number, wherein N and M can be set and changed according to actual needs, and the present invention does not limit this.

[0100] For example, combined with Figure 1 In the embodiment shown, in some optional embodiments, the determining of the first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and the determining of the second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1 in S500 include: step 4.1, step 4.2, step 4.3 and step 4.4;

[0101] Step 4.1, respectively decode the first N frames of the A1 image into N strips of A1 original data in YUV format, and respectively decode the first M frames of the B1 image into M strips of B1 original data in YUV format;

[0102] Step 4.2, comparing the N pieces of A1 original data in YUV format with the M pieces of B1 original data in YUV format one by one, thereby determining the first frame number;

[0103] Step 4.3, respectively decode the first N frames of the B1 image into N pieces of B1 original data in YUV format, and respectively decode the first M frames of the A1 image into M pieces of A1 original data in YUV format;

[0104] Step 4.4: Compare the N pieces of B1 original data in YUV format with the M pieces of A1 original data in YUV format one by one, so as to determine the second frame number.

[0105] Optionally, there is no necessary order between step 4.1 and step 4.3 of the present invention, and they may be executed in parallel, or step 4.1 may be executed first or step 4.3 may be executed first, and the present invention does not impose any limitation on this.

[0106] Optionally, the raw data in YUV format is a well-known concept in the art, and the present invention does not limit the process of decoding the raw data in YUV format. For details, please refer to the relevant descriptions in the art. It should be noted that the raw data in YUV format refers to the undamaged raw data after decoding a single frame, because when performing frame alignment, the YUV components of each pixel can be calculated and compared to determine whether the frame is aligned, which is more accurate.

[0107] S600, if the first frame number is greater than the second frame number, aligning the first frame image of A1 with the image of the corresponding frame in B1;

[0108] Optionally, if the first frame number is greater than the second frame number, then the starting position of A1 exists in B1, the first frame of A1 is the first frame of frame alignment, and the frame aligned with the first frame of A1 found in B1 is the starting point of frame alignment of B1. The present invention does not impose any limitation on this.

[0109] S700: If the second number of frames is greater than the first number of frames, align the first frame image of B1 with the image of the corresponding frame in A1.

[0110] Optionally, if the second frame number is greater than the first frame number, then the starting position of B1 exists in A1, the first frame of B1 is the first frame of frame alignment, and the frame aligned with the first frame of B1 found in A1 is the starting point of frame alignment of A1. The present invention does not impose any limitation on this.

[0111] If the first frame number and the second frame number are equal, the first frame for frame alignment cannot be determined. In this case, N and / or M can be adjusted to change the first frame number and / or the second frame number, thereby determining the first frame for frame alignment. The present invention does not limit this. Figure 1 In some optional embodiments, the method further comprises:

[0112] If the first frame number and the second frame number are equal and both are less than the preset frame number threshold, increase the M and execute Figure 1 The method comprises determining the first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determining the second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, and subsequent steps.

[0113] Optionally, the present invention does not impose any restrictions on the preset frame number threshold, and can be set according to actual needs. It should be noted that if the first frame number and the second frame number are equal and not less than the preset frame number threshold, it means that the length of the completely overlapping videos of A1 and B1 is greater than a certain length, and video frame alignment can be performed directly.

[0114] Optionally, in order to further clearly describe the solution of the present invention, please refer to Figure 2 The example shown takes video A and video B as examples, which includes the process of splitting into scene segments, scene alignment and frame alignment.

[0115] like Figure 3 As shown, the present invention provides a video frame alignment device, comprising: a splitting unit 100, a scene alignment unit 200, a scene pairing unit 300, a similarity determination unit 400, an overlapping frame number determination unit 500, a first frame alignment unit 600 and a second frame alignment unit 700;

[0116] The splitting unit 100 is used to split the first video and the second video into a first scene segment group and a second scene segment group according to different scenes;

[0117] The first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video;

[0118] The scene alignment unit 200 is used to determine a first pair of scene segments A1 and scene segments B1 that meet the scene alignment condition from the first scene segment group and the second scene segment group;

[0119] The scene alignment condition is as follows: the time difference obtained by subtracting the playing time of two scene segments is less than a preset time threshold, A1 is derived from the first scene segment group, and B1 is derived from the second scene segment group;

[0120] The scene pairing unit 300 is used to pair each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence, starting from A1 and B1;

[0121] The similarity determination unit 400 is used to perform, for any pair of the scene segments: determining the similarity of the two corresponding scene segments;

[0122] The overlapping frame number determining unit 500 is used to determine a first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determine a second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, if the number of scene segments whose similarity is greater than a preset similarity is greater than a preset number threshold;

[0123] Wherein, both N and M are integers greater than 0;

[0124] The first frame alignment unit 600 is configured to align the first frame image of the A1 with the image of the corresponding frame in the B1 if the first frame number is greater than the second frame number;

[0125] The second frame alignment unit 700 is configured to align the first frame image of B1 with the image of the corresponding frame in A1 if the second frame number is greater than the first frame number.

[0126] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the splitting unit 100 comprises: a splitting subunit;

[0127] The splitting subunit is used to perform scene recognition on the first video and the second video respectively, and split the first video and the second video into the first scene segment group and the second scene segment group respectively according to the corresponding results of the scene recognition.

[0128] Combination Figure 3 In the illustrated embodiment, in some optional embodiments, the scene alignment unit 200 includes: an absolute value calculation subunit, an absolute value judgment subunit, a first determination subunit and a circulation subunit;

[0129] an absolute value calculation subunit, configured to calculate an absolute value of a difference between a playback duration of each scene segment of the second scene segment group and a playback duration of a first scene segment of the first scene segment group;

[0130] an absolute value judgment subunit, used to judge whether there is an absolute value less than the preset time threshold, and if so, trigger the first determination subunit, otherwise trigger the circulation subunit;

[0131] A first determining subunit, configured to determine the first scene segment of the first scene segment group as the A1 and determine the corresponding scene segment in the second scene segment group as the B1;

[0132] The loop sub-unit is used to calculate the absolute value of the difference between the playback duration of each scene segment of the second scene segment group and the playback duration of the second scene segment of the first scene segment group, and determine whether there is an absolute value less than the preset time threshold, and repeat this cycle until the first pair of A1 and B1 is determined.

[0133] In combination with the previous embodiment, in some optional embodiments, the device further includes: a termination unit;

[0134] A termination unit is used to terminate the frame alignment of the first video and the second video after the cycle is repeated until the first pair of A1 and B1 is determined, if the absolute values ​​of the differences between the playback durations of the respective scene segments of the second scene segment group and the playback durations of the respective scene segments of the first scene segment group are not less than the preset time threshold.

[0135] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the scene pairing unit 300 includes: a scene pairing subunit;

[0136] The scene pairing subunit is used to pair the A1 and B1 starting from the A1 and the B1, pair the scene segment A2 arranged after the A1 with the scene segment B2 arranged after the B1, pair the scene segment A3 arranged after the A2 with the scene segment B3 arranged after the B2, and so on in sequence until all the scene segments of the first scene segment group are paired or until all the scene segments of the second scene segment group are paired.

[0137] Combination Figure 3 In the illustrated embodiment, in some optional embodiments, the similarity determination unit 400 includes: an intermediate frame subunit and a similarity calculation subunit;

[0138] The intermediate frame subunit is used to perform, for any pair of the scene segments: respectively acquiring intermediate frame images of the two scene segments;

[0139] The similarity calculation subunit is used to calculate the similarity using a preset algorithm.

[0140] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the device further comprises: a deletion subunit and a duplication subunit;

[0141] a deleting subunit, configured to perform, for any pair of the scene segments: after determining the similarity of the corresponding two scene segments, if the number of scene segments having the similarity greater than the preset similarity is not greater than a preset number threshold, deleting the A1 and the scene segment arranged before the A1, thereby obtaining a new first scene segment group;

[0142] Repeating subunit, used to use the new first scene segment group as Figure 3 The first scene segment group, and execute Figure 3 The method described.

[0143] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the stacked frame number determination unit 500 includes: a first decoding subunit, a first frame number subunit, a second decoding subunit, and a second frame number subunit;

[0144] A first decoding subunit, configured to decode the first N frames of images of A1 into N pieces of A1 original data in YUV format, and to decode the first M frames of images of B1 into M pieces of B1 original data in YUV format;

[0145] A first frame number subunit, used for comparing the N pieces of A1 original data in YUV format with the M pieces of B1 original data in YUV format one by one, so as to determine the first frame number;

[0146] The second decoding subunit is used to decode the first N frames of images of B1 into N pieces of B1 original data in YUV format, and to decode the first M frames of images of A1 into M pieces of A1 original data in YUV format;

[0147] The second frame number subunit is used to compare the N pieces of B1 original data in YUV format with the M pieces of A1 original data in YUV format one by one, so as to determine the second frame number.

[0148] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the apparatus further comprises: a frame alignment repetition unit;

[0149] A frame alignment repetition unit, configured to increase M if the first frame number and the second frame number are equal and both are less than a preset frame number threshold, and execute Figure 3The method comprises determining the first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determining the second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, and subsequent steps.

[0150] The present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the video frame alignment method described in any one of the above items is implemented.

[0151] like Figure 4 As shown, the present invention provides an electronic device 70, which includes at least one processor 701, and at least one memory 702 and a bus 703 connected to the processor 701; wherein the processor 701 and the memory 702 communicate with each other through the bus 703; the processor 701 is used to call the program instructions in the memory 702 to execute any of the video frame alignment methods described above.

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

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

[0154] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

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

Claims

1. A video frame alignment method, characterized in that: include: Splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, respectively, wherein the first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video; Determine a first pair of scene segments A1 and scene segments B1 that meet a scene alignment condition from the first scene segment group and the second scene segment group, wherein the scene alignment condition is that a time difference obtained by subtracting the playing time of the two scene segments is less than a preset time threshold, and A1 is from the first scene segment group, and B1 is from the second scene segment group; Starting from A1 and B1, pairing each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence; For any pair of the scene segments, the following steps are performed: determining the similarity between the two corresponding scene segments; If the number of scene segments whose similarity is greater than a preset similarity is greater than a preset number threshold, determining a first number of frames that are continuously overlapped between the first N frames of images of A1 and the first M frames of images of B1, and determining a second number of frames that are continuously overlapped between the first N frames of images of B1 and the first M frames of images of A1, wherein both N and M are integers greater than 0; If the first frame number is greater than the second frame number, aligning the first frame image of A1 with the image of the corresponding frame in B1; If the second frame number is greater than the first frame number, the first frame image of B1 is aligned with the image of the corresponding frame in A1.

2. The method according to claim 1, characterized in that The step of splitting the first video and the second video into a first scene segment group and a second scene segment group according to different scenes comprises: Scene recognition is performed on the first video and the second video respectively, and according to corresponding results of the scene recognition, the first video and the second video are respectively divided into the first scene segment group and the second scene segment group.

3. The method according to claim 1, characterized in that: The step of determining a first pair of scene segments A1 and scene segments B1 satisfying a scene alignment condition from the first scene segment group and the second scene segment group includes: Calculating and obtaining the absolute value of the difference between the playing time of each scene segment of the second scene segment group and the playing time of the first scene segment of the first scene segment group; Determine whether there is an absolute value less than the preset time threshold, and if so, determine the first scene segment of the first scene segment group as the A1 and determine the corresponding scene segment in the second scene segment group as the B1; If there is no absolute value less than the preset time threshold, the absolute value of the difference between the playback duration of each scene segment of the second scene segment group and the playback duration of the second scene segment of the first scene segment group is calculated, and it is determined whether there is an absolute value less than the preset time threshold, and this cycle is repeated until the first pair of A1 and B1 is determined.

4. The method according to claim 3, characterized in that After the cycle is repeated until the first pair of A1 and B1 is determined, the method further includes: If the absolute values ​​of the differences between the playback durations of each scene segment of the second scene segment group and the playback durations of each scene segment of the first scene segment group are not less than the preset time threshold, the frame alignment of the first video and the second video is terminated.

5. The method according to claim 1, characterized in that The step of sequentially pairing each scene segment in the first scene segment group with each scene segment in the second scene segment group starting from A1 and B1 includes: Starting from A1 and B1, pair A1 and B1, pair the scene segment A2 arranged after A1 with the scene segment B2 arranged after B1, pair the scene segment A3 arranged after A2 with the scene segment B3 arranged after B2, and so on, in sequence, until all the scene segments of the first scene segment group are paired or until all the scene segments of the second scene segment group are paired.

6. The method according to claim 1, characterized in that The step of performing, for any pair of the scene segments, determining the similarity of the two corresponding scene segments comprises: For any pair of the scene segments, the following steps are performed: respectively acquiring intermediate frame images of the two scene segments; The similarity is calculated by using a preset algorithm.

7. The method according to claim 1, characterized in that After performing the step of determining the similarity of the two corresponding scene segments for any pair of the scene segments, the method further comprises: If the number of scene segments with a similarity greater than a preset similarity is not greater than a preset number threshold, then deleting A1 and the scene segment arranged before A1, thereby obtaining a new first scene segment group; The new first scene segment group is used as the first scene segment group described in claim 1, and the method described in claim 1 is performed.

8. The method according to claim 1, characterized in that The step of determining a first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determining a second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, comprises: Decode the first N frames of the A1 image into N pieces of A1 original data in YUV format, and decode the first M frames of the B1 image into M pieces of B1 original data in YUV format; Compare the N pieces of A1 original data in YUV format with the M pieces of B1 original data in YUV format one by one, so as to determine the first frame number; Decode the first N frames of images of B1 into N pieces of B1 original data in YUV format, and decode the first M frames of images of A1 into M pieces of A1 original data in YUV format; The N pieces of B1 original data in YUV format are compared one by one with the M pieces of A1 original data in YUV format, so as to determine the second frame number.

9. The method according to claim 1, characterized in that: The method further comprises: If the first number of frames is equal to the second number of frames and both are less than a preset frame number threshold, then increase M, and determine the first number of frames of continuous overlap between the first N frames of A1 and the first M frames of B1 as described in claim 1, and determine the second number of frames of continuous overlap between the first N frames of B1 and the first M frames of A1, as well as subsequent steps.

10. A video frame alignment device, characterized in that: include: A splitting unit, a scene alignment unit, a scene pairing unit, a similarity determination unit, an overlapping frame number determination unit, a first frame alignment unit, and a second frame alignment unit; The splitting unit is used to split the first video and the second video into a first scene segment group and a second scene segment group according to different scenes, wherein the first scene segment group includes scene segments of multiple different scenes of the first video, and the second scene segment group includes scene segments of multiple different scenes of the second video, one scene segment corresponds to one scene, and different scene segments are arranged in sequence according to the order in the corresponding video; The scene alignment unit is used to determine a first pair of scene segments A1 and scene segments B1 that meet a scene alignment condition from the first scene segment group and the second scene segment group, wherein the scene alignment condition is that a time difference obtained by subtracting the playing time of the two scene segments is less than a preset time threshold, and A1 is derived from the first scene segment group, and B1 is derived from the second scene segment group; The scene pairing unit is used to pair each scene segment in the first scene segment group with each scene segment in the second scene segment group in sequence, starting from A1 and B1; The similarity determination unit is used to perform, for any pair of the scene segments: determining the similarity of the corresponding two scene segments; The overlapping frame number determining unit is used to determine a first number of frames that are continuously overlapped between the first N frames of the image of A1 and the first M frames of the image of B1, and determine a second number of frames that are continuously overlapped between the first N frames of the image of B1 and the first M frames of the image of A1, if the number of scene segments whose similarity is greater than a preset similarity is greater than a preset number threshold, wherein both N and M are integers greater than 0; The first frame alignment unit is configured to align the first frame image of A1 with the image of the corresponding frame in B1 if the first frame number is greater than the second frame number; The second frame alignment unit is configured to align the first frame image of B1 with the image of the corresponding frame in A1 if the second frame number is greater than the first frame number.