Video processing method, device, electronic device and readable storage medium

The video processing method uses separate threads and adaptive processing modes to manage video editing and rendering, addressing display freezes in streaming frameworks by ensuring editing occurs ahead of playback, enhancing user experience and efficiency.

JP7769112B2Active Publication Date: 2025-11-12BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
JP2024529213
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-11-15
Filing Date
2022-11-02
Publication Date
2025-11-12
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

Existing video editing applications experience serious display freezes during playback due to the use of streaming processing frameworks, which fail to efficiently manage video editing operations and rendering in real-time with user input commands.

Method used

A video processing method that utilizes separate threads for performing video editing operations and rendering, ensuring that the video frame position where editing occurs precedes the frame position of playback, and employs multiple processing modes to adapt to different scenarios and user inputs, such as key frames, frame-by-frame, and playback speed-based operations.

Benefits of technology

This approach prevents display freezes and ensures smooth preview playback by decoupling editing and rendering processes, improving user experience and reducing resource waste associated with frequent decoder updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007769112000001
    Figure 0007769112000001
  • Figure 0007769112000002
    Figure 0007769112000002
  • Figure 0007769112000003
    Figure 0007769112000003
Patent Text Reader

Abstract

The present disclosure relates to a video processing method, an apparatus, an electronic device, and a readable storage medium, the method including: performing a target video editing operation on a processing target video from a specified video frame position by a first thread, obtaining each target video frame obtained by performing the target video editing operation, and performing rendering on each target video frame by a second thread in response to a playback command, thereby ensuring that the video frame position where the target video editing operation is performed always precedes the video frame position of the presented target video frame by performing the target video editing operation in advance, solving the problem of preview freezing and ensuring the preview needs of users. In addition, the target video editing process and rendering are separated and performed by different threads, solving the problem of the rendering thread being blocked due to the target video editing operation being performed in a streaming framework, which is favorable for improving the preview effect.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] [CROSS-REFERENCE TO RELATED APPLICATIONS] This application is based on and claims priority from a Chinese application having application number 202111347351.6 and filing date November 15, 2021, the entire disclosure of which is incorporated herein by reference.

[0002] [Technical field] The present disclosure relates to the field of Internet technology, and in particular to a video processing method, device, electronic device and readable storage medium. [Background technology]

[0003] With the development of Internet technology, various applications (APPs) have been developed, among which applications with video editing functions are particularly popular. Currently, applications that can provide video editing functions can implement many video editing operations, such as intelligent matting, which requires corresponding processing for each video frame image of a video.

[0004] In related art, a streaming processing framework is generally adopted for such video editing operations, for example, when performing intelligent matting, encoding, matting, rendering and display on a frame-by-frame basis. Summary of the Invention

[0005] To solve or at least partially solve the above technical problems, the present disclosure provides a video processing method, apparatus, electronic device and readable storage medium.

[0006] According to a first aspect, the present disclosure provides a method for manufacturing a semiconductor device, comprising: performing, by a first thread, a target video editing operation on a video frame at the specified video frame position in the target video from a specified video frame position, and pre-performing the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation; and in response to a playback command, rendering each of the target video frames by a second thread and presenting each of the target video frames, wherein a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0007] In one possible embodiment, the specified video frame position is determined based on a video frame position positioned when a video editing command is obtained, the video editing command being for instructing the target video editing operation to be performed on the processing target video, and the video frame position positioned when the video editing command is obtained is a preset video frame position or a video frame position specified by a first jump command.

[0008] In one possible embodiment, the specified video frame position is determined based on a video frame position specified in a second jump instruction, and the second jump instruction is an instruction following a video editing instruction for performing the target video editing operation on the target video.

[0009] In one possible embodiment, when the specified video frame position is determined based on the video frame position determined when the video editing command is acquired, the method includes the steps of: executing a target video editing operation on a video frame at the specified video frame position in the target video from the specified video frame position by the first thread; and pre-executing the target video editing operation on each video frame after the specified video frame position, before acquiring each target video frame obtained by executing the target video editing operation, the method includes the steps of: The method further includes determining a video editing processing mode corresponding to the first thread based on the specified video frame position, wherein the video editing processing mode is a first processing mode that performs the target video editing operation on a key frame, or a second processing mode that performs the target video editing operation on a frame-by-frame basis.

[0010] In one possible embodiment, the step of determining a video editing processing mode corresponding to the first thread based on the specified video frame position as described above includes: If the specified video frame position is the preset video frame position, determining a video editing processing mode corresponding to the first thread as the first processing mode; If the specified video frame position is a video frame position specified by a first jump instruction, determining the video editing processing mode corresponding to the first thread as the first processing mode or the second processing mode.

[0011] In one possible embodiment, the step of determining a video editing processing mode corresponding to the first thread based on the specified video frame position as described above includes: determining whether a corresponding target video frame exists at the specified video frame location; If there is no corresponding target video frame at the specified video frame position, determining a video editing processing mode corresponding to the first thread according to whether the specified video frame position is the preset video frame position or a video frame position specified by the first jump command.

[0012] In one possible embodiment, the method comprises: If a corresponding target video frame exists at the specified video frame position, determining a video editing processing mode corresponding to the first thread as the second processing mode; The above-mentioned, performing a target video editing operation on a video frame at the specified video frame position in a processing target video from a first thread, and performing the target video editing operation on each video frame after the specified video frame position in advance to obtain each target video frame obtained by performing the target video editing operation, includes: determining whether a corresponding target video frame exists for each frame after the specified video frame position until a first video frame position without a corresponding target video frame is determined; The method includes performing the target video editing operation on video frames of the processing target video from the first video frame position where no corresponding target video frame exists according to the second processing mode by the first thread.

[0013] In one possible embodiment, when the specified video frame position is determined based on the video frame position specified by the second jump instruction, the method includes: executing the target video editing operation by the first thread from the specified video frame position to the video frame at the specified video frame position in the processing target video; and performing the target video editing operation in advance on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation, The method further includes determining a video editing processing mode corresponding to the first thread as a second processing mode when there is no corresponding target video frame at the specified video frame position.

[0014] In one possible embodiment, the method comprises: If a corresponding target video frame exists at the specified video frame position and the first thread is currently performing the target video editing operation on the target video, the method further includes not suspending the first thread and allowing the first thread to continue performing the target video editing operation on the target video.

[0015] In one possible embodiment, the method comprises: The method further includes, in response to the playback command, switching the video editing processing mode to a third processing mode, which is a mode in which a video frame position at which the target video editing operation is to be performed is determined according to a playback speed, and performing the target video editing operation on a video frame of the video to be processed by the first thread according to the third processing mode.

[0016] In one possible embodiment, the step of switching the video editing processing mode to a third processing mode in response to the playback instruction and performing the target video editing operation on video frames of the target video by the first thread in accordance with the third processing mode, as described above, comprises: responsive to said play command, detecting in real time whether there is a next target video frame to be played; When it is detected that there is no next target video frame to be played back, the first thread performs the target video editing operation on video frames of the processing target video according to the third processing mode from the position of the next target video frame to be played back.

[0017] In one possible embodiment, the step of switching the video editing processing mode to a third processing mode in response to the playback instruction and performing the target video editing operation on video frames of the target video by the first thread in accordance with the third processing mode, as described above, comprises: In response to the playback command, the first thread performs the target video editing operation on video frames of the processing target video according to the third processing mode from the video frame position where the target video editing operation is being performed when the playback command is received.

[0018] In one possible embodiment, the step of switching the video editing processing mode to a third processing mode in response to the playback instruction and performing the target video editing operation on video frames of the target video by the first thread in accordance with the third processing mode, as described above, comprises: determining a switching position corresponding to the third processing mode in response to the playback command based on a processing time length for performing the target video editing operation on a predetermined single video frame, a playback speed, and a video frame position on which the target video editing operation is currently being performed; and performing, by the first thread, the target video editing operation on video frames of the target video from the switching position according to the third processing mode.

[0019] In one possible embodiment, the method comprises: Obtaining a playback pause command; The method further includes pausing rendering of the target video frames by the second thread in response to the playback pause command, and the first thread continuing to perform the target video editing operations on the video frames of the target video according to the third processing mode.

[0020] In one possible embodiment, the method comprises: and after performing the target video editing operation on the last video frame of the to-be-processed video, performing the target video editing operation on video frames of the to-be-processed video from the position of the first video frame of the to-be-processed video according to a fourth processing mode by the first thread; The fourth processing mode is a mode in which the target video editing operation is sequentially performed on video frames in the processing target video that do not have corresponding target video frames.

[0021] According to a second aspect, the present disclosure provides a method for manufacturing a semiconductor device, comprising: a first processing module for executing, by a first thread, a target video editing operation on a video frame at the specified video frame position in a target video from a specified video frame position, and pre-executing the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by executing the target video editing operation; and a second processing module for rendering each of the target video frames by a second thread in response to a playback command and presenting each of the target video frames, wherein a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the processed video of the target video frame being presented.

[0022] According to a third aspect, the present disclosure provides an electronic device including a memory and a processor, the memory configured to store computer program instructions; The processor is configured to execute the computer program instructions to cause the electronic device to implement the video processing method of any one of the first aspects.

[0023] According to a fourth aspect, the present disclosure provides a readable storage medium comprising computer program instructions which, when executed by at least one processor of an electronic device, cause the electronic device to implement the video processing method according to any one of the first aspects.

[0024] According to a fifth aspect, the present disclosure provides a computer program product which, when executed by a computer, causes the computer to implement the video processing method according to any one of the first aspects.

[0025] The present disclosure provides a video processing method, apparatus, electronic device, and readable storage medium, the method including: performing, by a first thread, a target video editing operation on a target video from a specified video frame position, and obtaining each target video frame obtained by performing the target video editing operation; and, in response to a playback command, performing, by a second thread, rendering on each target video frame and presenting each target video frame. [Brief explanation of the drawings]

[0026] The drawings herein, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure.

[0027] In order to more clearly describe the technical solutions in the embodiments or related art of the present disclosure, the following briefly describes the drawings that need to be used in the description of the embodiments or related art. Obviously, those skilled in the art can obtain other drawings based on these drawings without any creative efforts.

[0028] [Figure 1]1 is a flowchart of a video processing method according to one embodiment of the present disclosure. [Figure 2] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 3] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 4] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 5] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 6] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 7] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 8] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 9] 10 is a flowchart of a video processing method according to another embodiment of the present disclosure. [Figure 10] 1 is a schematic framework diagram of a video processing device according to an embodiment of the present disclosure. [Figure 11] FIG. 11 is a schematic diagram of the life cycle of each module in the embodiment shown in FIG. 10 according to one embodiment of the present disclosure. [Figure 12] 1 is a schematic diagram illustrating the configuration of a video processing device according to an embodiment of the present disclosure. [Figure 13] 1 is a schematic diagram illustrating the configuration of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE INVENTION

[0029] In order to make the above-mentioned objects, features and advantages of the present disclosure more clearly understandable, the present disclosure will be further described below. It should be noted that, unless contradictory, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

[0030] In the following description, many specific details are set forth in order to fully understand the present disclosure; however, the present disclosure may be embodied in other forms different from those described herein. Obviously, the embodiments in the specification are only some of the embodiments of the present disclosure, but not all of the embodiments.

[0031] In the related art, in the process of adopting a streaming processing framework to perform intelligent matting, when a user previews playback, a serious display freeze problem is likely to occur, which seriously affects the user experience.

[0032] The video processing method according to the present disclosure can be performed by a video processing device, which can be implemented by any software and / or hardware. For example, the video processing device can be a tablet, a mobile phone (e.g., a flip phone, a large-screen phone, etc.), a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a smart TV, a smart screen, a high-definition TV, a 4K TV, a smart speaker, a smart projector, or other Internet of Things (IoT) device. The present disclosure does not limit the specific type of electronic device.

[0033] It should be noted that the video processing method according to the present disclosure is applicable to at least scenarios with the following characteristics:

[0034] 1. A video editing operation needs to be performed on each video frame of the target video, and a corresponding target video frame (i.e., the video editing processing result) needs to be generated and saved for rendering and display.

[0035] 2. It takes more time to edit the video, but it provides a better preview playback effect.

[0036] 3. Video editing operations need to follow and match in real time with user-input operation commands, such as user-input jump commands (which may also be called seek commands), update commands (which may also be called refresh commands), playback commands, variable speed playback commands, playback pause commands, etc.

[0037] For any of the scenarios with the above characteristics, the video editing processing method according to the present disclosure can be adopted to ensure the user's preview effect.

[0038] In order to more clearly explain the video processing method according to the present disclosure, the following examples will explain in detail the video processing method according to the present disclosure using the example of a case where a video editing application (hereinafter referred to as application) is installed in an electronic device.

[0039] 1 is a flowchart of a video processing method according to an embodiment of the present disclosure. As shown in FIG. 1, the method according to this embodiment includes the following steps:

[0040] S101: A first thread performs a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation.

[0041] The target video is a material that needs to perform a target video editing operation. The present disclosure does not limit the duration, storage format, resolution, video content, and acquisition method of the target video.

[0042] The first thread is a thread for executing a target video editing operation on the target video. The first thread may be referred to as an algorithm thread. The algorithm thread may invoke an algorithm instance corresponding to the target video editing operation to realize the execution of the target video editing operation on the target video. Furthermore, the present disclosure does not limit the manner in which the first thread is determined.

[0043] Here, the present disclosure does not limit the type of the target video editing operation. Exemplarily, the target video editing operation may include, but is not limited to, intelligent matting, adding stickers, filters, etc.

[0044] The specified video frame position may be the position of any one of the video frames in the video to be processed. For example, the specified video frame position may be the video frame position determined when the video editing command is received, or may be the video frame position specified by the user through a trigger operation.

[0045] The video editing instructions are for instructing the execution of target video editing operations on each video frame of the processing target video. The present disclosure does not limit the implementation of obtaining the video editing instructions. For example, a user may input the video editing instructions into an application by operating corresponding controls provided by the application.

[0046] The implementation of this step will now be described exemplarily by taking different scenarios as examples.

[0047] In one possible embodiment, a user may select a target video via a material selection page displayed in the application and introduce it into the application to perform video editing. The application may display a video editing page in a user interface. The video editing page may include controls corresponding to multiple different video editing operations, including a target control corresponding to a target video editing operation (e.g., intelligent matting). When the application receives a trigger operation (e.g., a tap operation) by the user on the target control, it generates a video editing command instructing the application to perform intelligent matting on each video frame of the target video. In response to the video editing command, the application performs the target video editing operation on the target video starting from the specified video frame position.

[0048] In this scenario, when the target video is introduced, the application may position it at a preset video frame position by default. Since the user does not subsequently input any triggering operation, the positioned video frame position remains unchanged. When a video editing command is acquired, the positioned video frame position remains the preset video frame position. That is, the specified video frame position is the preset video frame position. Here, the preset video frame position may be the position of any one video frame in the target video. For example, the preset video frame position is the position of the first video frame in the target video.

[0049] In another possible embodiment, a user may select a target video through a material selection page displayed in the application and introduce it into the application to perform video editing. The application may display a video editing page in a user interface. The video editing page may include controls corresponding to multiple different video editing operations, including a target control corresponding to a target video editing operation (e.g., intelligent matting). When the application receives a trigger operation (e.g., a tap operation) on the target control by the user, the application generates a video editing command instructing the application to perform intelligent matting on each video frame of the target video. In response to the video editing command, the application performs the target video editing operation on the target video from the specified video frame position. Here, before the user inputs the trigger operation on the target control, the user may input a first jump command to cause the positioned position to jump from a preset video frame position to a video frame position indicated by the first jump command.

[0050] In this scenario, the designated video frame position is the video frame position indicated by the first jump command. Note that the user may input one or more first jump commands, and typically the video frame position indicated by the last jump command is the designated video frame position.

[0051] In another possible embodiment, based on the above first possible embodiment, the first thread may already execute a target video editing operation from a preset video frame position, and while executing the target video editing operation, the user may input a second jump instruction, and then, in response to the second jump instruction, the application needs to execute the target video editing operation in the first thread from the video frame position indicated by the second jump instruction.

[0052] In this scenario, the specified video frame position is the video frame position indicated by the second jump instruction. Here, the user may input multiple second jump instructions. In response to each second jump instruction, the first thread needs to execute the target video editing operation from the video frame position indicated by the second jump instruction.

[0053] S102: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0054] In the first thread, while the target video editing operation is being performed on the target video, the application supports the user to preview each target video frame obtained by performing the target video editing operation, i.e., the application supports the user to preview playback of each target video frame.

[0055] In one possible embodiment, when the application receives a play command, it performs rendering for each target video frame according to the play speed and plays each target video frame in response to the play command using a second thread.

[0056] While the first thread is performing the target video editing operation on the target video to be processed, the first thread may perform the target video editing operation on the video frame at the specified video frame position to obtain the target video frame corresponding to the specified video frame position, and the second thread may automatically perform rendering on the target video frame corresponding to the specified video frame position to present the target video frame corresponding to the specified video frame position, thereby ensuring that the user can preview the processing effect corresponding to the specified video frame position before the application receives a playback command.

[0057] In another possible embodiment, while the first thread is performing the target video editing operation on the target video, the second thread may perform the target video editing operation on the video frame at the specified video frame position to obtain the target video frame corresponding to the specified video frame position, and then the second thread may automatically render each target video frame from the specified video frame position, i.e., without the user needing to trigger a playback command.

[0058] Regardless of which of the above embodiments is adopted, the method according to this embodiment ensures that the video frame position on which the target video editing operation is being performed always precedes the position of the target video frame being presented in the processing video, thereby ensuring that the target video frame on which the target video editing operation has been performed is available for preview, thereby solving the problem of the user's preview freezing.

[0059] To clarify the present technical solution, an example will be used to explain what it means that the video frame position where the target video editing operation is being performed precedes the position of the presented target video frame in the to-be-processed video. Assuming that the to-be-processed video has 100 frames, starting from the first frame to the 100th frame in order of earliest, the presented target video frame corresponds to the 20th frame, and the video frame position where the target video editing operation is being performed is the 30th frame, this indicates that the video frame position where the target video editing operation is being performed precedes the position of the presented target video frame in the to-be-processed video.

[0060] In this embodiment, a method uses a first thread to perform a target video editing operation on a target video starting from a specified video frame position, obtain each target video frame obtained by performing the target video editing operation, and then uses a second thread to render each target video frame in response to a playback command and present the target video frame. The present disclosure pre-performs the target video editing operation on each video frame after the specified video frame position, ensuring that the video frame position at which the target video editing operation is performed always precedes the video frame position in the target video at which the target video editing operation is being performed. This solves the problem of preview freezing while the target video editing operation is being performed on the target video, ensuring the user's preview needs. Furthermore, because the execution of the target video editing operation takes time, if the time required for algorithm processing does not match the time required for the rendering thread, the rendering thread is likely to be blocked. Therefore, the present disclosure separates the currently executed video editing process from the rendering and performs them on different threads, thereby solving the problem of the rendering thread being blocked due to the execution of the target video editing operation in a streaming framework and advantageously improving the preview experience.

[0061] Based on the embodiment shown in FIG. 1 , the video processing method according to the present disclosure can provide at least the following video editing processing modes: When an application receives a video editing command, it may determine a video editing processing mode corresponding to the first thread based on a preset policy, where the preset policy may be related to one or more factors, such as, but not limited to, a current video frame position of the target video, an overall progress of performing the target video editing operation on the target video, a playback state (playback paused state or playing state), and a user trigger operation.

[0062] Here, the application supports at least four video editing processing modes: a first processing mode, a second processing mode, a third processing mode, and a fourth processing mode.

[0063] Here, the first processing mode is a mode for performing a target video editing operation on a key frame of the target video, and may be called other names such as a pre-processing mode, an anchor mode, or an anchor mode.

[0064] The second processing mode is a mode in which the target video editing operation is performed frame by frame, and may be called other names such as a jump processing mode or a seek mode.

[0065] The third processing mode is a mode in which a video frame position for performing a target video editing operation is determined based on the playback progress, and may be called a playback processing mode or other names.

[0066] The fourth processing mode is a mode in which a target video editing operation is sequentially performed on video frames in the target video for which no corresponding target video frame exists. That is, the fourth processing mode is a mode in which a target video editing operation is sequentially performed on video frames for which no target video editing operation has been performed, from the first video frame to the last video frame in the target video. The fourth processing mode may also be called a self-enhancing processing mode, adaptive mode, or other names.

[0067] Based on the above preset policy, the application can determine the video editing processing mode corresponding to the first thread performing the target video editing operation in different scenarios.

[0068] The following describes in detail how the first thread performs the target video editing operation on the target video in different scenarios through several specific embodiments.

[0069] 2 is a flowchart of a video processing method according to an embodiment of the present disclosure. As shown in FIG. 2, the method according to this embodiment includes the following steps:

[0070] S201: Determine a video editing processing mode corresponding to a first thread based on a specified video frame position, where the video editing processing mode is a first processing mode or a second processing mode.

[0071] 1, the specified video frame position may be a preset video frame position, a video frame position indicated by a first jump instruction, or a video frame position indicated by a second jump instruction. The video editing processing mode corresponding to the first thread may vary depending on the situation.

[0072] Here, the first processing mode is a mode in which target video editing operations are performed on key frames (i.e., I frames). I frames, also known as intra pictures, are important frames in intraframe compression encoding. During encoding, a series of video frames are partially compressed into I frames, partially compressed into P frames, and partially compressed into B frames. During decoding, the entire image can be reconstructed based only on the data of the I frames, without needing to refer to the data of other video frames.

[0073] The second processing mode is a mode for performing a target video editing operation on the target video on a frame-by-frame basis, where the second processing mode is a video editing processing mode for responding to a user-input seek command according to the present disclosure.

[0074] In one possible embodiment, if the specified video frame position is a preset video frame position (e.g., the position of the first video frame of the video to be processed), the video editing processing mode corresponding to the first thread is determined as the first processing mode.

[0075] By performing a target video editing operation on a key frame of the target video, when a user previews the effect processing result, the entire image can be reconstructed from the target video frame corresponding to the key frame, so that the preview effect performed by the user can be well ensured.

[0076] In another possible embodiment, when the specified video frame position is a video frame position indicated by a jump instruction, the video editing processing mode corresponding to the first thread is the first processing mode or the second processing mode. Exemplarily, when the specified video frame position is a video frame position indicated by a first jump instruction, the video editing processing mode corresponding to the first thread may be the first processing mode or the second processing mode. When the specified video frame position is a video frame position indicated by a first jump instruction, the video editing processing mode corresponding to the first thread may be the second processing mode.

[0077] S202: The first thread executes a target video editing operation on a video frame at the specified video frame position in the processing target video from a specified video frame position according to the determined video editing processing mode, and pre-executes the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by executing the target video editing operation.

[0078] If the determined video editing processing mode is the first processing mode, the application sequentially performs a target video editing operation on each key frame in the video to be processed, starting from the specified video frame position, and stores the target video frame obtained by performing the target video editing operation on each key frame.

[0079] If the determined video editing processing mode is the second processing mode, the application performs a target video editing operation on the processing target video for each frame from the specified video frame position, and stores the target video frame obtained by performing the target video editing operation on each video frame.

[0080] S203: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0081] Step S203 in this embodiment is similar to step S102 in the embodiment shown in FIG. 1, and reference may be made to the detailed description of the embodiment shown in FIG. 1, and for the sake of brevity, no further description will be given here.

[0082] In a video editing scenario, the method of this embodiment obtains and analyzes a specified video frame position to determine a video editing processing mode corresponding to a first thread, and then performs a target video editing operation on a corresponding video frame in the target video according to the determined video editing processing mode, ensuring that the video frame position at which the target video editing operation is being performed always precedes the video frame position at which the presented target video frame is being displayed in the target video. This solves the problem of preview freezing while the target video editing operation is being performed on the target video, ensuring the user's preview needs. Furthermore, since the target video editing operation takes time to execute, if the time required for algorithm processing and the time required for the rendering thread are not consistent, the rendering thread is likely to be blocked. Therefore, the present disclosure separates the currently executed video editing process from rendering and performs them on different threads, thereby solving the problem of the rendering thread being blocked due to the execution of the target video editing operation in a streaming framework and advantageously improving the preview experience.

[0083] 3 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 3, the method of this embodiment includes the following steps:

[0084] Based on the embodiment shown in FIG. 2, S201 in the embodiment shown in FIG. 2 can be realized by S301 to S306 in this embodiment.

[0085] S301: Determine whether there is a corresponding target video frame at a specified video frame position.

[0086] If there is no corresponding target video frame at the specified video frame position, execute S302. If there is a corresponding target video frame at the specified video frame position, execute S303.

[0087] S302: Determine a video editing processing mode corresponding to the first thread based on a specified video frame position.

[0088] Here, after determining the video editing processing mode corresponding to the first thread, S305 is executed.

[0089] S303: Determine whether the current first thread performs a target video editing operation on the target video.

[0090] If the current first thread is not performing a target video editing operation on the current video, execute S304 and S305. If the current first thread is performing a target video editing operation on the current video, execute S306.

[0091] S304: The video editing processing mode is determined as the second processing mode.

[0092] S305: The first thread performs a target video editing operation on the target video according to the determined video editing processing mode, and obtains each target video frame obtained by performing the target video editing operation.

[0093] S306: The first thread continues to perform the target video editing operation on the target video.

[0094] In a practical scenario, when the first thread starts to perform a target video editing operation according to a video editing processing mode or when the video editing processing mode is switched, the decoder needs to be updated, which requires a lot of computational resources. Therefore, the method according to this embodiment determines whether to switch the video editing processing mode by analyzing whether a corresponding target video frame exists at a specified video frame position and whether a process currently performing the target video editing operation on the target video (i.e., whether the current first thread is performing the target video editing operation on the target video), thereby reducing the waste of computational resources associated with frequent decoder updates and further improving the processing efficiency of executing the target video editing operation.

[0095] Here, the reason for analyzing whether a corresponding target video frame exists at the specified video frame position is that a target video editing operation may have already been performed on the target video, and therefore corresponding target video frames may exist in some or all of the video frames in the target video. Taking the target video editing operation as an example, assuming that a user generates a video editing command by operating a control corresponding to intelligent matting after introducing the target video, the application performs intelligent matting on the target video in accordance with the video editing command. If intelligent matting is not completely completed, the user can input a cancel command to cancel intelligent matting on the target video. When canceling intelligent matting, because intelligent matting on the target video is not completely completed, corresponding target video frames (i.e., matting results) exist for some video frames.

[0096] In one possible case, if there is no corresponding target video frame at the specified video frame position, regardless of whether the current first thread is performing a target video editing operation on the target video, it is necessary to determine a video editing processing mode corresponding to the first thread based on the specified video frame position, and the first thread performs a target video editing operation on the target video from the specified video frame position according to the determined video editing processing mode.

[0097] Here, the implementation form for determining the video editing processing mode corresponding to the first thread based on the specified video frame position can be referred to the above content, and will not be further described here.

[0098] In another possible case, if a corresponding target video frame exists at the specified video frame position and there is no process currently performing a target effect on the video to be processed, since video encoding is performed in order of video frame order, it is determined whether a corresponding target video frame exists for each frame, starting from the frame next to the specified video frame position, until the first video frame position where no corresponding target video frame exists is determined, and the first thread can perform the target video editing operation on the video to be processed from the first video frame position where no corresponding target video frame exists, according to the first processing mode or the second processing mode.

[0099] In this scenario, whether the first thread adopts the first processing mode or the second processing mode may be determined depending on whether the specified video frame position is a preset video frame position or a video frame position indicated by the first jump instruction.

[0100] In another possible case, if a corresponding target video frame exists at the specified video frame position and a process currently executing a target effect on the target video exists, the process can continue to run. This eliminates the need to update the decoder, thereby reducing resource consumption associated with updating the decoder due to switching effect processing modes. For example, if the specified video frame position is the video frame position indicated by the second jump instruction, the first thread is performing a target video editing operation on the target video according to one video editing processing mode, and a corresponding target video frame may exist at the video frame position indicated by the second jump instruction. Therefore, there is no need to switch the video editing processing mode, i.e., the first thread is not suspended.

[0101] Here, if the designated video frame position is a preset video frame position or a video frame position indicated by a first jump command, the video editing processing mode can be determined by referring to the above-mentioned method. If the designated video frame position is a video frame position indicated by a second jump command, the video editing processing mode can be determined as a second processing mode.

[0102] S307: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where the video frame position at which the target video editing operation is being performed precedes the corresponding video frame position in the target video at which the target video frame is being presented.

[0103] While the first thread is performing the target video editing operation on the target video based on S305 or S306, the application can perform playback using the second thread in response to a playback command. Specifically, step S307 in this embodiment is similar to step S203 in the embodiment shown in Figure 2, and reference may be made to the detailed description of the embodiment shown in Figure 2, and for the sake of brevity, further description will not be provided here.

[0104] In a video editing scenario, the method of this embodiment determines whether to switch the video editing processing mode by analyzing whether a corresponding target video frame exists at a specified video frame position and whether a process is currently performing a target video editing operation on the video being processed, thereby satisfying the user's preview needs and solving the problem of the user's preview freezing, while also reducing the resource waste associated with frequent decoder updates and improving the processing efficiency of executing the target video editing.

[0105] 4 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 4, the method according to this embodiment includes the following steps:

[0106] S401: A first thread performs a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation.

[0107] S402: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0108] Steps S401 and S402 in this embodiment are similar to steps S101 and S102 in the embodiment shown in FIG. 1, respectively, and reference may be made to the detailed description of the embodiment shown in FIG. 1, and for the sake of brevity, no further description will be given here.

[0109] S403: In response to the playback command, switch a video editing processing mode to a third processing mode, and perform a target video editing operation on the target video according to the third processing mode by a first thread.

[0110] The third processing mode is a mode in which the video frame position at which the target effect is to be executed is determined according to the preview playback speed.

[0111] For example, if the video to be processed has 100 frames, in steps S401 and S402, the target video editing operation has already been performed on the first to tenth video frames according to the determined video editing processing mode, and the corresponding target video frames have been obtained. When the application receives a playback command, the second thread sequentially renders the target video frames corresponding to the first to tenth video frames and plays the target video frames corresponding to the first to tenth video frames, respectively, according to the set playback speed. Assuming that playback has now reached the tenth frame, it is detected that the next video frame to be played (i.e., the eleventh frame) does not have a corresponding target video frame. If the time required to perform the target video editing operation is greater than the playback speed, performing the target video editing operation on the eleventh video frame in order of the earliest video frames will fail to meet the playback needs, inevitably resulting in serious playback freezes and problems such as image distortion. Therefore, the video editing processing mode is switched to a third processing mode, and the first thread determines the video frame position at which the target video editing operation is to be performed according to the playback speed, thereby ensuring that the video frame position at which the target video editing operation is being performed always precedes the corresponding video frame position in the video being processed of the presented target video frame, and by performing the target video editing operation on the video frame that precedes the preview playback progress, the preview playback needs are met and problems such as serious freezing of preview playback and screen distortion are solved.

[0112] In addition, when the video editing processing mode is the third processing mode, the video frame ahead of the playback progress on which the target video editing operation is to be performed may be dynamically determined in combination with one or more factors such as the preview playback speed, the processing time length for performing the target video editing operation on a predetermined single video frame (i.e., the average time required for the target video editing operation), the video frame position on which the target video editing operation is currently being performed, and the video frame on which the target video editing operation has already been performed.

[0113] Continuing with the example in the previous paragraph, for example, if the first thread determines to perform a target video editing operation on the 15th video frame according to the third processing mode, and the target effect has already been performed on the 15th frame, the first thread may perform the target video editing operation on the 16th video frame in the earliest video frame order (obviously, the target video editing operation is not limited to the 16th frame, but may be another video frame a certain distance after the 15th frame, for example, the 18th frame). If it is determined that there is no corresponding target video frame in the 16th video frame, the first thread performs the target video editing operation on the 16th video frame. After performing the target video editing operation on the 16th video frame, the third processing mode is subsequently used to flexibly determine the video frame position on which the target video editing operation is to be performed.

[0114] As can be seen from the above description and examples of the third processing mode, the third processing mode is a video editing processing mode responsive to a playback command. During playback of a target video frame, the third processing mode can ensure that the video frame position at which the target video editing operation is being performed always precedes the corresponding video frame position in the target video of the target video frame being played, i.e., precedes the playback progress.

[0115] In this embodiment, the video editing processing mode may be switched to the third processing mode, and the timing of the switch may be determined by one or more of the following factors:

[0116] 1. The randomness of user operations, for example, the user may repeatedly input play and pause commands; 2. Whether there is currently a process executing the target video editing operation on the target video; and 3. The target video frame obtained by executing the target video editing operation.

[0117] The influence of the above factors will now be described by way of example.

[0118] Assuming that the video to be processed has 100 frames, in steps S401 to S402, the target video editing operation has already been performed on the first to tenth video frames according to the determined video editing processing mode, and target video frames corresponding to the first to tenth video frames, respectively, have been obtained.

[0119] Case (1): Assume that an application receives a play command, updates the decoder, immediately switches the video editing processing mode to the third processing mode, and plays the target video frame from the position of the first frame. Next, the application receives a play pause command. Because the interval between the play command and the play pause command is short, the second thread may not have rendered up to the tenth frame. Suspending the current video editing processing mode process, i.e., suspending the first thread, re-updating the decoder, and switching the video editing processing mode, consumes a large amount of computing resources, thereby reducing video processing efficiency.

[0120] Case (2): During playback, whether a corresponding target video frame exists at the position of the next video frame to be played is detected in real time. If it is determined that a corresponding target video frame does not exist at the position of the next video frame to be played, and then the video editing processing mode is switched, the target video editing operation can continue to be performed on the target video according to the original video editing processing mode while playing frames 1 to 10. That is, the process of currently performing the target video editing operation is not interrupted, and the utilization rate of computing resources can be improved.

[0121] Further, based on case (2), when the application receives a playback pause command, the playback progress has not reached the progress of the target video editing operation. For example, when playing back to the eighth frame, if the application receives a playback pause command, during playback from the first frame to the eighth frame, the application also performs the target video editing operation on the eleventh and twelfth frames according to the original video editing processing mode.

[0122] In the above case (2), the application receives a play command and a play pause command, but there are corresponding target video frames for the part to be played, so there is no need to switch the video editing processing mode corresponding to the first thread, which similarly ensures smooth playback and reduces the large consumption of computing resources caused by switching the video editing processing mode. Meanwhile, during playback, the first thread also performs the target video editing operation on some video frames according to the original video editing processing mode, thereby improving video processing efficiency.

[0123] As is clear from the above description, in this step, the application may determine the timing of switching the video editing processing mode based on one or more of the above factors in response to the playback command.

[0124] In this embodiment, the method receives a playback command while the first thread is performing a target video editing operation on the target video, and in response to the playback command, switches the video editing processing mode to a third processing mode to perform the target video editing operation on a video frame of the target video, ensuring that the video frame position where the target video editing operation is being performed during playback always precedes the playback progress, thereby solving problems such as serious freezing of user preview playback and screen distortion, improving video processing efficiency, and enhancing the user experience.

[0125] Optionally, based on the embodiment shown in FIG. 4, further includes the following steps:

[0126] S404: A playback pause command is received.

[0127] S405: In response to a playback pause command, the second thread pauses playback, and the first thread continues to perform target video editing operations on video frames of the target video according to a third processing mode.

[0128] Specifically, when the application receives a playback pause command, the second thread stops rendering the target video frame, that is, pauses the playback of the target video frame.

[0129] When a playback pause command is received, there is a process currently executing a target effect on the target video, so the process does not need to be interrupted. That is, the first thread continues to execute the target video editing operation on the target video, i.e., continues to execute the target video editing operation on the video frames of the target video according to the third processing mode. In this way, the computing resources of the electronic device can be effectively utilized to perform video editing, thereby improving the utilization rate of the computing resources and thereby improving the efficiency of video processing.

[0130] Hereinafter, some possible implementations corresponding to step S403 will be described with reference to the examples shown in FIGS.

[0131] 5 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 5, the method of this embodiment includes the following steps:

[0132] S501: A first thread executes a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-executes the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by executing the target video editing operation.

[0133] S502: In response to a playback command, a second thread performs rendering on each of the target video frames and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0134] Steps S501 and S502 in this embodiment are similar to steps S401 and S402 in the embodiment shown in FIG. 4, respectively, and reference may be made to the detailed description of the embodiment shown in FIG. 4, and for the sake of brevity, no further description will be given here.

[0135] S503: In response to the playback command, perform a target video editing operation on a video frame of the processing target video according to a third processing mode from the video frame position where the target video editing operation is being performed when the preview playback command is obtained.

[0136] In this step, when the first thread receives the playback command, the first thread may be executing a target video editing operation on a certain video frame. In such a case, the video frame position at which the video editing processing mode is switched is the video frame position at which the target video editing operation is being executed. The application may have just executed the target video editing operation on a certain video frame, but may not have started executing the target video editing operation on the next video frame. In such a case, the video frame position at which the video editing processing mode is switched is the position of the next video frame at which the target video editing operation is to be executed.

[0137] Here, when the application obtains a playback command, it may immediately switch the video editing processing mode corresponding to the first thread to a third processing mode, and perform a target video editing operation on a video frame of the processing target video according to the third processing mode from the position of the video frame determined to switch the video editing processing mode.

[0138] The order in which S502 and S503 are executed does not matter.

[0139] The method of this embodiment involves receiving a playback command while performing a target video editing operation on a target video, and, in response to the playback command, using a first thread to perform a target video editing operation on a video frame of the target video according to a third processing mode, starting from the video frame position where the target video editing operation was being performed when the playback command was received. This implementation has simple logic and does not require complex decisions. Furthermore, the third processing mode ensures that the video frame position where the target video editing operation was being performed during playback always stays ahead of the playback progress. This solves problems such as serious freezes in preview playback performed by users, resulting in screen distorts, improves video processing efficiency, and enhances the user experience.

[0140] Optionally, based on the embodiment shown in FIG. 5, further includes the following steps:

[0141] S504: A playback pause command is acquired.

[0142] S505: In response to a playback pause command, the second thread pauses playback, and the first thread continues to perform target video editing operations on video frames of the target video according to a third processing mode.

[0143] Specifically, when the application receives a playback pause command, the second thread stops rendering the target video frame, that is, pauses the playback of the target video frame.

[0144] When a playback pause command is received, there is a process currently executing a target effect on the target video, so the process does not need to be interrupted. That is, the first thread continues to execute the target video editing operation on the target video, i.e., continues to execute the target video editing operation on the video frames of the target video according to the third processing mode. In this way, the computing resources of the electronic device can be effectively utilized to perform video editing, thereby improving the utilization rate of the computing resources and thereby improving the efficiency of video processing.

[0145] 6 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 6, the method according to this embodiment includes the following steps:

[0146] S601: A first thread performs a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation.

[0147] S602: In response to a playback command, a second thread performs rendering on each of the target video frames and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0148] Steps S601 and S602 in this embodiment are similar to steps S401 and S402 in the embodiment shown in FIG. 4, respectively, and reference may be made to the detailed description of the embodiment shown in FIG. 4, and for the sake of brevity, no further description will be given here.

[0149] S603: In response to a playback command, determine a switching position corresponding to a third processing mode based on a processing time length for performing a target video editing operation on a predetermined single video frame, a playback speed, and a video frame position at which the target video editing operation is currently being performed.

[0150] For example, a maximum time length for which the current video editing processing mode can be continuously executed may be determined based on the position of the video frame on which the target video editing operation is currently being executed and the playback speed. Then, based on the determined maximum time length and a predetermined processing time length for executing the target video editing operation on a single video frame, a number S of video frames that can be processed in the current video editing processing mode within the maximum time length is determined. Next, a switching position for the video editing processing mode is determined from among S consecutive video frames from the video frame position on which the target video editing operation is currently being executed. Here, the switching position for the video editing processing mode may be any one of the S consecutive video frames from the video frame position on which the target video editing operation is currently being executed.

[0151] In some possible implementations, to reduce errors in switching video editing processing modes, for example, switching too late and causing the processing progress of the target video editing operation to not meet the rendering progress, a video frame among S consecutive video frames that is closest to the video frame on which the target video editing operation is currently being performed may be set as the switching position.

[0152] It should be understood that when determining the maximum duration, since the target video editing operation for the video frame on which the target video editing operation is currently being performed has not been completed, the maximum duration may be calculated from the frame immediately preceding the video frame on which the target video editing operation is currently being performed, thereby improving the accuracy of the calculation result.

[0153] The order in which S602 and S603 are executed does not matter.

[0154] S604: The first thread executes the target video editing operation on the video frames of the target video from the switching position according to the third processing mode.

[0155] For details of the third processing mode, please refer to the description in the embodiment shown in Figure 4. For the sake of brevity, no further description will be given here.

[0156] In this embodiment, a playback command is received while a target video editing operation is being performed on a target video. In response to the playback command, a video editing processing mode switching position is flexibly determined based on the time required to perform the target video editing operation on a single video frame, the playback speed, and the video frame position where the target video editing operation is currently being performed. When the progress of the target video editing operation reaches the switching position, the video editing processing mode is switched to a third processing mode, thereby improving the flexibility of video editing processing mode switching. Furthermore, the third processing mode ensures that the video frame position where the target video editing operation is being performed always precedes the playback progress during playback. This solves problems such as serious freezing of preview playback performed by users and screen distortion, improves video processing efficiency, and contributes to an improved user experience.

[0157] Optionally, based on the embodiment shown in FIG. 6, further includes the following steps:

[0158] S605: A playback pause command is obtained.

[0159] S606: In response to a playback pause command, the second thread pauses playback, and the first thread continues to perform target video editing operations on video frames of the target video according to a third processing mode.

[0160] Specifically, when the application receives a playback pause command, the second thread stops rendering the target video frame, that is, pauses the playback of the target video frame.

[0161] When a playback pause command is received, there is a process currently executing a target effect on the target video, so the process does not need to be interrupted. That is, the first thread continues to execute the target video editing operation on the target video, i.e., continues to execute the target video editing operation on the video frames of the target video according to the third processing mode. In this way, the computing resources of the electronic device can be effectively utilized to perform video editing, thereby improving the utilization rate of the computing resources and thereby improving the efficiency of video processing.

[0162] 7 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 7, the method according to this embodiment includes the following steps:

[0163] S701: A first thread performs a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation.

[0164] S702: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0165] Steps S701 and S702 in this embodiment are similar to steps S401 and S402 in the embodiment shown in FIG. 4, respectively, and reference may be made to the detailed description of the embodiment shown in FIG. 4, and for the sake of brevity, no further description will be given here.

[0166] S703: In response to a playback command, detect in real time whether there is a corresponding target video frame in the next video frame to be played.

[0167] If it is detected that there is no corresponding target video frame in the next video frame to be played, S704 is executed.

[0168] The order in which S702 and S703 are executed does not matter.

[0169] S704: The first thread performs a target video editing operation on a video frame of the processing target video according to a third processing mode, from the position of the next target video frame to be played.

[0170] Note that performing a target video editing operation according to the third processing mode from the position of the next target video frame to be played does not mean that the next video frame to be played is the video frame corresponding to the next video frame position to be played. For example, if the next video frame to be played is the tenth frame of the current video frame but there is no corresponding target video frame at the tenth frame, the first thread performs the target video editing operation according to the third processing mode from the tenth frame. However, the determined video frame position to be performed for the target video editing operation may be the thirteenth frame, the fifteenth frame, etc. in the current video. This ensures that the video frame position at which the target video editing operation is being performed is ahead of the playback progress.

[0171] In this embodiment, a playback command is received while a target video editing operation is being performed on a target video. In response to the preview playback command, if it is detected that the next video frame to be played back does not contain a corresponding target video frame, the video editing processing mode is switched. This minimizes resource consumption caused by frequent switching of video editing processing modes due to frequent user operations. Furthermore, the playback processing mode ensures that the video frame position where the target video editing operation is being performed during playback always stays ahead of the playback progress. This solves the serious problem of freezing preview playback performed by the user and causing screen distortion, improves video processing efficiency, and contributes to an improved user experience.

[0172] Optionally, based on the embodiment shown in FIG. 7, further includes the following steps:

[0173] S705: A playback pause command is obtained.

[0174] S706: In response to a playback pause command, the second thread pauses playback, and the first thread continues to perform target video editing operations on video frames of the target video according to a third processing mode.

[0175] Specifically, when the application receives a playback pause command, the second thread stops rendering the target video frame, that is, pauses the playback of the target video frame.

[0176] When a playback pause command is received, there is a process currently executing a target effect on the target video, so the process does not need to be interrupted. That is, the first thread continues to execute the target video editing operation on the target video, i.e., continues to execute the target video editing operation on the video frames of the target video according to the third processing mode. In this way, the computing resources of the electronic device can be effectively utilized to perform video editing, thereby improving the utilization rate of the computing resources and thereby improving the efficiency of video processing.

[0177] FIG. 8 is a flowchart of a video processing method according to another embodiment of the present disclosure.

[0178] Here, since the application supports video frame position jumping, the application can also obtain a jump command while the application is playing each target video frame, that is, the method of this embodiment can also be performed based on any one of the embodiments of Figures 1 to 7 above.

[0179] As shown in FIG. 8, the method of this embodiment includes the following steps:

[0180] S801: Obtain the third jump instruction.

[0181] S802: In response to the third jump command, re-determine the video editing processing mode depending on whether a corresponding target video exists at the video frame position indicated by the third jump command and whether the first thread is performing the target video editing operation on the video to be processed.

[0182] S803: The first thread performs a target video editing operation on a video frame of the target video according to the redetermined video editing processing mode.

[0183] A second thread performs rendering on a target video frame corresponding to the video frame position indicated by the jump instruction, and presents a target video frame corresponding to the video frame position indicated by a third jump instruction.

[0184] In some cases, when a user inputs a third jump command during playback, the application may switch the playback state to pause playback. In other cases, when a user inputs a third jump command during playback, the application may play the target video frame from the video frame position indicated by the third jump command.

[0185] In this embodiment, when the application switches the playback state to a playback pause state in response to the third jump command, there may be several cases: Case (a): If there is a corresponding target video frame at the video frame position indicated by the third jump instruction and there is a process currently performing a target video editing operation on the target video, the current process is not interrupted and the first thread continues to perform the target video editing operation on the target video according to the original video editing processing mode.

[0186] Since there is a corresponding target video frame at the video frame position indicated by the third jump command, the application can present the target video frame corresponding to the video frame position indicated by the third jump command. Since the application can be in a preview playback pause state, no freezing phenomenon occurs. Based on this, the application can continue to execute the ongoing process.

[0187] Case (b): Since a corresponding target video frame exists at the video frame position indicated by the third jump command, but there is no process currently performing the target effect on the video to be processed, it may be determined whether a corresponding target video frame exists for each frame, starting from the frame next to the video frame position indicated by the third jump command, and the target video editing operation may be performed on the video to be processed according to the second processing mode from the first video frame position where the determined corresponding target video frame does not exist.

[0188] Case (c): If there is no corresponding target video frame at the video frame position indicated by the third jump command, perform the target video editing operation on the video frame of the processing target video from the video frame position indicated by the third jump command according to the second processing mode.

[0189] In response to the third jump command, when the application starts playing the target video frame from the video frame position indicated by the third jump command, the video editing processing mode is switched to the third processing mode, and when starting to play the target video frame from the video frame position indicated by the third jump command, the video frame position where the target video editing operation is being performed always precedes the current playback progress, thereby realizing that playback does not freeze and satisfying the user's preview needs.

[0190] Here, the implementation form for determining the timing of switching the video editing processing mode may be the form shown in any one of the embodiments shown in Figures 5 to 7 described above, and reference may be made to the detailed description of the embodiment shown in Figures 5 to 7 described above, and for the sake of simplicity, no further description will be given here.

[0191] The method according to this embodiment determines whether to switch the video editing processing mode by analyzing whether a corresponding target video frame exists at the video frame position indicated by the third jump command and whether the target video editing operation is currently being performed, and also takes the playback status into consideration when determining whether to switch the video editing processing mode to ensure a real-time display effect.

[0192] 9 is a flowchart of a video processing method according to another embodiment of the present disclosure. As shown in FIG. 9, the method of this embodiment includes the following steps:

[0193] S901: A first thread performs a target video editing operation on a video frame at a specified video frame position in a video to be processed, starting from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation.

[0194] S902: In response to a playback command, a second thread performs rendering on each of the target video frames, and presents each of the target video frames, where a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video at which the target video frame is being presented.

[0195] Steps S901 and S902 in this embodiment are similar to steps S101 and S102 in the embodiment shown in FIG. 1, respectively, and reference may be made to the detailed description of the embodiment shown in FIG. 1, and for the sake of brevity, no further description will be given here.

[0196] S903: After performing the target video editing operation on the last video frame of the video to be processed, the first thread performs the target video editing operation on the video frames of the video to be processed according to a fourth processing mode, starting from the position of the first video frame of the video to be processed.

[0197] The fourth processing mode is an adaptive video editing processing mode in which target video editing operations are sequentially performed on video frames in the target video that do not have corresponding target video frames.

[0198] When the application executes according to any one or more of the video editing processing modes from the first processing mode to the third processing mode up to the last video frame position of the video to be processed, it may switch to the fourth processing mode and make full use of the computing resources to sequentially perform target video editing operations on video frames in the video to be processed that do not have corresponding target video frames.

[0199] Next, the case where the video to be processed includes one video clip and the case where the video to be processed includes multiple video clips will be described separately.

[0200] 1. The video to be processed contains one video clip.

[0201] Assuming that the video to be processed includes one video clip, the video clip will be referred to as video clip A1. When it is detected that the target video editing operation has been performed on the last video frame of video clip A1, the video editing processing mode is switched to a fourth processing mode, and the target video editing operation is sequentially performed on the video frames in video clip A1 on which the target video editing operation has not been performed, starting from the first video frame position of video clip A1 and proceeding in order from the earliest video frame position.

[0202] For example, assume that video clip A1 includes 100 frames. A target video editing operation is performed on frames 50 to 100 in accordance with the second processing mode. Upon receiving the completion of the target video editing operation on frame 100, the processing mode is switched to the fourth processing mode, and the target video editing operation is performed on frames 1 to 49, frame by frame, starting from frame 1.

[0203] For example, assume that video clip A1 includes 100 frames. In the first processing mode, target video editing operations are performed on the first, fifth, tenth, fifteenth, and twentieth frames. From the thirtieth frame, the processing mode is switched to the second processing mode, and target video editing operations are performed on the thirtieth to hundredth frames. Upon detecting the completion of the target video editing operation on the hundredth frame, the processing mode is switched to the fourth processing mode, and target video editing operations are sequentially performed on frames 2 to 4, 6 to 9, 11 to 14, and 16 to 19, starting from the first frame, on which target video editing operations have not been performed.

[0204] 2. The video to be processed contains multiple video clips.

[0205] Assuming that the video to be processed includes a plurality of video clips, the plurality of video clips are respectively designated as video clips B1 to B2. N Video Clip B n When detecting that the target video editing operation has been performed on the last video frame of video clip B, the video editing processing mode is switched to the fourth processing mode, and n From the first video frame position of video clip B n The target video editing operation is sequentially performed on the video frames in which the target video editing operation has not been performed, in order from earliest to latest, where N is an integer equal to or greater than 2, and n is an integer equal to or greater than 1 and equal to or less than N.

[0206] In other words, if the video to be processed includes multiple video clips, when it is detected that the target video editing operation has been performed on the last video frame of a video clip, the effect processing task of the fourth processing mode may be executed preferentially within the video clip.

[0207] In practical applications, each video clip corresponds to one decoder, and the target video editing operation task of the fourth processing mode is executed within the video clip, which can reduce the consumption of computing resources associated with updating the decoder due to switching of video clips. Also, by executing the target video editing operation task of the fourth processing mode within the video clip, the computing resources can be fully utilized and the video processing efficiency can be improved.

[0208] For example, assume that the video to be processed includes three video clips, namely, video clips B1, B2, and B3. Currently, a target video editing operation is being performed on video clip B2 according to the second processing mode. When it is detected that the target video editing operation has been performed on the last video frame of video clip B2, the processing mode is switched to the fourth processing mode, and the target video editing operation is sequentially performed on video frames in video clip B2 that do not have corresponding target video frames, starting from the first video frame position of video clip B2.

[0209] If there are corresponding target video frames for all video frames in video clip B2, video clip B2 may be marked as "completed." If no other operation command has been received, the target video editing operation may be performed on video clip B1 and video clip B3.

[0210] Here, an example will be described in which the target video editing operation for video clip B2 has been completed and the next video clip to be processed is video clip B1.

[0211] It is possible that a target video editing operation has never been performed on the video clip B1. Therefore, there is no corresponding target video frame for any of the video frames in the video clip B1. In this case, the target video editing operation may be first performed sequentially on each video frame of the video clip B1 according to the first processing mode, starting from the first video frame of the video clip B1. Based on this, after it is detected that the target video editing operation has been performed on the last video frame of the video clip B1, the processing mode is switched to the fourth processing mode, and the target video editing operation is sequentially performed on the video frames in the video clip B1 for which there is no corresponding target video frame.

[0212] It is possible that a target video editing operation has been performed on the video clip B1. Therefore, there are corresponding target video frames for some video frames in the video clip B1. In this case, the target video editing operation is sequentially performed on the video frames in the video clip B1 that do not have corresponding target video frames, starting from the first video frame position of the video clip B1, according to the fourth processing mode.

[0213] If there are corresponding target video frames for all video frames in the video clip B1, the video clip B1 is marked as "completed", and it can be determined based on the marking that there is no need to perform the target video editing operation on the video clip B1.

[0214] If the next video clip to be processed is video clip B3, the implementation form is similar to the implementation form when the next video clip to be processed is video clip B1, and reference may be made to the detailed description above, and no further explanation will be given here.

[0215] In the method of this embodiment, when it is detected that the target video editing operation has been performed on the last video frame of the video to be processed while performing the target video editing operation on the video frames of the video to be processed, the method switches the video editing processing mode to a fourth processing mode, and sequentially performs the target video editing operation on the video frames in the video to be processed that do not have corresponding target video frames.

[0216] 10 is a schematic framework diagram of a video processing device according to an embodiment of the present disclosure. Referring to the video processing device shown in FIG. 10, it includes three entity layers, which are a graph layer, an interaction layer, and an algorithm processing layer, respectively.

[0217] The graph layer includes a decoding thread and a rendering thread, the decoding thread includes a decoder reader unit, and the rendering thread includes a clip preprocessing unit.

[0218] The decoding control unit is for updating the algorithm processing tasks being executed in the algorithm processing layer and synchronously updating the rendering position according to operation commands input by the user, such as jump commands, play commands, etc.

[0219] The video pre-processing unit is for determining whether a corresponding target video frame exists at the current video frame position, and if so, reading the target video frame, uploading texture, rendering, and displaying on the screen; if not, reading the corresponding target video frame data from the previous video frame on which the target video editing operation was performed, uploading texture, rendering, and displaying on the screen.

[0220] The interaction layer includes a task scheduling module and a cache control module.

[0221] Here, the task scheduling module is for generating video editing tasks and distributing the video editing tasks to the algorithm processing layer.

[0222] The task scheduling module may generate a video editing task based on an operation command input by a user, or based on information for switching the video editing processing mode to a self-expanding processing mode in accordance with an instruction returned from the algorithm processing layer. Therefore, the task scheduling module may be considered to perform task scheduling through an external trigger policy and a self-expanding policy.

[0223] In the overall framework of the video processing device, an algorithm task is the smallest processing unit. Each time a video editing operation for a clip is added, one algorithm task, i.e., an algorithm task (task Param) object, is created and one task identifier (task ID) is returned. One algorithm task object uniquely corresponds to one task identifier (task ID).

[0224] An algorithm task (task Param) object is a structure in which all parameters required for algorithm processing in one clip are recorded, and which has a reference to one algorithm processing instance (task Process wrapper).

[0225] The algorithm processing instance (task process wrapper) has a Lab algorithm model instance that corresponds to it one-to-one and manages the corresponding contents. The algorithm processing instance holds one main file (MANE File), records information about all algorithm results (i.e., target video frames) of this path file (e.g., timestamp information indicating the video frame position, e.g., PTS information), and provides query interfaces.

[0226] In practical applications, Lab algorithm model instances have large data volumes. For example, in intelligent matting, the Lab algorithm model instances are approximately 100M. To reduce the risk of out of memory (OOM), Lab algorithm model instances are discarded immediately after use.

[0227] The cache control module returns a target video frame to the rendering thread based on the target video frame stored in the cache, and if there is no corresponding target video frame in the cache area, returns an access path in the external memory space of the target video frame to the rendering thread, and if there is no target video frame in the external memory space, returns NULL to the rendering thread.

[0228] The algorithm layer may be referred to by other names such as an algorithm interaction layer, an intermediate layer, etc., and the present disclosure is not limited in this respect.

[0229] The algorithm processing layer includes an algorithm task management module, which provides an access interface to the outside, for example, the algorithm task management module provides an interface to add, delete, and query effect processing tasks and progress.

[0230] The algorithm task management module itself further has algorithm task (task Param) objects, algorithm process instances, and algorithm threads.

[0231] Here, the essence of an algorithm thread is a thread object, which is a thread selected from a thread pool and performs effect processing tasks on the corresponding message queue.

[0232] When the algorithm thread performs a video editing task, it may include the following steps:

[0233] Step 1: Update the appropriate decoder.

[0234] Step 2: Correct the total number of frames corresponding to the video editing task.

[0235] Step 3: Determine whether the number of processed frames is equal to the total number of frames, or whether the starting position of the target video editing operation is the last video frame of the video to be processed.

[0236] Note that whether the number of processed frames is equal to the total number of frames corresponds to condition 1 in FIG. 10, and whether the start position of the target video editing operation is the last video frame of the video to be processed corresponds to condition 2 in FIG.

[0237] Step 4: If none of the above conditions are met, determine whether a corresponding target video frame already exists for the video frame. If so, skip the execution of the target video editing operation for the video frame; if not, execute step 5.

[0238] Step 5: According to the corresponding video editing processing mode, determine whether the video frame is a video frame that should be discarded.

[0239] The video editing processing mode may be any one of the playback processing mode, jump processing mode, pre-processing mode, and self-expansion processing mode. For the meanings of the various video editing processing modes, please refer to the above explanation.

[0240] If the video editing processing mode is a playback processing mode, it is determined whether the video frame is a video frame to be discarded according to the playback speed. If it is a video frame to be discarded, there is no need to perform the target video editing operation on it; if it is not a video frame to be discarded, step 6 is performed.

[0241] When the video editing processing mode is the jump processing mode, none of the video frames should be discarded.

[0242] If the video editing processing mode is the pre-processing mode, the key frames are video frames that should not be discarded, and execute step 6. Other frames are video frames that should be discarded.

[0243] When the video editing processing mode is the self-expansion mode, any video frame that does not have a corresponding target video frame is a video frame that should not be discarded, and any video frame that has a corresponding target video frame is a video frame that should be discarded.

[0244] Step 6: Perform a target video editing operation on the video frame to obtain a corresponding target video frame.

[0245] Step 7: Store the target video frame corresponding to the video frame.

[0246] Here, a target video frame corresponding to a video frame may be stored in an external memory space and a cache simultaneously. When rendering in a rendering thread, if a corresponding target video frame exists in the cache, the data may be read directly from the cache. If a corresponding target video frame does not exist in the cache, the corresponding target video frame is read from the external memory space. In this way, the number of data input / output operations can be reduced, and video processing efficiency can be improved.

[0247] Furthermore, when storing a target video frame corresponding to a video frame, information about the target video frame may be passed to a callback service, which may then invoke a service thread to perform related operations. For example, while performing a target video edit, the callback service may provide feedback to the service thread about the progress of the current target video edit.

[0248] By adopting the framework shown in Figure 10 above, the algorithm thread can perform target video editing operations on the target video according to multiple video editing processing modes, ensuring that the algorithm thread's execution progress always precedes the rendering thread's progress, thereby solving the problem of the user preview freezing. Furthermore, after accepting a task to perform a target video editing operation on a video frame of the target video, the algorithm thread can execute independently without affecting the upper-level coding thread and rendering thread. This realizes parallel processing among the coding thread, algorithm thread, and rendering thread, solving the problem of the algorithm thread taking a long time to process, blocking the rendering thread and freezing the user preview.

[0249] Fig. 11 is a schematic diagram of the life cycle of each thread in the embodiment shown in Fig. 10, according to one embodiment of the present disclosure. As shown in Fig. 11, a frame skipping thread, a rendering thread, a service thread, and an algorithm thread are included.

[0250] The frame skipping thread is for performing synchronous frame skipping. The rendering thread is for rendering target video frames for playback. The service thread controls the algorithm thread to perform target video editing operations for each video frame of the target video according to the determined video editing processing mode, and controls pausing and starting playback. The algorithm thread is for performing target video editing operations for the corresponding video frames according to the instructions of the service thread.

[0251] Upon receiving a video editing command to perform a target video editing operation on each video frame of the target video, the service thread first sets the video editing processing mode to a pre-processing mode or a jump processing mode, and controls the algorithm thread to run according to the set video editing processing mode to perform the target video editing operation on the video frames of the target video. As shown in Figure 11, this process requires sequential buffering of the corresponding target video frames.

[0252] When playback is required, the service thread first suspends the algorithm thread, sets the video editing processing mode to playback processing mode, and controls the algorithm thread to run the algorithm according to the playback processing mode to perform the target video editing operation on the video frames of the video being processed. As shown in Figure 11, this process still requires sequential buffering of the corresponding target video frames. Simultaneously, the service thread controls the rendering thread to read the corresponding target video frames from the cache and render and display them for user preview.

[0253] When preview playback is paused, the service thread takes control of the rendering thread and pauses playback.

[0254] When jumping a video frame position, the service thread first suspends the algorithm thread, sets the video editing processing mode to a jump processing mode, controls the algorithm thread, and runs the algorithm according to the jump processing mode to perform a target video editing operation on a video frame of the target video from the final jumped video frame position. As shown in Figure 11, this process still requires synchronously buffering a corresponding target video frame from the final jumped video frame position. Synchronously, the service thread controls the rendering thread to present the target video frame at the corresponding video frame position.

[0255] After the target video editing operation is performed on the last video frame of the target video, the service thread sets the video editing processing mode to the self-expanding processing mode and controls the algorithm thread to sequentially perform the target video editing operation on the video frames on which the target video editing operation has not been performed, starting from the first video frame position of the target video. As shown in Figure 11, this process still requires sequential buffering of the corresponding target video frames.

[0256] When the execution of the target video editing operation on the video frame being processed is canceled or stopped, the service thread takes control of the algorithm thread, stops the running of the algorithm, reclaims the resources occupied by the algorithm thread, and then reclaims the rendering thread and the algorithm thread.

[0257] As shown in Figures 10 and 11, through the framework shown in Figure 10, in combination with the interactions between threads shown in Figure 11, the execution of the target video editing operation for each video frame of the video to be processed is realized, which effectively solves the problem of the user's preview playback freezing.

[0258] 12 is a schematic diagram of a configuration of a video processing device according to an embodiment of the present disclosure. As shown in FIG. 12, a video processing device 1200 according to this embodiment includes: a first processing module 1210 for executing, by a first thread, a target video editing operation on a video frame at the specified video frame position in a target video, from a specified video frame position, and pre-executing the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by executing the target video editing operation; and a second processing module 1220 for rendering each of the target video frames by a second thread in response to a playback command and presenting each of the target video frames, wherein a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the target video of the target video frame being presented.

[0259] In one possible embodiment, the video processing device 1200 may further include a display module 1240. The display module 1240 is for presenting each target video frame.

[0260] In one possible embodiment, the specified video frame position is determined based on a video frame position positioned when a video editing command is obtained, the video editing command being for instructing the target video editing operation to be performed on the processing target video, and the video frame position positioned when the video editing command is obtained is a preset video frame position or a video frame position specified by a first jump command.

[0261] Accordingly, the video processing device 1200 may further include an acquisition module 1230 .

[0262] The obtaining module 1230 is for obtaining a video editing instruction and obtaining a first jump instruction.

[0263] In one possible embodiment, the specified video frame position is determined based on a video frame position specified in a second jump instruction, and the second jump instruction is an instruction following a video editing instruction for performing the target video editing operation on the target video.

[0264] Accordingly, the acquisition module 1230 is further used to acquire a second jump instruction.

[0265] In one possible embodiment, if the specified video frame position is determined based on the video frame position positioned when the video editing command is acquired, the first processing module 1210 is used to perform, by a first thread, a target video editing operation on the video frame at the specified video frame position in the video to be processed from the specified video frame position, and to pre-execute the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation; and further to determine a video editing processing mode corresponding to the first thread based on the specified video frame position, wherein the video editing processing mode is a first processing mode in which the target video editing operation is performed on a key frame, or a second processing mode in which the target video editing operation is performed on each frame.

[0266] In one possible embodiment, the first processing module 1210 is specifically used to determine the video editing processing mode corresponding to the first thread as the first processing mode when the specified video frame position is the preset video frame position, and to determine the video editing processing mode corresponding to the first thread as the first processing mode or the second processing mode when the specified video frame position is the video frame position specified by a first jump command.

[0267] In one possible embodiment, the first processing module 1210 is specifically used to determine whether a corresponding target video frame exists at the specified video frame position, and if no corresponding target video frame exists at the specified video frame position, determine a video editing processing mode corresponding to the first thread according to whether the specified video frame position is the preset video frame position or the video frame position specified by the first jump command.

[0268] In one possible embodiment, the first processing module 1210 is specifically used to determine the video editing processing mode corresponding to the first thread as the second processing mode if a corresponding target video frame exists at the specified video frame position.

[0269] Accordingly, the second processing module 1220 is specifically used to determine whether a corresponding target video frame exists for each frame from the specified video frame position onwards until the first video frame position where no corresponding target video frame exists is determined, and to perform the target video editing operation on the video frames of the processing target video from the first video frame position where no corresponding target video frame exists according to the second processing mode using the first thread.

[0270] In one possible embodiment, if the specified video frame position is determined based on the video frame position specified by the second jump command, the first processing module 1210 uses a first thread to perform a target video editing operation on the video frame at the specified video frame position in the video to be processed from the specified video frame position, and pre-performs the target video editing operation on each video frame after the specified video frame position to obtain each target video frame obtained by performing the target video editing operation. If it is determined that there is no corresponding target video frame at the specified video frame position, the first processing module 1210 determines the video editing processing mode corresponding to the first thread as the second processing mode.

[0271] In one possible embodiment, if a corresponding target video frame exists at the specified video frame position and the first thread is performing the target video editing operation on the target video, the first processing module 1210 does not interrupt the first thread, allowing the first thread to continue performing the target video editing operation on the target video.

[0272] In one possible embodiment, the first processing module 1210 is further configured to switch the video editing processing mode to a third processing mode in response to the playback command, the third processing mode being a mode in which the video frame position at which the target video editing operation is to be performed is determined according to the playback speed, and the first thread is configured to perform the target video editing operation on the video frames of the video to be processed according to the third processing mode.

[0273] In one possible embodiment, the first processing module 1210 is specifically used to detect in real time whether a next target video frame to be played exists in response to the playback command, and when it detects that a next target video frame to be played does not exist, to perform the target video editing operation on the video frames of the processing target video according to the third processing mode from the position of the next target video frame to be played using the first thread.

[0274] In one possible embodiment, the first processing module 1210 is specifically used to, in response to the playback command, perform the target video editing operation on a video frame of the processing target video according to the third processing mode by the first thread from the video frame position where the target video editing operation was being performed when the playback command was obtained.

[0275] In one possible embodiment, the first processing module 1210 is specifically used to, in response to the playback command, determine a switching position corresponding to the third processing mode based on the processing time length for performing the target video editing operation on a predetermined single video frame, the playback speed, and the video frame position on which the target video editing operation is currently being performed, and then execute the target video editing operation on the video frame of the processing target video from the switching position according to the third processing mode using the first thread.

[0276] In one possible embodiment, the first processing module 1210 is specifically further configured to pause rendering of the target video frame by the second thread in response to the playback pause command, and the first thread continues to perform the target video editing operation on the video frame of the processing target video according to the third processing mode.

[0277] Accordingly, the acquisition module 1230 is further used to acquire a playback pause command.

[0278] In one possible embodiment, the first processing module 1210 is further used to, after performing the target video editing operation on the last video frame of the video to be processed, perform the target video editing operation on video frames of the video to be processed from the position of the first video frame of the video to be processed according to a fourth processing mode by the first thread, wherein the fourth processing mode is a mode in which the target video editing operation is sequentially performed on video frames in the video to be processed that do not have corresponding target video frames.

[0279] The video processing device according to this embodiment can be used to implement the technical solution according to any one of the above method embodiments, and since the implementation principles and technical effects are similar, reference can be made to the detailed description of the above method embodiments, and for the sake of simplicity, no further description will be given here.

[0280] 13 is a schematic diagram of the configuration of an electronic device according to an embodiment of the present disclosure. As shown in FIG. 13, an electronic device 1300 according to this embodiment includes a memory 1301 and a processor 1302.

[0281] Here, the memory 1301 may be an independent physical unit, or may be connected to the processor 1302 via a bus 1303. The memory 1301 and the processor 1302 may be integrated together and realized by hardware or the like.

[0282] The memory 1301 is used to store program instructions that can be called upon by the processor 1302 to perform the operations of any one of the method embodiments described above.

[0283] Alternatively, when a part or all of the methods of the above-described embodiments are implemented in software, the above-described electronic device 1300 may include only the processor 1302. The memory 1301 for storing a program is located outside the electronic device 1300, and the processor 1302 is connected to the memory via circuits / wiring to read and execute the program stored in the memory.

[0284] The processor 1302 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and an NP.

[0285] The processor 1302 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0286] The memory 1301 may include volatile memory, such as random-access memory (RAM). The memory may also include non-volatile memory, such as flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). The memory may also include a combination of the above types of memory.

[0287] The present disclosure further provides a readable storage medium containing computer program instructions that, when executed by at least one processor of an electronic device, cause the computer program instructions to implement the video processing method set forth in any one of the method embodiments above.

[0288] The present disclosure further provides a computer program product which, when executed by a computer, causes the computer to implement the video processing method set forth in any one of the above method embodiments.

[0289] It should be noted that, in this specification, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply that such a physical relationship or sequence exists between those entities or operations. Furthermore, the terms "comprise," "include," and any other variations thereof are intended to indicate a non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements not expressly specified or elements inherent in such process, method, article, or device. Absent more limitations, elements defined by the words "comprise..." do not exclude the inclusion of other identical elements in the process, method, article, or device that includes said elements.

[0290] The foregoing are merely specific embodiments of the present disclosure, and are used to enable those skilled in the art to understand or realize the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. performing, by a first thread, a target video editing operation on a video frame at the designated video frame position in the to-be-processed video from a designated video frame position, and pre-performing the target video editing operation on each video frame after the designated video frame position to obtain and store each target video frame obtained by performing the target video editing operation; and in response to a playback command, by a second thread, reading each target video frame, performing rendering on each said target video frame, and presenting each said target video frame, wherein a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the processed video of the target video frame being presented.

2. 2. The method of claim 1, wherein the specified video frame position is determined based on a video frame position positioned when a video editing command is acquired, the video editing command being for instructing the target video to be processed to perform the target video editing operation, and the video frame position positioned when the video editing command is acquired is a preset video frame position or a video frame position designated by a first jump command.

3. 2. The method of claim 1, wherein the specified video frame position is determined based on a video frame position specified in a second jump instruction, and the second jump instruction is an instruction following a video editing instruction for performing the target video editing operation on the processed video.

4. If the specified video frame position is determined based on a video frame position located when a video editing command is acquired, the method includes: using a first thread to perform a target video editing operation on a video frame at the specified video frame position in the processing target video from the specified video frame position; and performing the target video editing operation on each video frame after the specified video frame position in advance to obtain each target video frame obtained by performing the target video editing operation, 3. The method of claim 2, further comprising: determining a video editing processing mode corresponding to the first thread based on the specified video frame position, the video editing processing mode being a first processing mode that performs the target video editing operation on a keyframe, or a second processing mode that performs the target video editing operation on a frame-by-frame basis.

5. determining a video editing processing mode corresponding to the first thread based on the specified video frame position; If the specified video frame position is the preset video frame position, determining a video editing processing mode corresponding to the first thread as the first processing mode; 5. The method of claim 4, further comprising: if the specified video frame position is a video frame position specified by a first jump instruction, determining a video editing processing mode corresponding to the first thread as the first processing mode or the second processing mode.

6. determining a video editing processing mode corresponding to the first thread based on the specified video frame position; determining whether a corresponding target video frame exists at the specified video frame location; 5. The method of claim 4, further comprising: if there is no corresponding target video frame at the specified video frame position, determining a video editing processing mode corresponding to the first thread depending on whether the specified video frame position is the preset video frame position or a video frame position specified by the first jump instruction.

7. The method comprises: If a corresponding target video frame exists at the specified video frame position, determining a video editing processing mode corresponding to the first thread as the second processing mode; performing, by a first thread, a target video editing operation on a video frame at the specified video frame position in a target video from a specified video frame position, and performing the target video editing operation on each video frame after the specified video frame position in advance to obtain each target video frame obtained by performing the target video editing operation; determining whether a corresponding target video frame exists for each frame after the specified video frame position until a first video frame position without a corresponding target video frame is determined; 7. The method of claim 6, further comprising: performing, by the first thread, the target video editing operation on video frames of the processing target video from a first video frame position for which no corresponding target video frame exists, according to the second processing mode.

8. When the specified video frame position is determined based on the video frame position specified by a second jump instruction, the method includes: performing, by a first thread, a target video editing operation on a video frame at the specified video frame position in the processing target video from the specified video frame position; and performing the target video editing operation on each video frame after the specified video frame position in advance to obtain each target video frame obtained by performing the target video editing operation, the method including:

4. The method of claim 3, further comprising: determining a video editing processing mode corresponding to the first thread as a second processing mode if there is no corresponding target video frame at the specified video frame position.

9. 9. The method of claim 8, further comprising: if a corresponding target video frame exists at the specified video frame position and the first thread is currently performing the target video editing operation on the target video, not suspending the first thread and allowing the first thread to continue performing the target video editing operation on the target video.

10. 4. The method of claim 1, further comprising: in response to the playback instruction, switching a video editing processing mode to a third processing mode; and performing, by the first thread, the target video editing operation on video frames of the target video according to the third processing mode; wherein, in the third processing mode, the first thread determines a video frame position at which to perform the target video editing operation according to a playback speed, thereby ensuring that the video frame position at which the target video editing operation is being performed always precedes a corresponding video frame position in the target video of a presented target video frame.

11. switching the video editing processing mode to a third processing mode in response to the playback instruction and performing, by the first thread, the target video editing operation on video frames of the subject video according to the third processing mode, responsive to said play command, detecting in real time whether there is a next target video frame to be played; 11. The method of claim 10, further comprising: upon detecting that there is no next target video frame to be played, performing, by the first thread, the target video editing operation on video frames of the processing target video according to the third processing mode from the position of the next target video frame to be played.

12. switching the video editing processing mode to a third processing mode in response to the playback instruction and performing, by the first thread, the target video editing operation on video frames of the subject video according to the third processing mode, 11. The method of claim 10, further comprising: in response to the play command, performing, by the first thread, the target video editing operation on video frames of the processed video according to the third processing mode, from a video frame position where the target video editing operation was being performed when the play command was received.

13. switching the video editing processing mode to a third processing mode in response to the playback instruction and performing, by the first thread, the target video editing operation on video frames of the subject video according to the third processing mode, determining a switching position corresponding to the third processing mode based on a processing time length for performing the target video editing operation on a predetermined single video frame, a playback speed, and a video frame position on which the target video editing operation is currently being performed in response to the playback command; 11. The method of claim 10, further comprising: performing, by the first thread, the target video editing operation on video frames of the subject video from the switch position according to the third processing mode.

14. Obtaining a playback pause command; 11. The method of claim 10, further comprising: in response to the pause playback instruction, pausing rendering of the target video frames by the second thread, and the first thread continuing to perform the target video editing operations on video frames of the subject video according to the third processing mode.

15. The method comprises: and after performing the target video editing operation on the last video frame of the to-be-processed video, performing, by the first thread, the target video editing operation on video frames of the to-be-processed video from the position of the first video frame of the to-be-processed video according to a fourth processing mode; The method according to any one of claims 1 to 3, wherein the fourth processing mode is a mode in which the target video editing operation is sequentially performed on video frames in the processing target video for which no corresponding target video frame exists.

16. a first processing module configured to perform, by a first thread, a target video editing operation on a video frame at the specified video frame position in a to-be-processed video from a specified video frame position, and to previously perform the target video editing operation on each video frame after the specified video frame position, thereby acquiring and storing each target video frame obtained by performing the target video editing operation; and a second processing module configured to, in response to a playback command, read each target video frame by a second thread, perform rendering on each said target video frame, and present each said target video frame, wherein a video frame position at which the target video editing operation is being performed precedes a corresponding video frame position in the processed video of the target video frame being presented.

17. An electronic device including a memory and a processor, the memory configured to store computer program instructions; An electronic device, wherein the processor is configured to execute the computer program instructions to cause the electronic device to implement the video processing method of any one of claims 1 to 3.

18. A readable storage medium containing computer program instructions, comprising: A readable storage medium, the computer program instructions of which, when executed by at least one processor of an electronic device, cause the electronic device to implement the video processing method of any one of claims 1 to 3.

19. A computer program product which, when executed by a computer, causes the computer to implement the video processing method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Video previewing method and apparatus

    CN104967865A

  • To-be-rendered object processing method and device and terminal

    CN111459591A

  • Video data processing method and device

    CN112954459A

  • Rendering in multi-user video editing system

    JP2010252328A

  • Visual effects network-based rendering and steering

    JP2015502678A