Video processing method, device and equipment and computer readable storage medium
Through rough estimation of optical flow between video frames and determination of the number of adaptive interpolation frames, the quality of intermediate video frame generation in video frame interpolation technology is improved, the problem of optical flow estimation performance limitations is solved, and a smoother video splicing effect is achieved. .
Patent Information
- Application Number
- CN202311733538.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2024-10-22
AI Technical Summary
In existing video frame interpolation technology, the performance limitation of optical flow estimation results in low quality of intermediate frame generation, with problems such as blur, artifacts or jumps. Especially in high-speed motion scenes and complex scenes, the generation quality is reduced.
By performing rough optical flow estimation between different video frames, target intermediate video frames are generated to reduce the impact of optical flow estimation performance on frame interpolation performance, and improve video splicing quality through adaptive interpolation frame number determination and iterative optimization.
It improves the generation quality of intermediate video frames, avoids over-reliance on optical flow estimation performance, achieves smoother video splicing effects, and reduces the resource consumption of manually setting the number of inserted frames.
Smart Images

Figure CN118828052A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video generation technology, and in particular to a video processing method, device, equipment and computer-readable storage medium. Background Art
[0002] In the field of video generation, video frame interpolation (VFI) technology is a method for improving video frame rate, which can effectively improve the smoothness of video playback and the user's viewing experience. The general operation method of video interpolation is to give two frames of input image I 1 and I 2 , generate the intermediate frame image I between the two i , and I i Insert to I 1 with I 2 The position between.
[0003] The video interpolation performance of the video interpolation method in the related art is limited by the performance of the optical flow estimation algorithm, that is, it usually relies on the optical flow estimation algorithm to calculate accurate inter-frame motion information, and further uses image deformation to generate intermediate frame images. However, accurate optical flow (OF) estimation does not necessarily bring continuous gains in downstream video frame generation tasks. The intermediate frame images generated by the video interpolation method in the related art usually have problems such as blurring, artifacts or jumps, resulting in reduced quality of intermediate video frame generation. Summary of the invention
[0004] In order to solve the technical problems existing in the related art, the embodiments of the present application provide a video processing method, device, equipment and computer-readable storage medium.
[0005] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a video processing method, the method comprising:
[0007] Acquire a first video clip and a second video clip; the first video clip and the second video clip are different video clips in the same scene in the video to be spliced;
[0008] Performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment;
[0009] Determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame;
[0010] A target intermediate video frame is generated based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and a displacement factor; the displacement factor represents a position of the target intermediate video frame.
[0011] In a second aspect, an embodiment of the present application further provides a video processing device, including:
[0012] An acquisition unit, configured to acquire a first video segment and a second video segment; the first video segment and the second video segment are different video segments in the same scene in the video to be spliced;
[0013] an extraction unit, configured to perform frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment;
[0014] A first determining unit, configured to determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame;
[0015] A generating unit is used to generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and a displacement factor; the displacement factor represents the position of the target intermediate video frame.
[0016] In a third aspect, an embodiment of the present application further provides a video processing device, comprising: a processor and a memory for storing a computer program that can be run on the processor;
[0017] Wherein, when the processor is used to run the computer program, it executes the steps of the video processing method described in the embodiment of the present application.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the video processing method described in the embodiment of the present application are implemented.
[0019] The video processing method, apparatus, device and computer-readable storage medium provided in the embodiment of the present application obtain different video clips in the same scene in the video to be spliced, namely, the first video clip and the second video clip; perform frame extraction on the first video clip and the second video clip to obtain the first video frame corresponding to the first video clip and the second video frame corresponding to the second video clip; determine the first optical flow intensity from the first video frame to the second video frame, and the second optical flow intensity from the second video frame to the first video frame; generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and the displacement factor; the displacement factor represents the position of the target intermediate video frame. The video processing method of the embodiment of the present application is used to perform a rough optical flow estimation on the optical flow intensity between different video frames, so as to generate a target intermediate video frame based on the rough estimated optical flow intensity and the video frame to be spliced, that is, by shifting the focus of the video interpolation task from the precise optical flow estimation to the final task, namely, the generation of the intermediate video frame, so as to alleviate the influence of the optical flow estimation performance limitation on the interpolation performance, improve the generation quality of the intermediate video frame, and thus avoid the excessive dependence of the intermediate video frame generation quality on the optical flow estimation performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 The video processing method of the present invention is shown in FIG. Figure 1 ;
[0021] Figure 2 The video processing method of the present invention is shown in FIG. Figure 2 ;
[0022] Figure 3 The video processing method of the present invention is shown in FIG. Figure 3 ;
[0023] Figure 4 A schematic diagram of a flow chart of a method for determining the number of interpolation frames according to an embodiment of the present application;
[0024] Figure 5 A schematic diagram of a process for generating a target intermediate video frame according to an embodiment of the present application;
[0025] Figure 6 A schematic diagram of the structure of a video processing device according to an embodiment of the present application;
[0026] Figure 7 Schematic diagram of the hardware structure of the video processing device according to the embodiment of the present application. DETAILED DESCRIPTION
[0027] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0029] At present, in the field of video generation, video interpolation technology is used as a method to improve video frame rate. On the one hand, it can effectively improve the smoothness of video playback and the user's viewing experience; on the other hand, it can also be used to alleviate the splicing jumps between different video clips and improve the splicing smoothness and fluency between different video clips of the same scene.
[0030] Generally speaking, the general operation method of video interpolation is to give two frames of input image I 1 and I 2 , generate the intermediate frame image I between the two i , and I i Insert to I 1 with I 2 The position between them. The video interpolation method in the related art usually relies on accurate optical flow estimation algorithms to calculate accurate inter-frame motion information, and further uses image deformation (warp) to generate intermediate frame images. However, accurate optical flow estimation may not necessarily bring continuous gains in downstream video frame generation tasks. Existing video interpolation algorithms usually have problems such as generating blur, artifacts or jumps, resulting in reduced quality of intermediate frame image generation. In addition, for images of high-speed motion scenes and more complex motion scenes, interpolation bad cases are also prone to occur, which will also lead to reduced quality of intermediate frame image generation.
[0031] Based on this, an embodiment of the present application proposes a video processing method. In various embodiments of the present application, a rough optical flow estimation is performed on the optical flow intensity between different video frames, so as to generate a target intermediate video frame based on the roughly estimated optical flow intensity and the video frame to be spliced. That is to say, by shifting the focus of the video interpolation task from accurate optical flow estimation to the final task, namely, intermediate video frame generation, the impact of the optical flow estimation performance limitation on the interpolation performance is alleviated, and the generation quality of the intermediate video frames is improved, thereby avoiding excessive dependence of the intermediate video frame generation quality on the optical flow estimation performance.
[0032] The embodiment of the present application provides a video processing method, which is applied to a video processing device. Figure 1 The video processing method of the present invention is shown in FIG. Figure 1 ;like Figure 1 As shown, the video processing method includes:
[0033] Step 101: Obtain a first video segment and a second video segment.
[0034] Here, the video processing device can obtain a target video image that needs to be interpolated, wherein the target video image includes a video frame sequence composed of continuous video frames; that is, each video frame is a frame image, multiple video frames can constitute a video segment, and the target video image includes at least two video segments.
[0035] In the embodiment of the present application, the first video segment and the second video segment are associated with each other, that is, the first video segment and the second video segment are different video segments in the same scene in the video to be spliced. For obtaining the first video segment and the second video segment, specifically, the video processing device can obtain the first video segment and the second video segment from at least two video segments in the same scene of the target video image.
[0036] As an implementation method, the video processing device can download the target video image through the network, and obtain the first video segment and the second video segment from the video frame sequence of the target video image. Specifically, the video processing device can obtain the target video image from the server through an application programming interface (API), wherein the server can be a specific server for storing or generating video images for different application scenarios. The video processing device can include a computer device with storage and computing functions, such as a smart phone and a tablet.
[0037] As another implementation, the video processing device may obtain the target video image locally, that is, obtain the target video image offline from a locally stored file.
[0038] Step 102: performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment.
[0039] In actual application, when performing video frame insertion, the video processing device usually inserts video frames between the last frame of the first video segment to be spliced and the first frame of the second video segment to be spliced in order to achieve a smooth splicing effect for the splicing of two different video segments of the same scene, namely the first video segment and the second video segment, so as to slow down the splicing jump. Therefore, before this, the video processing device needs to extract frames from the video segments to be spliced to obtain the corresponding last frame of the first video segment and the first frame of the second video segment.
[0040] Based on this, in one embodiment, the performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment includes:
[0041] Extracting frames from at least two video frames included in the first video segment, and determining the last frame of the first video segment as the first video frame; the last frame represents a video frame at the last position of the at least two video frames of the first video segment;
[0042] Frames are extracted from at least two video frames included in the second video segment, and the first frame of the second video segment is determined as the second video frame; the first frame represents a video frame at a starting position among the at least two video frames of the second video segment.
[0043] Here, both the first video segment and the second video segment include at least two video frames. When the video segment includes two video frames, the two video frames are the first frame and the last frame of the video segment (including the first video segment and the second video segment); when the video segment includes more than two video frames, the two or more video frames are the first frame, the middle frame and the last frame of the video segment (including the first video segment and the second video segment); wherein the first frame can be understood as a video frame at the starting position of at least two video frames, and the last frame can be understood as a video frame at the end position of at least two video frames. In the embodiment of the present application, the first video frame is the last frame obtained by frame extraction from the first video segment, and the second video frame is the first frame obtained by frame extraction from the second video segment.
[0044] Step 103: Determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame.
[0045] In actual applications, in order to improve the quality of optical flow estimation, the video processing device first downsamples the video frame when performing a rough optical flow estimation on the video frame, which can also be called downsampling, and then uses the optical flow estimation algorithm to perform optical flow estimation on the downsampled video frame to obtain the corresponding optical flow intensity.
[0046] Based on this, in one embodiment, determining a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame includes:
[0047] Performing spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame;
[0048] An optical flow estimation algorithm is used to estimate a first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and a second optical flow intensity from the downsampled second video frame to the downsampled first video frame.
[0049] Here, the video frame is downsampled, specifically, the video frame is downsampled in the spatial direction, that is, the first video frame and the second video frame are spatially downsampled, and the first video frame is taken as I 1 , the second video frame is I 2 For example, the spatial downsampling of the first video frame can be expressed as F s ↓ (I 1 ), the spatial downsampling of the second video frame can be expressed as F s ↓ (I 2 ), where F s ↓ () represents a spatial downsampling function; that is, in the embodiment of the present application, the spatial downsampling function can be used to perform spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame.
[0050] It should be noted that the multiple of spatial downsampling of the video frame, that is, the first multiple, can be set according to actual needs, for example, it can be set to 2 times, and the embodiment of the present application is not limited here.
[0051] Here, the optical flow estimation algorithm can adopt the LiteFlowNet3 method, wherein LiteFlowNet3 is a lightweight optical flow estimation method that uses adaptive priors and optical flow consistency constraints to solve the matching ambiguity problem and improve the quality of optical flow estimation. 1 , the second video frame is I 2 For example, assuming that the first optical flow intensity from the downsampled first video frame to the downsampled second video frame is f' 12 , the second optical flow intensity from the downsampled second video frame to the downsampled first video frame is f' 21 , then f' can be calculated by the following formula 12 and f' 21 :
[0052]
[0053]
[0054] Among them, F s ↓ (I 1 ) represents spatial downsampling of the first video frame; Fs ↓ (I 2 ) indicates that spatial downsampling of the second video frame is performed.
[0055] Step 104: Generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and a displacement factor; the displacement factor represents the position of the target intermediate video frame.
[0056] In actual application, in order to avoid the negative impact of outliers in optical flow estimation on the quality of target intermediate video frame generation, the embodiment of the present application performs optical flow estimation on the downsampled video frame to obtain the corresponding optical flow intensity, and upsamples the calculated optical flow intensity to the original resolution. It is also necessary to further perform Gaussian smoothing on the upsampled optical flow intensity to remove outliers in the optical flow estimation.
[0057] Based on this, in one embodiment, after estimating the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, the method further includes:
[0058] Performing spatial upsampling of a second multiple on the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and on the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, to obtain an upsampled first optical flow intensity and an upsampled second optical flow intensity; the first multiple matches the second multiple;
[0059] Gaussian smoothing is performed on the upsampled first optical flow intensity and the upsampled second optical flow intensity to obtain corresponding third optical flow intensity and fourth optical flow intensity.
[0060] Here, the purpose of spatially upsampling the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame is to restore the resolution of the first video frame and the resolution of the second video frame to the original resolution. Therefore, the multiple of spatial upsampling should be consistent with the multiple of spatial downsampling, that is, the first multiple matches the second multiple. In an embodiment of the present application, in order to eliminate outliers in the optical flow estimation, a Gaussian function can be used to smooth the optical flow prediction. Specifically, a Gaussian function is used to perform Gaussian smoothing on the upsampled first optical flow intensity and the upsampled second optical flow intensity to obtain the corresponding third optical flow intensity and fourth optical flow intensity.
[0061] Accordingly, in one embodiment, generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor includes:
[0062] A target intermediate video frame is generated based on the first video frame, the second video frame, the third optical flow intensity, the fourth optical flow intensity, and the displacement factor.
[0063] Here, the video processing device can smooth the upsampled first optical flow intensity and the upsampled second optical flow intensity through a Gaussian smoothing operation to obtain the corresponding third optical flow intensity and fourth optical flow intensity, that is, after removing the negative impact of outliers in the optical flow estimation on the generation quality of the target intermediate video frame, it can generate a target intermediate video frame based on the first video frame, the second video frame, the third optical flow intensity, the fourth optical flow intensity and the displacement factor, thereby improving the generation quality of the target intermediate video frame.
[0064] In actual application, after generating the target intermediate video frame, the video processing device may insert the target intermediate video frame between the first video frame and the second video frame to achieve a video splicing effect.
[0065] Based on this, in one embodiment, after generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor, the method further includes:
[0066] The target intermediate video frame is inserted between the first video frame and the second video frame based on the shift factor.
[0067] Here, since the displacement factor represents the position of the target intermediate video frame, the video processing device can insert the generated target intermediate video frame between the first video frame and the second video frame according to the position indicated by the displacement factor, thereby accurately achieving the video interpolation effect.
[0068] In actual application, the video processing device needs to determine the displacement factor before generating the target intermediate video frame.
[0069] Based on this, in one embodiment, before generating the target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and the displacement factor, the method further includes: determining the displacement factor.
[0070] However, the shift factor is related to the number of interpolated frames, that is, the number of video interpolated frames. Therefore, before determining the shift factor, the video processing device needs to first determine the number of video interpolated frames, and then determine the shift factor based on the number of video interpolated frames.
[0071] Based on this, in one embodiment, determining the displacement factor includes:
[0072] Determine the number of video interpolation frames;
[0073] The displacement factor is determined based on the number of video interpolation frames.
[0074] The video interpolation algorithm in the related art usually manually sets the number of interpolation frames based on the motion between the two video frames to be spliced. For the smooth video splicing task, on the one hand, manually setting the number of interpolation frames consumes a lot of human resources and it is difficult to ensure the adaptive interpolation effect of smooth video splicing. On the other hand, the existing video interpolation algorithm only considers the motion between the two video frames to be spliced, but does not consider the motion changes within the video clip to be spliced, so it is impossible to achieve smooth motion splicing between the two video clips. In order to solve the above technical problems, the embodiment of the present application proposes a method for determining the number of adaptive interpolation frames to achieve the effect of smooth motion splicing between two video clips.
[0075] In one embodiment, determining the number of video insertion frames includes:
[0076] Performing frame sampling on the first video segment and the second video segment to obtain corresponding third video segment and fourth video segment;
[0077] The number of video insertion frames is determined based on the optical flow estimation of the third video clip and the fourth video clip.
[0078] Here, frame sampling is performed on the first video segment and the second video segment, including temporal downsampling and spatial downsampling of both the first video segment and the second video segment; that is, the first video segment is frame sampled using the temporal downsampling function and the spatial downsampling function to obtain the corresponding third video segment, and the second video segment is frame sampled using the temporal downsampling function and the spatial downsampling function to obtain the corresponding fourth video segment.
[0079] In actual application, after the video processing device obtains the third video segment and the fourth video segment through frame sampling, it further performs optical flow estimation between adjacent frames in the two video segments, and performs optical flow estimation between the two video segments, thereby calculating the required number of interpolated frames, that is, the number of video interpolated frames, based on the motion differences within the third video segment and the fourth video segment and between the video segments. The determined number of adaptive interpolated frames can be used to achieve smooth motion splicing between the two video segments.
[0080] Based on this, in one embodiment, determining the number of video insertion frames based on the optical flow estimation of the third video clip and the fourth video clip includes:
[0081] Determine a first average optical flow intensity corresponding to the third video clip, and a second average optical flow intensity corresponding to the fourth video clip;
[0082] Determine a fifth optical flow intensity between the third video segment and the fourth video segment based on the last frame of the third video segment and the first frame of the fourth video segment;
[0083] The number of video interpolation frames is determined based on the first average optical flow intensity, the second average optical flow intensity, and the fifth optical flow intensity.
[0084] Here, the first average optical flow intensity and the second average optical flow intensity are used to represent the motion changes in the video segments to be spliced. In an embodiment of the present application, the video processing device first determines the optical flow set corresponding to the third video segment and the number of video frames in the third video segment, and then determines the first average optical flow intensity corresponding to the third video segment based on the optical flow set corresponding to the third video segment and the number of video frames in the third video segment; the video processing device first determines the optical flow set corresponding to the fourth video segment and the number of video frames in the fourth video segment, and then determines the second average optical flow intensity corresponding to the fourth video segment based on the optical flow set corresponding to the fourth video segment and the number of video frames in the fourth video segment.
[0085] Here, the fifth optical flow intensity is used to represent the motion change between the video segments to be spliced. In an embodiment of the present application, the video processing device uses an optical flow estimation algorithm to perform optical flow estimation between the last frame of the third video segment and the first frame of the fourth video segment to obtain the fifth optical flow intensity.
[0086] In actual application, the video processing device can generate a target intermediate video frame through a video frame generation module, wherein the input data of the video frame generation module is the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and the displacement factor. After obtaining the first candidate video frame and the second candidate video frame based on the input data, the target intermediate video frame is generated based on the iterative optimization and intermediate supervision of the first candidate video frame and the second candidate video frame, thereby realizing the generation of high-quality intermediate video frames at any position between the two video frames to be spliced.
[0087] Based on this, in one embodiment, generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor includes:
[0088] Determine a first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor;
[0089] Determine a second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor;
[0090] The target intermediate video frame is generated based on the first candidate video frame, the second candidate video frame and the fusion parameter.
[0091] The generation process of the target intermediate video frame is described in detail below.
[0092] In one embodiment, determining the first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor includes:
[0093] Performing a logical operation on the first optical flow intensity and the displacement factor to obtain a first target optical flow intensity;
[0094] An inverse transformation operation is performed on the first target optical flow intensity and the first video frame to obtain the first candidate video frame.
[0095] Here, performing a logical operation on the first optical flow intensity and the displacement factor can be understood as performing a product operation on the first optical flow intensity and the displacement factor to obtain a first target optical flow intensity. In practical applications, the first optical flow intensity can also be Gaussian smoothed to obtain a corresponding third optical flow intensity, and then the third optical flow intensity and the displacement factor are multiplied to obtain the first target optical flow intensity. After obtaining the first target optical flow intensity, the first video frame is mapped to the target position, i.e., the position indicated by the displacement factor, using an inverse transformation operation based on the first optical flow intensity or the third optical flow intensity, thereby obtaining an initial video frame prediction value corresponding to the target position, i.e., the first candidate video frame.
[0096] In one embodiment, determining the second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor includes:
[0097] Performing a logical operation on the second optical flow intensity and the displacement factor to obtain a second target optical flow intensity;
[0098] An inverse transformation operation is performed on the second target optical flow intensity and the second video frame to obtain the second candidate video frame.
[0099] Here, performing a logical operation on the second optical flow intensity and the displacement factor can be understood as performing a product operation on the second optical flow intensity and the displacement factor to obtain a second target optical flow intensity. In practical applications, the second optical flow intensity can also be first subjected to Gaussian smoothing to obtain a corresponding fourth optical flow intensity, and then the fourth optical flow intensity and the displacement factor are multiplied to obtain a second target optical flow intensity. After obtaining the second target optical flow intensity, the second video frame is mapped to the target position, i.e., the position indicated by the displacement factor, using an inverse transformation operation based on the second optical flow intensity or the fourth optical flow intensity, thereby obtaining the initial video frame prediction value corresponding to the target position, i.e., the second candidate video frame.
[0100] In practical applications, the first candidate video frame and the second candidate video frame are iteratively optimized and intermediately supervised to generate a target intermediate video frame, that is, to generate a high-quality intermediate video frame at any position between the two video frames to be spliced.
[0101] Based on this, in one embodiment, generating the target intermediate video frame based on the first candidate video frame, the second candidate video frame and the fusion parameter includes:
[0102] Inputting the first candidate video frame, the second candidate video frame, and the fusion parameters into a pre-trained target neural network to obtain a first output result of the target neural network; the first output result includes first residual information corresponding to the first candidate video frame, second residual information corresponding to the second candidate video frame, and third residual information corresponding to the fusion parameters;
[0103] Determine an optimized first candidate video frame, an optimized second candidate video frame, and an optimized fusion parameter based on the first residual information, the second residual information, and the third residual information;
[0104] The target intermediate video frame is generated based on the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters.
[0105] Here, the target neural network includes a convolutional neural network (CNN) in deep learning, wherein CNN can adopt any qualified network structure, and the embodiment of the present application does not limit the network structure of CNN. In practical applications, the video processing device further connects the input information, namely the first candidate video frame, the second candidate video frame, and the fusion parameter, and inputs them into the CNN network for residual prediction. The corresponding output result can be obtained through the CNN network, namely the residual information corresponding to each input information, specifically including the first residual information corresponding to the first candidate video frame, the second residual information corresponding to the second candidate video frame, and the third residual information corresponding to the fusion parameter. Among them, the fusion parameter is the initialization occlusion mask. The residual information is a three-channel image residual that can compensate for contextual details. For example, when the image texture of the reconstructed video frame is not sharp enough, the texture information is supplemented by the residual information, so that the image corresponding to the video frame is displayed more realistically. Furthermore, by adding the residual information corresponding to each input information and the input information before optimization, the optimized information can be obtained, including the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters. Next, the above-mentioned optimized information is input into the CNN network again for residual prediction, and the next optimization result can be obtained. The above process is repeated to continuously perform residual optimization on the first candidate video frame and the second candidate video frame until the number of iterations reaches the set threshold, and the iterative optimization process is stopped.
[0106] Based on this, in one embodiment, after determining the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters, the method further includes:
[0107] Inputting the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter into the target neural network to obtain a second output result of the target neural network; the second output result includes residual information corresponding to the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter respectively;
[0108] The process of iteratively executing the updating of the second output result continuously adjusts the parameters of the target neural network until the number of iterations reaches a set number threshold.
[0109] It should be noted that the setting number threshold can be set according to actual needs. For example, the setting number threshold K can be set to 3, and the embodiment of the present application does not limit this.
[0110] The embodiment of the present application also provides another video processing method, which is applied to a video processing device. Figure 2The video processing method of the present invention is shown in FIG. Figure 2 ;like Figure 2 As shown, the video processing method includes:
[0111] Step 201: Obtain a first video segment and a second video segment.
[0112] In an embodiment of the present application, the first video clip and the second video clip are different video clips in the same scene in the video to be spliced.
[0113] Step 202: Perform frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment.
[0114] In one embodiment, the performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment includes:
[0115] Extracting frames from at least two video frames included in the first video segment, and determining the last frame of the first video segment as the first video frame;
[0116] Frame extraction is performed from at least two video frames included in the second video segment, and a first frame of the second video segment is determined as the second video frame.
[0117] In an embodiment of the present application, the tail frame represents a video frame at the end position of at least two video frames of the first video segment, and the first frame represents a video frame at the start position of at least two video frames of the second video segment.
[0118] Step 203: Perform spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame.
[0119] Step 204: using an optical flow estimation algorithm, estimating a first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and a second optical flow intensity from the downsampled second video frame to the downsampled first video frame.
[0120] Step 205: Determine the number of video interpolation frames, and determine a displacement factor based on the number of video interpolation frames.
[0121] Step 206: Determine a first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor, and determine a second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor.
[0122] Step 207: input the first candidate video frame, the second candidate video frame, and the fusion parameters into a pre-trained target neural network to obtain a first output result of the target neural network.
[0123] In an embodiment of the present application, the first output result includes first residual information corresponding to the first candidate video frame, second residual information corresponding to the second candidate video frame, and third residual information corresponding to the fusion parameter.
[0124] Step 208: Determine an optimized first candidate video frame, an optimized second candidate video frame, and optimized fusion parameters based on the first residual information, the second residual information, and the third residual information.
[0125] Step 209: Generate a target intermediate video frame based on the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters.
[0126] It should be noted that the specific process of the video processing device completing the video processing has been described in detail above and will not be repeated here.
[0127] By adopting the technical solution of the embodiment of the present application, a rough optical flow estimation is performed on the optical flow intensity between different video frames, thereby generating a target intermediate video frame based on the roughly estimated optical flow intensity and the video frame to be spliced. In other words, by shifting the focus of the video interpolation task from accurate optical flow estimation to the final task, namely, the generation of intermediate video frames, the impact of the optical flow estimation performance limitation on the interpolation performance is alleviated, and the generation quality of the intermediate video frames is improved, thereby avoiding the excessive dependence of the intermediate video frame generation quality on the optical flow estimation performance. The embodiment of the present application also proposes a method for determining the number of adaptive interpolation frames by considering the motion between two video frames to be spliced and the motion changes within two video clips to be spliced, so as to achieve smooth motion splicing between two video clips.
[0128] The present application is described below in conjunction with application examples.
[0129] The technical problems to be solved by this application include the following two points:
[0130] 1) How to improve the performance of video interpolation to alleviate the impact of optical flow estimation performance limitations on video interpolation performance and improve the quality of intermediate video frame generation;
[0131] 2) For the video stitching task, how to adaptively determine the number of video interpolation frames to achieve smooth motion stitching between two video clips.
[0132] In view of the above problems existing in the related art, the present application proposes an adaptive frame insertion method for smooth video splicing, namely the aforementioned video processing method. Figure 3 The video processing method of the present invention is shown in FIG. Figure 3 , the method mainly includes three modules: determining the number of inserted frames, rough estimation of optical flow, and generation of video frames. In the module for determining the number of inserted frames, the present application proposes an adaptive method for determining the number of inserted frames based on the motion changes within and between the videos to be spliced; in the module for rough estimation of optical flow, in order to reduce the computational burden of motion estimation, the present application performs real-time optical flow estimation and Gaussian smoothing on the downsampled video frames to be spliced, and uses them to initialize the video frame generation module; in the video frame generation module, the present application proposes a bidirectional iterative video frame generation method, which continuously improves the quality of video frame generation based on multiple iterative optimizations and intermediate supervision. The following is combined with Figure 3 , and the above three modules are introduced in detail respectively.
[0133] 1. Insertion frame number determination module
[0134] For the splicing of two different video clips of the same scene (such as video clip 1 (corresponding to the first video clip mentioned above) and video clip 2 (corresponding to the second video clip mentioned above)), in order to achieve a smooth splicing effect, video interpolation is usually performed between the last frame of the video clip 1 to be spliced and the first frame of the video clip 2 to be spliced to slow down the splicing jump.
[0135] In the related art, the number of interpolation frames (corresponding to the aforementioned number of video interpolation frames) is usually manually set based on the motion between two video frames to be spliced. However, the manual setting method usually consumes a lot of human resources and may not guarantee a smooth splicing effect. On the other hand, this manual setting method does not take into account the motion changes within the video segments to be spliced, and cannot achieve smooth motion video splicing. In response to this technical problem, the present application proposes an adaptive interpolation frame number calculation method, which calculates the required number of interpolation frames based on the motion differences within the input video segments and between video segments to achieve a smooth and natural video splicing effect.
[0136] Figure 4 FIG. 1 is a flow chart of a method for determining the number of interpolation frames according to an embodiment of the present application. Figure 4 As shown, for the two input video clips, namely video clip 1 and video clip 2, the two video clips are firstly frame sampled respectively, and then the optical flow estimation within the two video clips and the optical flow estimation between the two video clips are calculated respectively based on the results of the frame sampling, and finally, the number of interpolated frames is calculated based on the aforementioned two optical flow estimation results.
[0137] The process of determining the number of interpolation frames is described in detail below.
[0138] The frame sampling of video clip 1 and video clip 2 can be obtained by the following formula (3):
[0139]
[0140] Among them, V i is a video segment, i is 1 or 2, indicating video segment 1 and video segment 2; F t ↓ () and F s ↓ () are temporal downsampling function and spatial downsampling function respectively. Tru() is a truncation function, which only retains t frames of video frames after temporal downsampling. Video segment 1 is truncated from the last frame, and video segment 2 is truncated from the first frame. That is, for V 1 For example, assuming F t ↓ () The number of video frames after downsampling is T 1 , then the Tru() function only retains (T 1 -t:T 1 ] interval video frame, for V 2 For example, assuming F t ↓ () The number of video frames after downsampling is T 2 , then the Tru() function only retains the video frames in the interval [0:t). In the experiment, t=6 can be set, F t ↓ () is 4 times downsampling in the time direction, F s ↓ () is 2 times downsampling in the spatial direction.
[0141] After frame sampling, the video segment v is obtained 1 and v 2 After that, the optical flow between adjacent frames is further estimated in two video clips to obtain v 1 and v 2 The corresponding optical flow sets are expressed as and The average optical flow intensity value f in the two video clips is calculated by the following formula (4): 1 and f 2 :
[0142]
[0143] Among them, f 1 The video segment v obtained by frame sampling 1 The corresponding average optical flow intensity value, f 2 The video segment v obtained by frame sampling 2 The corresponding average optical flow intensity value, t is the video clip v 1 and v 2The number of video frames in, i is v 1 and v 2 The number of optical flows in the corresponding optical flow set.
[0144] At the same time, for the video clip v 1 The last frame and video segment v 2 The optical flow between the two video clips is estimated by taking the first frame of the video clip as the first frame, and the optical flow intensity f is obtained. 12 The number of interpolated frames can be calculated using the following formula (5):
[0145]
[0146] Among them, N t represents the number of interpolated frames, t represents the displacement factor, and is the position of the video frame to be generated, with a value of (0, 1). 12 Represents a video clip v 1 The last frame and video segment v 2 The optical flow intensity value between the first frames, f 1 The video segment v obtained by frame sampling 1 The corresponding average optical flow intensity value, f 2 The video segment v obtained by frame sampling 2 The corresponding average optical flow intensity value; 4 means f 1 and f 2 is the optical flow intensity after 4 times time downsampling, and f 12 The optical flow intensity between the first and last frames is not downsampled in the time direction, and the two are 4 times the relationship between them.
[0147] 2. Optical flow rough estimation module
[0148] In the present application, the optical flow rough estimation module can use the LiteFlowNet3 method to perform optical flow estimation, wherein LiteFlowNet3 is a lightweight optical flow estimation method that uses adaptive priors and optical flow consistency constraints to solve the matching ambiguity problem and improve the quality of optical flow estimation.
[0149] In the module for determining the number of inserted frames, the same method is used to estimate the optical flow. This application can use any optical flow estimation algorithm, and only the LiteFlowNet3 algorithm is used as an example in the experiment. Figure 3 As shown, the input of the optical flow rough estimation module is the last frame V of video clip 1 1 [-1] (corresponding to the first video frame mentioned above) and the first frame V of video segment 2 2 [0] (corresponding to the aforementioned second video frame), wherein the first video frame is defined as video frame 1 (I 1 ), the second video frame is defined as video frame 2 (I 2Specifically, when the optical flow rough estimation module performs the optical flow rough estimation, it first performs the rough estimation of the video frame I i Downsample by 2 in the spatial direction, and then use the LiteFlowNet3 method to estimate I respectively using the above formulas (1) and (2) 1 To I 2 The optical flow intensity f' 12 and I 2 To I 1 The optical flow intensity f' 21 .
[0150] In this application, in order to avoid the negative impact of outliers in optical flow estimation on the generation of intermediate video frames, the calculated optical flow intensity f' 12 and f' 21 After upsampling to the original resolution, the Gaussian function G() is used to smooth the optical flow prediction. The final output of the optical flow rough estimation module can be obtained as f” through the following formulas (6) and (7): 12 and f" 21 :
[0151]
[0152]
[0153] Among them, f” 12 is the optical flow intensity f' after upsampling 12 The third optical flow intensity obtained by Gaussian smoothing, f" 21 is the optical flow intensity f' after upsampling 21 The fourth optical flow intensity is obtained by Gaussian smoothing, where G() represents a Gaussian function.
[0154] 3. Video frame generation module
[0155] Figure 5 Schematic diagram of the process of generating the target intermediate video frame according to an embodiment of the present application. Figure 5 As shown, the input of the video frame generation module is the last frame I of the video segment 1 1 , the first frame I of video clip 2 2 , the optical flow rough estimation module outputs I 1 To I 2 The optical flow intensity f' 12 ,I 2 To I 1 The optical flow intensity f' 21 And the displacement factor t, where the displacement factor t represents the position of the video frame to be generated, and takes a value of (0, 1). The displacement factor t can be obtained by the following formula (8):
[0156]
[0157] Among them, N t is the number of interpolation frames calculated by the above formula 5, where i is an integer.
[0158] like Figure 5 As shown, in the present application, the video frame generation module first uses the reverse warp operation (corresponding to the aforementioned reverse transformation operation) according to the optical flow intensity f" 12 and f" 21 I 1 and I 2 Map to the target position t and get the initial video frame prediction corresponding to the target position and Specifically, it can be obtained by the following formulas (9) and (10):
[0159]
[0160]
[0161] in, represents the first candidate video frame, Represents the second candidate video frame, IW() represents the inverse warp operation, that is, the inverse transformation operation, which can be implemented differently through the torch.nn.functional.grid_sample() function.
[0162] In getting and After that, initialize the occlusion mask M 0 (corresponding to the aforementioned fusion parameters) is a full 1 feature map with the same dimension as is consistent, which is 3*H*W (where 3, H, and W represent the three channels (RGB), height, and width of the image, respectively), and and The concatenated data are then fed into a CNN network (corresponding to the aforementioned target neural network) for residual prediction. The CNN network can use any network structure that meets the requirements. In the experiment, this application only uses an hourglass network as an example.
[0163] Here, the output of the CNN network is and M 0 The corresponding residual information (corresponding to the aforementioned first residual information), (corresponding to the aforementioned second residual information) and r M (corresponding to the third residual information mentioned above). r M and before optimization and M 0By adding them separately, we can get an optimized I 1→t (corresponding to the aforementioned optimized first candidate video frame), I 2→t (corresponding to the aforementioned optimized second candidate video frame) and M (corresponding to the aforementioned optimized fusion parameter); Next, the optimized I 1→t ,I 2→t It is further connected to M and sent to the parameter-sharing CNN network for residual prediction again, and the next optimization result can be obtained. The above process is repeated, and residual optimization is continuously performed until the specified number of iterations K (corresponding to the aforementioned set number threshold).
[0164] Here, for each optimization, the optimized I 1→t ,I 2→t and M, the video frame I corresponding to position t can be calculated by the following formula (11): t :
[0165] I t =M·I 1→t +(1-M)I 2→t (11)
[0167] During CNN network training, the inserted video frame position t is randomly selected and the I generated by each optimization is t Perform intermediate supervision. The training loss function can be expressed by the following formula (12):
[0168]
[0169] In this application, it is assumed that the number of iterative optimizations is 3, and the corresponding loss weight a k are 0.5, 0.7 and 1.0 respectively. mse is the mean square error function. During inference, the number of interpolation frames N calculated by the module is determined based on the number of interpolation frames t Calculate the position factors {t} corresponding to all the positions that need to be inserted, and perform the rough optical flow estimation and video frame generation module calculations to generate all the intermediate video frames that need to be generated. Finally, based on the intermediate video frames, the video segments 1 to be spliced and the video segments 2 to be spliced are spliced in sequence, so that a smooth video splicing effect can be achieved.
[0170] Compared with the methods of related technologies, this application has the following beneficial effects:
[0171] (1) The method for determining the number of adaptive interpolation frames proposed in the present application can adaptively determine the number of interpolation frames based on the motion differences within and between the video segments to be spliced, thereby reducing the resource consumption and uncertainty of manual settings and achieving a smooth motion splicing effect.
[0172] (2) This application proposes a rough optical flow estimation based on spatial downsampling and Gaussian smoothing, and a video frame generation method based on iterative optimization and intermediate supervision. By shifting the computational focus from motion estimation to the final target intermediate video frame generation, the quality of intermediate video frame generation is improved, and the excessive dependence of video frame generation quality on optical flow estimation performance is avoided. In addition, the negative impact of outliers in optical flow estimation on the quality of intermediate video frame generation can be reduced through Gaussian smoothing.
[0173] (3) This application can achieve adaptive and smoother video splicing effects. The solution is simple to implement, has universality and flexibility, and has a very broad application prospect.
[0174] In order to implement the video processing method of the embodiment of the present application, the embodiment of the present application also provides a video processing device, Figure 6 FIG. 1 is a schematic diagram of the composition structure of the video processing device according to an embodiment of the present application. Figure 6 As shown, the video processing device includes:
[0175] An acquisition unit 61 is configured to acquire a first video segment and a second video segment; the first video segment and the second video segment are different video segments in the same scene in the video to be spliced;
[0176] An extraction unit 62, configured to perform frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment;
[0177] A first determining unit 63, configured to determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame;
[0178] The generating unit 64 is configured to generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and a displacement factor; the displacement factor represents a position of the target intermediate video frame.
[0179] In one embodiment, the extraction unit 62 is specifically used for:
[0180] Extracting frames from at least two video frames included in the first video segment, and determining the last frame of the first video segment as the first video frame; the last frame represents a video frame at the last position of the at least two video frames of the first video segment;
[0181] Frames are extracted from at least two video frames included in the second video segment, and the first frame of the second video segment is determined as the second video frame; the first frame represents a video frame at a starting position among the at least two video frames of the second video segment.
[0182] In one embodiment, the first determining unit 63 is specifically configured to:
[0183] Performing spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame;
[0184] An optical flow estimation algorithm is used to estimate a first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and a second optical flow intensity from the downsampled second video frame to the downsampled first video frame.
[0185] In one embodiment, the video processing device further includes: an up-sampling unit and a smoothing processing unit; wherein,
[0186] The upsampling unit is used for performing spatial upsampling of the first optical flow intensity from the downsampled first video frame to the downsampled second video frame and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame by a second multiple after the first determining unit 63 estimates the first optical flow intensity from the downsampled first video frame to the downsampled second video frame and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, so as to obtain the upsampled first optical flow intensity and the upsampled second optical flow intensity; the first multiple matches the second multiple;
[0187] The smoothing processing unit is used to perform Gaussian smoothing on the upsampled first optical flow intensity and the upsampled second optical flow intensity to obtain corresponding third optical flow intensity and fourth optical flow intensity;
[0188] Accordingly, the generating unit 64 is specifically configured to:
[0189] A target intermediate video frame is generated based on the first video frame, the second video frame, the third optical flow intensity, the fourth optical flow intensity, and the displacement factor.
[0190] In one embodiment, the video processing device further includes: a second determining unit; wherein,
[0191] The second determination unit is used to determine the displacement factor before the generation unit 64 generates a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor.
[0192] In one embodiment, the second determining unit includes a first determining subunit and a second determining subunit; wherein,
[0193] The first determining subunit is used to determine the number of video insertion frames;
[0194] The second determining subunit is used to determine the displacement factor based on the number of video interpolation frames.
[0195] In one embodiment, the first determining subunit includes a frame sampling subunit and a third determining subunit; wherein,
[0196] The frame sampling subunit is used to perform frame sampling on the first video segment and the second video segment to obtain a corresponding third video segment and a fourth video segment;
[0197] The third determination subunit is used to determine the number of video insertion frames based on the optical flow estimation of the third video clip and the fourth video clip.
[0198] In one embodiment, the third determining subunit is specifically configured to:
[0199] Determine a first average optical flow intensity corresponding to the third video clip, and a second average optical flow intensity corresponding to the fourth video clip;
[0200] Determine a fifth optical flow intensity between the third video segment and the fourth video segment based on the last frame of the third video segment and the first frame of the fourth video segment;
[0201] The number of video interpolation frames is determined based on the first average optical flow intensity, the second average optical flow intensity, and the fifth optical flow intensity.
[0202] In one embodiment, the generating unit 64 includes a fourth determining subunit, a fifth determining subunit and a first generating subunit; wherein,
[0203] The fourth determining subunit is used to determine a first candidate video frame based on the first video frame, the first optical flow intensity and the displacement factor;
[0204] The fifth determining subunit is used to determine a second candidate video frame based on the second video frame, the second optical flow intensity and the displacement factor;
[0205] The first generating subunit is used to generate the target intermediate video frame based on the first candidate video frame, the second candidate video frame and a fusion parameter.
[0206] In one embodiment, the fourth determining subunit is specifically configured to:
[0207] Performing a logical operation on the first optical flow intensity and the displacement factor to obtain a first target optical flow intensity;
[0208] Performing an inverse transformation operation on the first target optical flow intensity and the first video frame to obtain the first candidate video frame;
[0209] In one embodiment, the fifth determining subunit is specifically configured to:
[0210] Performing a logical operation on the second optical flow intensity and the displacement factor to obtain a second target optical flow intensity;
[0211] An inverse transformation operation is performed on the second target optical flow intensity and the second video frame to obtain the second candidate video frame.
[0212] In one embodiment, the first generating subunit includes a first input subunit, a sixth determining subunit and a second generating subunit; wherein,
[0213] The first input subunit is used to input the first candidate video frame, the second candidate video frame, and the fusion parameter into a pre-trained target neural network to obtain a first output result of the target neural network; the first output result includes first residual information corresponding to the first candidate video frame, second residual information corresponding to the second candidate video frame, and third residual information corresponding to the fusion parameter;
[0214] The sixth determining subunit is used to determine an optimized first candidate video frame, an optimized second candidate video frame, and an optimized fusion parameter based on the first residual information, the second residual information, and the third residual information;
[0215] The second generating subunit is used to generate the target intermediate video frame based on the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters.
[0216] In one embodiment, the video processing device further includes: a second input subunit and an updating unit; wherein,
[0217] The second input subunit is used to input the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter into the target neural network after the sixth determination subunit determines the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter, so as to obtain a second output result of the target neural network; the second output result includes residual information corresponding to the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter respectively;
[0218] The updating unit is used to iteratively execute the process of updating the second output result, and continuously adjust the parameters of the target neural network until the number of iterations reaches a set number threshold.
[0219] In one embodiment, the video processing device further includes: an inserting unit; wherein,
[0220] The insertion unit is used to insert the target intermediate video frame between the first video frame and the second video frame based on the displacement factor after the generation unit 64 generates the target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and the displacement factor.
[0221] In actual application, the acquisition unit 61 may be implemented by a communication interface in the video processing device; the extraction unit 62, the first determination unit 63 and the generation unit 64 may be implemented by a processor in the video processing device.
[0222] It should be noted that: when the video processing device provided in the above embodiment performs video processing, only the division of the above program modules is used as an example. In actual application, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the video processing device provided in the above embodiment and the video processing method embodiment belong to the same concept. The specific implementation process is detailed in the video processing method embodiment, which will not be repeated here.
[0223] Based on the hardware implementation of the above program modules, and in order to implement the video processing method of the embodiment of the present application, the embodiment of the present application also provides a video processing device, Figure 7 FIG. 1 is a schematic diagram of the hardware structure of the video processing device according to an embodiment of the present application. Figure 7 As shown, the video processing device 70 includes:
[0224] Communication interface 71, capable of exchanging information with other devices;
[0225] The processor 72 is connected to the communication interface 71 to implement information interaction with other devices and is used to execute the above-mentioned video processing method when running a computer program, and the computer program is stored in the memory 73.
[0226] Specifically, the communication interface 71 is used to obtain a first video segment and a second video segment; the first video segment and the second video segment are different video segments in the same scene in the video to be spliced;
[0227] The processor 72 is used to perform frame extraction on the first video clip and the second video clip to obtain a first video frame corresponding to the first video clip and a second video frame corresponding to the second video clip; determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame; generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and a displacement factor; the displacement factor represents the position of the target intermediate video frame.
[0228] In one embodiment, the processor 72 is specifically configured to:
[0229] Extracting frames from at least two video frames included in the first video segment, and determining the last frame of the first video segment as the first video frame; the last frame represents a video frame at the last position of the at least two video frames of the first video segment;
[0230] Frames are extracted from at least two video frames included in the second video segment, and the first frame of the second video segment is determined as the second video frame; the first frame represents a video frame at a starting position among the at least two video frames of the second video segment.
[0231] In one embodiment, the processor 72 is further specifically configured to:
[0232] Performing spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame;
[0233] An optical flow estimation algorithm is used to estimate a first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and a second optical flow intensity from the downsampled second video frame to the downsampled first video frame.
[0234] In one embodiment, the processor 72 is further configured to:
[0235] After estimating the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, spatially upsampling the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame by a second multiple, to obtain the upsampled first optical flow intensity and the upsampled second optical flow intensity; the first multiple matches the second multiple;
[0236] Performing Gaussian smoothing on the upsampled first optical flow intensity and the upsampled second optical flow intensity to obtain corresponding third optical flow intensity and fourth optical flow intensity;
[0237] Accordingly, the processor 72 is specifically configured to:
[0238] A target intermediate video frame is generated based on the first video frame, the second video frame, the third optical flow intensity, the fourth optical flow intensity, and the displacement factor.
[0239] In one embodiment, the processor 72 is further configured to determine the displacement factor before generating the target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor.
[0240] In one embodiment, the processor 72 is specifically configured to:
[0241] Determine the number of video interpolation frames;
[0242] The displacement factor is determined based on the number of video interpolation frames.
[0243] In one embodiment, the processor 72 is specifically configured to:
[0244] Performing frame sampling on the first video segment and the second video segment to obtain corresponding third video segment and fourth video segment;
[0245] The number of video insertion frames is determined based on the optical flow estimation of the third video clip and the fourth video clip.
[0246] In one embodiment, the processor 72 is specifically configured to:
[0247] Determine a first average optical flow intensity corresponding to the third video clip, and a second average optical flow intensity corresponding to the fourth video clip;
[0248] Determine a fifth optical flow intensity between the third video segment and the fourth video segment based on the last frame of the third video segment and the first frame of the fourth video segment;
[0249] The number of video interpolation frames is determined based on the first average optical flow intensity, the second average optical flow intensity, and the fifth optical flow intensity.
[0250] In one embodiment, the processor 72 is further specifically configured to:
[0251] Determine a first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor;
[0252] Determine a second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor;
[0253] The target intermediate video frame is generated based on the first candidate video frame, the second candidate video frame and the fusion parameter.
[0254] In one embodiment, the processor 72 is specifically configured to:
[0255] Performing a logical operation on the first optical flow intensity and the displacement factor to obtain a first target optical flow intensity;
[0256] An inverse transformation operation is performed on the first target optical flow intensity and the first video frame to obtain the first candidate video frame.
[0257] In one embodiment, the processor 72 is specifically configured to:
[0258] Performing a logical operation on the second optical flow intensity and the displacement factor to obtain a second target optical flow intensity;
[0259] An inverse transformation operation is performed on the second target optical flow intensity and the second video frame to obtain the second candidate video frame.
[0260] In one embodiment, the processor 72 is further specifically configured to:
[0261] Inputting the first candidate video frame, the second candidate video frame, and the fusion parameters into a pre-trained target neural network to obtain a first output result of the target neural network; the first output result includes first residual information corresponding to the first candidate video frame, second residual information corresponding to the second candidate video frame, and third residual information corresponding to the fusion parameters;
[0262] Determine an optimized first candidate video frame, an optimized second candidate video frame, and an optimized fusion parameter based on the first residual information, the second residual information, and the third residual information;
[0263] The target intermediate video frame is generated based on the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters.
[0264] In one embodiment, the processor 72 is further configured to:
[0265] After determining the optimized first candidate video frame, the optimized second candidate video frame, and the optimized fusion parameters, the optimized first candidate video frame, the optimized second candidate video frame, and the optimized fusion parameters are input into the target neural network to obtain a second output result of the target neural network; the second output result includes residual information corresponding to the optimized first candidate video frame, the optimized second candidate video frame, and the optimized fusion parameters, respectively;
[0266] The process of iteratively executing the updating of the second output result continuously adjusts the parameters of the target neural network until the number of iterations reaches a set number threshold.
[0267] In one embodiment, the processor 72 is further configured to:
[0268] After generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and the displacement factor, the target intermediate video frame is inserted between the first video frame and the second video frame based on the displacement factor.
[0269] It should be noted that the specific processing process of the communication interface 71 and the processor 72 can be understood by referring to the above-mentioned video processing method.
[0270] Of course, in actual application, the various components in the video processing device 70 are coupled together through the bus system 74. It is understandable that the bus system 74 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 74 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus system 74 .
[0271] The memory 73 in the embodiment of the present application is used to store various types of data to support the operation of the video processing device 70. Examples of such data include: any computer program used to operate on the video processing device 70.
[0272] The video processing method disclosed in the above embodiment of the present application can be applied to the processor 72, or implemented by the processor 72. The processor 72 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above video processing method can be completed by the hardware integrated logic circuit or software instructions in the processor 72. The above processor 72 may be a general processor, a digital signal processor (DSP, DigitalSignal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 72 can implement or execute the various video processing methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the video processing method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 73, and the processor 72 reads the information in the memory 73 and completes the steps of the aforementioned video processing method in combination with its hardware.
[0273] In an exemplary embodiment, the video processing device 70 can be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned video processing method.
[0274] It can be understood that the memory 73 of the embodiment of the present application can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 73 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.
[0275] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 73 storing a computer program, and the computer program can be executed by a processor 72 in a video processing device 70 to complete the steps of the video processing method described in the above embodiment of the present application. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0276] It should be noted that: "first", "second", "third", etc. are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0277] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0278] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A video processing method, It is characterized in that The method comprises: Acquire a first video clip and a second video clip; the first video clip and the second video clip are different video clips in the same scene in the video to be spliced; Performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment; Determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame; A target intermediate video frame is generated based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and a displacement factor; the displacement factor represents a position of the target intermediate video frame.
2. The method according to claim 1, It is characterized in that The performing frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment includes: Extracting frames from at least two video frames included in the first video segment, and determining the last frame of the first video segment as the first video frame; the last frame represents a video frame at the last position of the at least two video frames of the first video segment; Frames are extracted from at least two video frames included in the second video segment, and the first frame of the second video segment is determined as the second video frame; the first frame represents a video frame at a starting position among the at least two video frames of the second video segment.
3. The method according to claim 1, It is characterized in that The determining of a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame, comprises: Performing spatial downsampling of the first video frame and the second video frame by a first multiple to obtain a downsampled first video frame and a downsampled second video frame; An optical flow estimation algorithm is used to estimate a first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and a second optical flow intensity from the downsampled second video frame to the downsampled first video frame.
4. The method according to claim 3, It is characterized in that After estimating the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, the method further includes: Performing spatial upsampling of a second multiple on the first optical flow intensity from the downsampled first video frame to the downsampled second video frame, and on the second optical flow intensity from the downsampled second video frame to the downsampled first video frame, to obtain an upsampled first optical flow intensity and an upsampled second optical flow intensity; the first multiple matches the second multiple; Performing Gaussian smoothing on the upsampled first optical flow intensity and the upsampled second optical flow intensity to obtain corresponding third optical flow intensity and fourth optical flow intensity; Generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and a displacement factor, including: A target intermediate video frame is generated based on the first video frame, the second video frame, the third optical flow intensity, the fourth optical flow intensity, and the displacement factor.
5. The method according to claim 1, It is characterized in that Before generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor, the method further includes: determining the displacement factor; The determining of the displacement factor comprises: Determine the number of video interpolation frames; The displacement factor is determined based on the number of video interpolation frames.
6. The method according to claim 5, It is characterized in that The determining the number of video insertion frames includes: Performing frame sampling on the first video segment and the second video segment to obtain corresponding third video segment and fourth video segment; The number of video insertion frames is determined based on the optical flow estimation of the third video clip and the fourth video clip.
7. The method according to claim 6, It is characterized in that The determining the number of video insertion frames based on the optical flow estimation of the third video segment and the fourth video segment includes: Determine a first average optical flow intensity corresponding to the third video clip, and a second average optical flow intensity corresponding to the fourth video clip; Determine a fifth optical flow intensity between the third video segment and the fourth video segment based on the last frame of the third video segment and the first frame of the fourth video segment; The number of video interpolation frames is determined based on the first average optical flow intensity, the second average optical flow intensity, and the fifth optical flow intensity.
8. The method according to claim 1, It is characterized in that The generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor includes: Determine a first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor; Determine a second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor; The target intermediate video frame is generated based on the first candidate video frame, the second candidate video frame and the fusion parameter.
9. The method according to claim 8, It is characterized in that The determining a first candidate video frame based on the first video frame, the first optical flow intensity, and the displacement factor includes: Performing a logical operation on the first optical flow intensity and the displacement factor to obtain a first target optical flow intensity; Performing an inverse transformation operation on the first target optical flow intensity and the first video frame to obtain the first candidate video frame; The determining a second candidate video frame based on the second video frame, the second optical flow intensity, and the displacement factor includes: Performing a logical operation on the second optical flow intensity and the displacement factor to obtain a second target optical flow intensity; An inverse transformation operation is performed on the second target optical flow intensity and the second video frame to obtain the second candidate video frame.
10. The method according to claim 8, It is characterized in that The generating the target intermediate video frame based on the first candidate video frame, the second candidate video frame and the fusion parameter includes: Inputting the first candidate video frame, the second candidate video frame, and the fusion parameters into a pre-trained target neural network to obtain a first output result of the target neural network; the first output result includes first residual information corresponding to the first candidate video frame, second residual information corresponding to the second candidate video frame, and third residual information corresponding to the fusion parameters; Determine an optimized first candidate video frame, an optimized second candidate video frame, and an optimized fusion parameter based on the first residual information, the second residual information, and the third residual information; The target intermediate video frame is generated based on the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameters.
11. The method according to claim 10, It is characterized in that After determining the optimized first candidate video frame, the optimized second candidate video frame, and the optimized fusion parameters, the method further includes: Inputting the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter into the target neural network to obtain a second output result of the target neural network; the second output result includes residual information corresponding to the optimized first candidate video frame, the optimized second candidate video frame and the optimized fusion parameter respectively; The process of iteratively executing the updating of the second output result continuously adjusts the parameters of the target neural network until the number of iterations reaches a set number threshold.
12. The method according to claim 1, It is characterized in that After generating a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity, and the displacement factor, the method further includes: The target intermediate video frame is inserted between the first video frame and the second video frame based on the shift factor.
13. A video processing device, It is characterized in that include: An acquisition unit, configured to acquire a first video segment and a second video segment; the first video segment and the second video segment are different video segments in the same scene in the video to be spliced; an extraction unit, configured to perform frame extraction on the first video segment and the second video segment to obtain a first video frame corresponding to the first video segment and a second video frame corresponding to the second video segment; A first determining unit, configured to determine a first optical flow intensity from the first video frame to the second video frame, and a second optical flow intensity from the second video frame to the first video frame; A generating unit is used to generate a target intermediate video frame based on the first video frame, the second video frame, the first optical flow intensity, the second optical flow intensity and a displacement factor; the displacement factor represents the position of the target intermediate video frame.
14. A video processing device, It is characterized in that include: a processor and a memory for storing a computer program capable of running on said processor; Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
