Video transition method, device, electronic device and computer-readable storage medium

By using preset texture coordinate system and fusion algorithm in video transitions, the transition effect problem with different video sizes is solved, and a better transition effect is achieved.

CN114331938BActive Publication Date: 2025-08-22MIGU CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111628124.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-08-22
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

In the prior art, the video transition effect is poor, especially when the front and back video sizes are different, and the transition effect is poor through stretching, scaling or cropping.

Method used

The image frames to be processed are mapped to the preset canvas area through the preset texture coordinate system, the texture image is restored and transparent pixel points are filled according to the frame properties, and the image frames to be fused of the same size as the preset canvas area are generated, and the transition video frames are fused through the preset fusion algorithm.

Benefits of technology

Improve the transition effect between videos of different sizes, avoid stretching, scaling or cropping, and improve the transition quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114331938B_ABST
    Figure CN114331938B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention relate to the field of video processing technology, and disclose a video transition method, device, electronic device, and computer-readable storage medium. The method includes: obtaining an image frame to be processed corresponding to a target transition video; mapping the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, and filling transparent pixels outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; fusing the image frame to be fused through a preset fusion algorithm to generate a transition video frame. In the above manner, the embodiments of the present invention improve the transition effect of video transition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of video processing technology, and in particular to a video transition method, device, electronic device, and computer-readable storage medium. Background Art

[0002] With the increasing popularity of video applications, the demand for video editing is increasing. Adding transitions to videos is a common video editing method that can make video playback more natural, thereby improving the user's viewing experience.

[0003] In the related art, adding transitions to videos requires ensuring that the sizes of the preceding and following videos are the same. If the sizes of the preceding and following videos are different, the size of one video is usually used as the target size, and the size of the other video is stretched or scaled to the target size; or the size of one video is used as the target size, and the size of the other video is cropped to the target size. However, in the process of implementing the embodiments of the present invention, the inventors found that the related art method of adding transitions to the preceding and following videos by stretching, scaling, or cropping the preceding and following videos results in poor transition effects. Summary of the Invention

[0004] In view of the above problems, embodiments of the present invention provide a video transition method, device, electronic device, and computer-readable storage medium to solve the problem of poor video transition effect in the prior art.

[0005] According to one aspect of an embodiment of the present invention, a video transition method is provided, the method comprising:

[0006] Obtain the image frame to be processed corresponding to the target transition video;

[0007] Mapping the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed;

[0008] Restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, and filling transparent pixels outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area;

[0009] The image frames to be fused are fused using a preset fusion algorithm to generate a transition video frame.

[0010] In an optional manner, the target transition video includes a preceding video and a succeeding video with different video sizes, and obtaining the image frame to be processed corresponding to the target transition video includes:

[0011] Respectively obtaining transition information of the preceding video and the succeeding video;

[0012] Determine the current transition frame of the preceding video according to the transition information of the preceding video and the current transition progress;

[0013] Determine the current transition frame of the subsequent video according to the transition information of the subsequent video and the current transition progress;

[0014] The current transition frame of the preceding video and the current transition frame of the succeeding video are determined as the image frames to be processed corresponding to the target transition video.

[0015] In an optional manner, the method further includes:

[0016] Flip the initial texture coordinate system so that the flipped texture coordinate system has the upper left point as the origin, the downward direction as the positive direction of the Y axis, and the rightward direction as the positive direction of the X axis;

[0017] Obtaining size information of the preview window, and adjusting the flipped texture coordinate system to coincide with the preview window coordinate system according to the size information;

[0018] The adjusted texture coordinate system is determined as the preset texture coordinate system.

[0019] In an optional manner, the restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed includes:

[0020] Determining a displacement scaling matrix and a rotation matrix corresponding to the image frame to be processed according to a frame attribute of the image frame to be processed;

[0021] Performing displacement and scaling transformation on the corresponding texture image within the preset canvas area using the displacement and scaling matrix;

[0022] The texture image after the displacement and scaling transformation is rotated using the rotation matrix, and the texture image after the rotation transformation is determined as the restored texture image.

[0023] In an optional manner, the method further includes:

[0024] Before performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a first aspect ratio processing on the texture image after the displacement and scaling transformation;

[0025] After performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a second aspect ratio processing on the texture image after the rotation transformation;

[0026] The texture image after the second aspect ratio processing is determined as the restored texture image.

[0027] In an optional manner, the target transition video is a single video, and obtaining the image frame to be processed corresponding to the target transition video includes:

[0028] Obtaining transition information and current transition progress corresponding to the single video, and determining a current transition frame of the single video according to the transition information and the current transition progress;

[0029] Generate a frame of size 0 corresponding to the current transition frame of the single video;

[0030] The current transition frame of the single video and the frame with a size of 0 are determined as the image frames to be processed corresponding to the target transition video.

[0031] In an optional manner, the method further includes:

[0032] Determine all transition frames of the single video according to the transition information corresponding to the single video;

[0033] Determine a current playback frame of the single video, and determine a current transition progress corresponding to the single video based on the current playback frame and all transition frames.

[0034] According to another aspect of an embodiment of the present invention, a video transition device is provided, the device comprising:

[0035] An acquisition module is used to obtain the image frame to be processed corresponding to the target transition video;

[0036] A first generating module, configured to map the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed;

[0037] A second generating module is configured to restore the texture image corresponding to the preset canvas area according to the frame attributes of the image frame to be processed, and fill transparent pixels outside the restored texture image to generate an image frame to be fused having the same size as the preset canvas area;

[0038] The third generating module is used to fuse the image frames to be fused by using a preset fusion algorithm to generate a transition video frame.

[0039] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;

[0040] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the above-mentioned video transition method.

[0041] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores at least one executable instruction. When the executable instruction is executed on an electronic device, the electronic device executes the operation of the above-mentioned video transition method.

[0042] When performing a video transition, the embodiment of the present invention first obtains the image frame to be processed corresponding to the target transition video, maps the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; then, according to the frame attributes of the image frame to be processed, the texture image corresponding to the preset canvas area is restored, and transparent pixels are filled outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; finally, the image frame to be fused is fused through a preset fusion algorithm to generate a transition video frame. It can be seen that the embodiment of the present invention can add transitions between videos of different sizes by mapping the image frame to be processed to a preset canvas area and generating the image frame to be fused based on the texture image, thereby improving the transition effect of the target transition video.

[0043] The above description is only an overview of the technical solutions of the embodiments of the present invention. In order to more clearly understand the technical means of the embodiments of the present invention, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the drawings. In the drawings:

[0045] Figure 1 A schematic diagram showing a flow chart of a video transition method provided by an embodiment of the present invention is shown;

[0046] Figure 2 A schematic structural diagram of a video transition device provided by an embodiment of the present invention is shown;

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

[0048] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0049] Figure 1The flowchart of the video transition method according to the embodiment of the present invention is shown, and the method is executed by an electronic device. The memory of the electronic device is used to store at least one executable instruction, and the executable instruction enables the processor of the electronic device to perform the operation of the video transition method.

[0050] like Figure 1 As shown, the method includes the following steps:

[0051] Step 110: Obtain the image frame to be processed corresponding to the target transition video.

[0052] Among them, the target transition video is the video used to add the transition. When performing a video transition, the user can add the target transition video to the video editing track. The video transition is triggered when the play head (i.e., the current play progress indicator head) or the browse head (i.e., the indicator head on the video editing track where the user moves the mouse) of the video editing track enters the transition interval. The video transition method of the embodiment of the present invention can add a transition between two videos with different video sizes, and can also add a transition at the beginning or end of a single video.

[0053] In one embodiment, the target transition video includes a preceding video and a subsequent video with different video sizes, and the image frame to be processed can be, for example, the current playback frame of the preceding video and the first frame of the subsequent video. When obtaining the image frame to be processed corresponding to the target transition video, first obtain the transition information of the preceding video and the subsequent video respectively, then determine the current transition frame of the preceding video based on the transition information of the preceding video and the current transition progress, and determine the current transition frame of the subsequent video based on the transition information of the subsequent video and the current transition progress; finally, determine the current transition frame of the preceding video and the current transition frame of the subsequent video as the image frame to be processed corresponding to the target transition video. During the video transition process, different transition progresses correspond to different image frames to be processed, and the play head or browse head is located at different positions on the video editing track. Furthermore, when determining the current transition progress, you can first determine all the transition frames of the preceding video based on the transition information corresponding to the preceding video, then determine the current playback frame of the preceding video, and finally determine the current transition progress based on the current playback frame of the preceding video and all the transition frames of the preceding video; or first determine all the transition frames of the subsequent video based on the transition information corresponding to the subsequent video, then determine the current playback frame of the subsequent video, and finally determine the current transition progress based on the current playback frame of the subsequent video and all the transition frames of the subsequent video.

[0054] In another embodiment, the target transition video is a single video. When obtaining the image frame to be processed corresponding to the target transition video, the transition information and current transition progress corresponding to the single video are first obtained, and the current transition frame of the single video is determined based on the transition information and current transition progress corresponding to the single video; then a frame of size 0 corresponding to the current transition frame of the single video is generated; finally, the current transition frame of the single video and the frame of size 0 are determined as the image frame to be processed corresponding to the target transition video. Furthermore, when determining the current transition progress corresponding to the single video, all transition frames of the single video can be determined based on the transition information corresponding to the single video, and then the current playback frame of the single video can be determined. Finally, the current transition progress corresponding to the single video can be determined based on the current playback frame of the single video and all transition frames of the single video.

[0055] Step 120: Mapping the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed.

[0056] Among them, the image frame to be processed is mapped to the preset canvas area through the preset texture coordinate system, that is, the image frame to be processed is texture mapped, so that the image frame to be processed is mapped to the preset canvas area. Each pixel of the texture image can be encoded in RGB or RGBA mode. The preset texture coordinate system is a coordinate system that coincides with the preview window coordinate system. In the preview window coordinate system, the upper left corner of the preview window is the origin of the preview window coordinate system, the origin is downward in the positive direction of the Y axis, and the origin is to the right in the positive direction of the X axis. In the initial texture coordinate system, the lower left corner of the canvas area is the origin of the initial texture coordinate system, the origin is upward in the positive direction of the Y axis, and the origin is to the right in the positive direction of the X axis. Therefore, the initial texture coordinate system needs to be transformed to obtain the preset texture coordinate system. When transforming the initial texture coordinate system, the initial texture coordinate system is first flipped so that the flipped texture coordinate system has the upper left point as its origin, the downward direction as the positive Y-axis, and the rightward direction as the positive X-axis. Next, the size information (length and width) of the preview window is obtained, and based on the size information, the flipped texture coordinate system is adjusted to coincide with the preview window coordinate system. The adjusted texture coordinate system is then determined as the preset texture coordinate system. It should be noted that since the texture coordinates of the preset texture coordinate system are normalized coordinates from [0, 0] to [1, 1], the size of the preset canvas area is consistent with the size of the preview window, which is the window that plays the transition video frame.

[0057] Step 130: According to the frame attributes of the image frame to be processed, the corresponding texture image in the preset canvas area is restored, and transparent pixels are filled outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area.

[0058] Among them, the restored texture image has the same frame attributes as the corresponding image frame to be fused. Since the size of the image frame to be fused is the same as the size of the preset canvas area, the pixels of each image frame to be fused have the same number of rows and columns, which meets the technical requirements of video transition. When restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, the displacement scaling matrix and rotation matrix corresponding to the image frame to be processed can be first determined according to the frame attributes of the image frame to be processed; then the corresponding texture image in the preset canvas area is subjected to displacement scaling transformation by the displacement scaling matrix, and finally the texture image after the displacement scaling transformation is rotated by the rotation matrix, and the texture image after the rotation transformation is determined as the restored texture image. If each pixel of the texture image is encoded in RGBA mode, the transparent pixel points filled outside the restored texture image can be represented as (0, 0, 0, 0). It should be noted that if the target transition video is a single video, for the frame with a size of 0 corresponding to the current transition frame of a single video, it is necessary to fill all transparent pixels (0, 0, 0, 0) within the corresponding preset canvas area so that the size of the image frame to be fused corresponding to the single video is the same as the preset canvas area size.

[0059] The following takes the example of the image frame to be processed including the current playback frame of the preceding video and the first frame of the subsequent video to illustrate the frame attributes of the image frame to be processed. When the image frame to be processed is the current playback frame of the preceding video, the frame attributes of the image frame to be processed may, for example, include the position coordinates, rotation angle (hereinafter represented by fromAngle) and scale size of the current playback frame of the preceding video. The position coordinates of the current playback frame of the preceding video may, for example, be: the X-axis coordinate (hereinafter represented by fromLeft) and Y-axis coordinate (hereinafter represented by fromTop) of the preview window coordinate system corresponding to the upper left point of the current playback frame of the preceding video; the scale size of the current playback frame of the preceding video may, for example, include the scaled width (hereinafter represented by fromHeight) and the scaled length (hereinafter represented by fromWidth). When the image frame to be processed is the first frame of the subsequent video, the frame attributes of the image frame to be processed may, for example, include the position coordinates, rotation angle (hereinafter represented by toAngle) and scale size of the first frame of the subsequent video. The position coordinates of the first frame of the subsequent video can be, for example, the X-axis coordinate (hereinafter represented by toLeft) and the Y-axis coordinate (hereinafter represented by toTop) of the preview window coordinate system corresponding to the upper left point of the first frame of the subsequent video; the scaled size of the first frame of the subsequent video can, for example, include the scaled width (hereinafter represented by toHeight) and the scaled length (hereinafter represented by toWidth). Furthermore, the embodiment of the present invention restores the corresponding texture image in the preset canvas area through a two-dimensional homogeneous coordinate matrix. The two-dimensional homogeneous coordinate matrix can be represented by the following matrix:

[0060]

[0061] In the above two-dimensional homogeneous coordinate matrix, a, b, d and e control the scaling, rotation, symmetry and shearing transformations of the texture image, c and f control the translation transformation of the texture image, g and h control the projection transformation of the texture image, and i controls the scaling transformation of the texture image as a whole.

[0062] Furthermore, the displacement scaling matrix corresponding to the current playback frame of the preceding video and the first frame of the succeeding video can be expressed as:

[0063]

[0064]

[0065] Among them, transformFromMatrix represents the displacement scaling matrix corresponding to the current playback frame of the preceding video, transformToMatrix represents the displacement scaling matrix corresponding to the first frame of the succeeding video; width and height represent the length and width of the preview window respectively.

[0066] The rotation matrix corresponding to the current playback frame of the preceding video and the first frame of the succeeding video can be expressed as:

[0067]

[0068]

[0069] Here, rotateFromMatrix represents the rotation matrix corresponding to the current playback frame of the preceding video, and rotateToMatrix represents the rotation matrix corresponding to the first frame of the succeeding video.

[0070] When the corresponding texture image in the preset canvas area is scaled by the displacement scaling matrices transformFromMatrix and transformToMatrix, the texture coordinates after the displacement scaling transformation can be expressed by the following formulas:

[0071] vFromTexCoord2=(transformFromMatrix*vec3(vFromTexCoord1,1.0)).xy

[0072] vToTexCoord2=(transformToMatrix*vec3(vToTexCoord1,1.0)).xy

[0073] Among them, vFromTexCoord1 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video before the displacement scaling transformation, and vFromTexCoord2 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after the displacement scaling transformation; vToTexCoord1 represents the texture coordinates of the texture image corresponding to the first frame of the subsequent video before the displacement scaling transformation, and vToTexCoord2 represents the texture coordinates of the texture image corresponding to the first frame of the subsequent video after the displacement scaling transformation.

[0074] It should be noted that, since the texture coordinate system is a normalized coordinate system, the distance between texture coordinates is not an absolute distance, and the preset canvas area is not necessarily a square. Before and after the texture image after the displacement scaling transformation is rotated, the aspect ratio of the texture image needs to be processed. In an embodiment of the present invention, before the texture image after the displacement scaling transformation is rotated by the rotation matrix, the texture image after the displacement scaling transformation is processed with a first aspect ratio, and after the texture image after the displacement scaling transformation is rotated by the rotation matrix, the texture image after the rotation transformation is processed with a second aspect ratio, and the texture image after the second aspect ratio processing is determined as the restored texture image. Furthermore, the texture image corresponding to the current playback frame of the preceding video and the texture image corresponding to the first frame of the subsequent video can be subjected to rotation transformation and aspect ratio processing by the following formula.

[0075] vFromTexCoord3.x=vFromTexCoord2.x*(fromWidth / fromHeight)

[0076] vFromTexCoord4=(rotateFromMatrix*vec3(vFromTexCoord3,1.0)).xy

[0077] vFromTexCoord5.x=vFromTexCoord4.x*(1.0 / (fromWidth / fromHeight))

[0078] Among them, vFromTexCoord3 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after processing in the first aspect ratio, vFromTexCoord4 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after rotation transformation, and vFromTexCoord5 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after processing in the second aspect ratio.

[0079] vToTexCoord3.x=vToTexCoord2.x*(toWidth / toHeight)

[0080] vToTexCoord4=(rotateToMatrix*vec3(vToTexCoord3,1.0)).xy

[0081] vToTexCoord5.x=vToTexCoord4.x*=(1.0 / (toWidth / toHeight))

[0082] Among them, vToTexCoord3 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after processing in the first aspect ratio, vToTexCoord4 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after rotation transformation, and vToTexCoord5 represents the texture coordinates of the texture image corresponding to the current playback frame of the previous video after processing in the second aspect ratio.

[0083] Step 140: Fusing the image frames to be fused using a preset fusion algorithm to generate a transition video frame.

[0084] Among them, the embodiment of the present invention avoids stretching, scaling or cropping the image frames to be processed themselves by fusing the image frames to be fused to generate transition video frames, and has a better transition effect. Before performing video transitions, the user can set the transition mode in advance, and the corresponding preset fusion algorithm can be determined according to the transition mode set by the user, and the image frames to be fused can be fused based on the preset fusion algorithm. Furthermore, after the transition video frames are generated, the transition video frames can be played through the preview window, and the user can view the video transition effect through the preview window. For example, in the upper wipe transition scene, if the subsequent video moves upward and erases 30% of the preceding video, it means that the transition has been carried out by 30%, and the current transition progress is 0.3.

[0085] When performing a video transition, the embodiment of the present invention first obtains the image frame to be processed corresponding to the target transition video, maps the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; then, according to the frame attributes of the image frame to be processed, the texture image corresponding to the preset canvas area is restored, and transparent pixels are filled outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; finally, the image frame to be fused is fused through a preset fusion algorithm to generate a transition video frame. It can be seen that the embodiment of the present invention can add transitions between videos of different sizes by mapping the image frame to be processed to a preset canvas area and generating the image frame to be fused based on the texture image, thereby improving the transition effect of the target transition video.

[0086] Figure 2 FIG. 1 shows a schematic diagram of the structure of a video transition device according to an embodiment of the present invention. Figure 2 As shown, the apparatus 300 includes: an acquisition module 310 , a first generation module 320 , a second generation module 330 and a third generation module 340 .

[0087] Among them, the acquisition module 310 is used to obtain the image frame to be processed corresponding to the target transition video; the first generation module 320 is used to map the image frame to be processed to the preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; the second generation module 330 is used to restore the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, and fill transparent pixels outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; the third generation module 330 is used to fuse the image frame to be fused through a preset fusion algorithm to generate a transition video frame.

[0088] In an optional manner, the target transition video includes a preceding video and a succeeding video with different video sizes, and the acquisition module 310 is configured to:

[0089] Respectively obtaining transition information of the preceding video and the succeeding video;

[0090] Determine the current transition frame of the preceding video according to the transition information of the preceding video and the current transition progress;

[0091] Determine the current transition frame of the subsequent video according to the transition information of the subsequent video and the current transition progress;

[0092] The current transition frame of the preceding video and the current transition frame of the succeeding video are determined as the image frames to be processed corresponding to the target transition video.

[0093] In an optional manner, the first generating module 320 is further configured to:

[0094] Flip the initial texture coordinate system so that the flipped texture coordinate system has the upper left point as the origin, the downward direction as the positive direction of the Y axis, and the rightward direction as the positive direction of the X axis;

[0095] Obtaining size information of the preview window, and adjusting the flipped texture coordinate system to coincide with the preview window coordinate system according to the size information;

[0096] The adjusted texture coordinate system is determined as the preset texture coordinate system.

[0097] In an optional manner, the second generating module 330 is configured to:

[0098] Determining a displacement scaling matrix and a rotation matrix corresponding to the image frame to be processed according to a frame attribute of the image frame to be processed;

[0099] Performing displacement and scaling transformation on the corresponding texture image within the preset canvas area using the displacement and scaling matrix;

[0100] The texture image after the displacement and scaling transformation is rotated using the rotation matrix, and the texture image after the rotation transformation is determined as the restored texture image.

[0101] In an optional manner, the second generating module 330 is configured to:

[0102] Before performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a first aspect ratio processing on the texture image after the displacement and scaling transformation;

[0103] After performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a second aspect ratio processing on the texture image after the rotation transformation;

[0104] The texture image after the second aspect ratio processing is determined as the restored texture image.

[0105] In an optional manner, the target transition video is a single video, and the acquisition module 310 is used to:

[0106] Obtaining transition information and current transition progress corresponding to the single video, and determining a current transition frame of the single video according to the transition information and the current transition progress;

[0107] Generate a frame of size 0 corresponding to the current transition frame of the single video;

[0108] The current transition frame of the single video and the frame with a size of 0 are determined as the image frames to be processed corresponding to the target transition video.

[0109] In an optional manner, the acquisition module 310 is configured to:

[0110] Determine all transition frames of the single video according to the transition information corresponding to the single video;

[0111] Determine a current playback frame of the single video, and determine a current transition progress corresponding to the single video based on the current playback frame and all transition frames.

[0112] When performing a video transition, the embodiment of the present invention first obtains the image frame to be processed corresponding to the target transition video, maps the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; then, according to the frame attributes of the image frame to be processed, the texture image corresponding to the preset canvas area is restored, and transparent pixels are filled outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; finally, the image frame to be fused is fused through a preset fusion algorithm to generate a transition video frame. It can be seen that the embodiment of the present invention can add transitions between videos of different sizes by mapping the image frame to be processed to a preset canvas area and generating the image frame to be fused based on the texture image, thereby improving the transition effect of the target transition video.

[0113] Figure 3 The schematic diagram of the structure of the electronic device according to the embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.

[0114] like Figure 3 As shown, the electronic device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .

[0115] Processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other devices, such as clients or other server network elements. Processor 402 is used to execute program 410, which may specifically perform the steps described in the aforementioned embodiment of the video transition method.

[0116] Specifically, the program 410 may include program code including computer-executable instructions.

[0117] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The one or more processors included in an electronic device may be processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.

[0118] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0119] Program 410 may be specifically called by processor 402 to enable the electronic device to perform the following operations:

[0120] Obtain the image frame to be processed corresponding to the target transition video;

[0121] Mapping the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed;

[0122] Restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, and filling transparent pixels outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area;

[0123] The image frames to be fused are fused using a preset fusion algorithm to generate a transition video frame.

[0124] In an optional manner, the target transition video includes a preceding video and a succeeding video with different video sizes, and the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0125] Respectively obtaining transition information of the preceding video and the succeeding video;

[0126] Determine the current transition frame of the preceding video according to the transition information of the preceding video and the current transition progress;

[0127] Determine the current transition frame of the subsequent video according to the transition information of the subsequent video and the current transition progress;

[0128] The current transition frame of the preceding video and the current transition frame of the succeeding video are determined as the image frames to be processed corresponding to the target transition video.

[0129] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0130] Flip the initial texture coordinate system so that the flipped texture coordinate system has the upper left point as the origin, the downward direction as the positive direction of the Y axis, and the rightward direction as the positive direction of the X axis;

[0131] Obtaining size information of the preview window, and adjusting the flipped texture coordinate system to coincide with the preview window coordinate system according to the size information;

[0132] The adjusted texture coordinate system is determined as the preset texture coordinate system.

[0133] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0134] Determining a displacement scaling matrix and a rotation matrix corresponding to the image frame to be processed according to a frame attribute of the image frame to be processed;

[0135] Performing displacement and scaling transformation on the corresponding texture image within the preset canvas area using the displacement and scaling matrix;

[0136] The texture image after the displacement and scaling transformation is rotated using the rotation matrix, and the texture image after the rotation transformation is determined as the restored texture image.

[0137] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0138] Before performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a first aspect ratio processing on the texture image after the displacement and scaling transformation;

[0139] After performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a second aspect ratio processing on the texture image after the rotation transformation;

[0140] The texture image after the second aspect ratio processing is determined as the restored texture image.

[0141] In an optional manner, the target transition video is a single video, and the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0142] Obtaining transition information and current transition progress corresponding to the single video, and determining a current transition frame of the single video according to the transition information and the current transition progress;

[0143] Generate a frame of size 0 corresponding to the current transition frame of the single video;

[0144] The current transition frame of the single video and the frame with a size of 0 are determined as the image frames to be processed corresponding to the target transition video.

[0145] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:

[0146] Determine all transition frames of the single video according to the transition information corresponding to the single video;

[0147] Determine a current playback frame of the single video, and determine a current transition progress corresponding to the single video based on the current playback frame and all transition frames.

[0148] When performing a video transition, the embodiment of the present invention first obtains the image frame to be processed corresponding to the target transition video, maps the image frame to be processed to a preset canvas area through a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; then, according to the frame attributes of the image frame to be processed, the texture image corresponding to the preset canvas area is restored, and transparent pixels are filled outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; finally, the image frame to be fused is fused through a preset fusion algorithm to generate a transition video frame. It can be seen that the embodiment of the present invention can add transitions between videos of different sizes by mapping the image frame to be processed to a preset canvas area and generating the image frame to be fused based on the texture image, thereby improving the transition effect of the target transition video.

[0149] An embodiment of the present invention provides a computer-readable storage medium storing at least one executable instruction. When the executable instruction is executed on an electronic device, the electronic device executes the video transition method in any of the above method embodiments.

[0150] An embodiment of the present invention provides a video transition device for executing the above-mentioned video transition method.

[0151] An embodiment of the present invention provides a computer program, which can be called by a processor to enable an electronic device to execute the video transition method in any of the above method embodiments.

[0152] An embodiment of the present invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are run on a computer, the computer executes the video transition method in any of the above method embodiments.

[0153] The algorithm or demonstration provided herein are not inherently relevant to any particular computer, virtual system or other equipment. Various general-purpose systems may also be used together with the teachings based on this. According to the above description, it is apparent that the structure required for constructing this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language yet. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the above description of specific languages ​​is for the purpose of disclosing the best mode of the present invention.

[0154] In the description provided herein, numerous specific details are described. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0155] Similarly, it should be understood that in order to streamline the present invention and facilitate understanding of one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0156] Those skilled in the art will appreciate that the modules in the devices in the embodiments can be adaptively changed and set in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed so far can be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) can be replaced by an alternative feature that provides the same, equivalent or similar purpose.

[0157] It should be noted that the above embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by a person skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.

Claims

1. A video transition method, characterized in that: The method comprises: Obtain the image frame to be processed corresponding to the target transition video; Mapping the image frame to be processed to a preset canvas area using a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; wherein the initial texture coordinate system is flipped so that the flipped texture coordinate system has an upper left point as an origin, a downward positive Y-axis direction, and a rightward positive X-axis direction; obtaining size information of a preview window, and adjusting the flipped texture coordinate system to coincide with the preview window coordinate system based on the size information; and determining the adjusted texture coordinate system as the preset texture coordinate system; Restoring the corresponding texture image in the preset canvas area according to the frame attributes of the image frame to be processed, and filling transparent pixels outside the restored texture image to generate an image frame to be fused with the same size as the preset canvas area; Restoring the texture image corresponding to the preset canvas area according to the frame attributes of the image frame to be processed includes: determining a displacement scaling matrix and a rotation matrix corresponding to the image frame to be processed according to the frame attributes of the image frame to be processed; performing a displacement scaling transformation on the texture image corresponding to the preset canvas area using the displacement scaling matrix; performing a rotation transformation on the texture image after the displacement scaling transformation using the rotation matrix, and determining the texture image after the rotation transformation as the restored texture image; The image frames to be fused are fused using a preset fusion algorithm to generate a transition video frame.

2. The method according to claim 1, characterized in that The target transition video includes a preceding video and a subsequent video with different video sizes, and obtaining the image frame to be processed corresponding to the target transition video includes: Respectively obtaining transition information of the preceding video and the succeeding video; Determine the current transition frame of the preceding video according to the transition information of the preceding video and the current transition progress; Determine the current transition frame of the subsequent video according to the transition information of the subsequent video and the current transition progress; The current transition frame of the preceding video and the current transition frame of the succeeding video are determined as the image frames to be processed corresponding to the target transition video.

3. The method according to claim 1, characterized in that The method further comprises: Before performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a first aspect ratio processing on the texture image after the displacement and scaling transformation; After performing rotation transformation on the texture image after the displacement and scaling transformation by the rotation matrix, performing a second aspect ratio processing on the texture image after the rotation transformation; The texture image after the second aspect ratio processing is determined as the restored texture image.

4. The method according to claim 1, wherein The target transition video is a single video, and obtaining the image frame to be processed corresponding to the target transition video includes: Obtaining transition information and current transition progress corresponding to the single video, and determining a current transition frame of the single video according to the transition information and the current transition progress; Generate a frame of size 0 corresponding to the current transition frame of the single video; The current transition frame of the single video and the frame with a size of 0 are determined as the image frames to be processed corresponding to the target transition video.

5. The method according to claim 4, characterized in that The method further comprises: Determine all transition frames of the single video according to the transition information corresponding to the single video; Determine a current playback frame of the single video, and determine a current transition progress corresponding to the single video based on the current playback frame and all transition frames.

6. A video transition device, characterized in that: The device comprises: An acquisition module is used to obtain the image frame to be processed corresponding to the target transition video; A first generating module is configured to map the image frame to be processed to a preset canvas area using a preset texture coordinate system to generate a texture image corresponding to the image frame to be processed; wherein the initial texture coordinate system is flipped so that the flipped texture coordinate system has an upper left point as its origin, a downward direction as a positive Y-axis direction, and a rightward direction as a positive X-axis direction; obtain size information of a preview window, and adjust the flipped texture coordinate system to coincide with the preview window coordinate system based on the size information; and determine the adjusted texture coordinate system as the preset texture coordinate system; A second generating module is configured to restore the texture image corresponding to the preset canvas area according to the frame attributes of the image frame to be processed, and fill transparent pixels outside the restored texture image to generate an image frame to be fused having the same size as the preset canvas area; Restoring the texture image corresponding to the preset canvas area according to the frame attributes of the image frame to be processed includes: determining a displacement scaling matrix and a rotation matrix corresponding to the image frame to be processed according to the frame attributes of the image frame to be processed; performing a displacement scaling transformation on the texture image corresponding to the preset canvas area using the displacement scaling matrix; performing a rotation transformation on the texture image after the displacement scaling transformation using the rotation matrix, and determining the texture image after the rotation transformation as the restored texture image; The third generating module is used to fuse the image frames to be fused by using a preset fusion algorithm to generate a transition video frame.

7. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the video transition method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that The storage medium stores at least one executable instruction. When the executable instruction is executed on the electronic device, the electronic device executes the operation of the video transition method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Video fusion method, electronic equipment and storage medium

    CN110996150A

  • Image processing method and device, electronic equipment and storage medium

    CN112087648A