A video processing method, a dynamic wallpaper setting method and device
By obtaining the resolution information of the source video and the playback device, the cropping frame is determined and dragged on the preview interface to crop the video frames. This solves the stretching distortion problem caused by the inconsistency in the aspect ratio of the source video and the playback device, and achieves efficient video cropping and display effects.
Patent Information
- Application Number
- CN202310091797.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-16
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-01-16
AI Technical Summary
In existing technologies, when the aspect ratio of the source video is inconsistent with the aspect ratio of the current playback device's display, the problem of video stretching and distortion has not been effectively solved.
By acquiring the resolution information of the source video and the playback device, the size of the cropping frame is determined and displayed on the preview playback interface. The user drags the cropping frame to determine the cropping area, and the video frames are cropped and re-encoded according to the cropping area to form the target video.
It enables simple and efficient video frame trimming when the aspect ratio of the source video differs from that of the playback device, avoiding stretching distortion and improving display quality.
Smart Images

Figure CN116132736B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of video processing technology, and in particular to a video processing method, a method for setting dynamic wallpapers, and a device. Background Technology
[0002] There may be a discrepancy between the aspect ratio of the source video and the aspect ratio of the display on the device currently playing the video. For example, videos from sources such as user-captured videos or downloaded videos often have multiple aspect ratios, and the user's playback device display also has multiple aspect ratios. If the aspect ratio of the source video is inconsistent with the aspect ratio of the target display, when the video is played on the target display (e.g., playing a 4:3 video on a target display with a 16:9 aspect ratio), large black bars will appear on both sides of the screen.
[0003] To match the aspect ratio of the source video to the aspect ratio of the playback device's display, and to fill the screen for a better user experience, the video frame typically needs to be cropped and / or scaled. Currently, there is no simple and efficient video processing method that can solve the video stretching and distortion problem caused by the difference between the aspect ratio of the source video and the aspect ratio of the current playback device's display. Summary of the Invention
[0004] The present invention aims to provide a video processing method, a method for setting dynamic wallpapers, and a device to solve the video stretching and distortion problem caused by the difference in aspect ratio between the source video and the current playback device display in the prior art.
[0005] To address the aforementioned technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] According to one aspect of the present invention, a video processing method is provided, the method comprising:
[0007] Obtain the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface;
[0008] Based on the first resolution information, the second resolution information, and the size information of the preview playback interface, the size information of the cropping frame used to crop video frames in the preview playback interface is determined.
[0009] The source video is decoded into video frame data and displayed on the preview playback interface, and the cropping frame is displayed on the playback screen of the video frame based on the size information of the cropping frame;
[0010] The position of the cropping area of each video frame in the first part is obtained by the user dragging the cropping frame on the playback screen of each video frame in the first part;
[0011] The cropping area corresponding to each video frame contained in the source video is determined based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame.
[0012] Each video frame of the source video is cropped based on the cropping region corresponding to each video frame contained in the source video, and the cropped video frames are re-encoded to form the target video.
[0013] Optionally, determining the size information of the cropping frame used to crop each video frame in the preview playback interface based on the first resolution information, the second resolution information, and the size information of the preview playback interface includes:
[0014] The first aspect ratio of the source video and the second aspect ratio of the current playback device are calculated based on the first resolution information and the second resolution information, respectively.
[0015] If the first aspect ratio is greater than the second aspect ratio, the size information of the cutting frame is obtained by formula (1) and formula (2):
[0016]
[0017]
[0018] If the first aspect ratio is less than the second aspect ratio, the size information of the cutting frame is obtained by formula (3) and formula (4):
[0019]
[0020]
[0021] Optionally, determining the cropping region corresponding to each video frame in the source video based on the position of the cropping region of each video frame in the first part and the size information of the cropping frame includes:
[0022] The positions of the cropping regions of each video frame in the second part are determined based on the positions of the cropping regions of each video frame in the first part. Each video frame in the second part is a video frame in the source video that has not been selected by the user by dragging the cropping frame.
[0023] The cropping region corresponding to each video frame contained in the source video is determined based on the position of the cropping region of each video frame in the first part, the position of the cropping region of each video frame in the second part, and the size information of the cropping frame.
[0024] Optionally, determining the position of the cropping region of each video frame in the second part based on the position of the cropping region of each video frame in the first part includes:
[0025] Based on each video frame of the second part, find the closest preceding and following video frames from each video frame of the first part.
[0026] The position of the cropped area of the video frame is determined based on the position of the cropped area of the preceding video frame or the position of the cropped area of the following video frame.
[0027] Optionally, determining the position of the cropped region of the video frame based on the position of the cropped region of the preceding video frame or the position of the cropped region of the following video frame includes:
[0028] The position of the cropped region of the video frame is determined by either the position of the cropped region of the preceding video frame or the position of the cropped region of the following video frame; or...
[0029] Calculate the first sequence difference between the sequence number of the video frame and the sequence number of the preceding video frame, and the second sequence difference between the sequence number of the video frame and the sequence number of the following video frame. Based on the first sequence difference, the second sequence difference, and the positions of the cropped regions of the preceding and following video frames, determine the position of the cropped region in the video frame.
[0030] Optionally, the video frame is in YUV data format.
[0031] Optionally, the method further includes:
[0032] Get the start and end times of the clip selected by the user;
[0033] The video frame data located between the start and end times of the clipping in the source video is clipped out and displayed in the preview playback interface. The clipping frame is also displayed on the playback screen of the video frame based on the size information of the clipping frame, so that the user can clip the clipped video frame data according to the playback screen of the video frame.
[0034] According to another aspect of the present invention, a method for setting a dynamic wallpaper is provided, the method comprising:
[0035] Obtain the Uniform Resource Identifier (URI) of the source video;
[0036] The source video is obtained through the URI, and the first resolution information of the source video is parsed out.
[0037] The source video is processed using any of the video processing methods described above to obtain the target video;
[0038] Set the target video as a live wallpaper.
[0039] According to another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the memory, wherein the processor executes the program to implement the steps of any of the methods described above.
[0040] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, performs the method described in any of the preceding claims.
[0041] The beneficial effects of this invention are as follows: Unlike existing technologies, in this invention, the size information of the cropping frame is determined based on the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface. The source video is decoded into video frame data and displayed on the preview playback interface. The user drags the cropping frame on the video frame playback screen of the preview playback interface to obtain the position of the cropping area of each video frame in the first part. Based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame, the cropping area corresponding to each video frame is determined. Each video frame of the source video is cropped based on the cropping area corresponding to each video frame, and then the cropped video frames are re-encoded to form the target video. Using the solution of this invention, when the aspect ratio of the source video is different from the aspect ratio of the current playback device display, the video frames of the source video can be cropped simply and efficiently according to user needs, so that the cropped video will not be stretched or distorted during playback, thus improving the display effect. Attached Figure Description
[0042] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0043] Figure 1 This is a flowchart of an optional video processing method provided in Embodiment 1 of the present invention;
[0044] Figure 2 This is a schematic diagram of video frame cropping provided in Embodiment 1 of the present invention;
[0045] Figure 3 This is a flowchart illustrating an optional method for setting a dynamic wallpaper according to Embodiment 2 of the present invention.
[0046] Figure 4 This is a schematic diagram of an optional electronic device provided in Embodiment 3 of the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0048] The technical solutions of the exemplary embodiments disclosed in this invention can be applied to various electronic devices capable of playing videos. In the exemplary embodiments described below, the electronic device is sometimes also referred to as a smart terminal device. The electronic devices involved in this disclosure may include: mobile phones, tablet computers, laptops, PDAs, projectors, electronic whiteboards, advertising machines, etc.
[0049] This invention provides a video processing method that decodes a source video into video frame data and displays a cropping frame corresponding to the current playback device on each video frame. The user drags the cropping frame to crop each video frame data to obtain the cropped target video. This solves the video stretching and distortion problem caused when the aspect ratio of the source video differs from the aspect ratio of the current playback device's display. The technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0050] Example 1
[0051] According to embodiments of the present invention, a video processing method is provided. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than that shown here.
[0052] Please see Figure 1 , Figure 1 The diagram shows an optional video processing method according to Embodiment 1 of the present invention, which is applied to the various electronic devices described above. The method includes:
[0053] Step S101: Obtain the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface.
[0054] In some embodiments of the present invention, the source video file can be obtained according to the URI (Uniform Resource Identifier) of the source video. Further parsing of the source video file can yield the first resolution information of the source video. For example, the first resolution information of the source video is 500×200, where 500 means that the source video has 500 pixels in the horizontal direction and 200 means that the source video has 200 pixels in the vertical direction.
[0055] The second resolution information of the current playback device refers to the resolution of the display screen of the current playback device. For example, the main resolutions of mobile phones are 720P (720×1280), 1080P (1080×1920), 2K (2560×1440), etc.
[0056] The size of the preview playback interface can be set according to needs. Generally, the width in the horizontal direction can be roughly equivalent to the width of the second resolution of the current playback device. For example, if the second resolution of the current playback device is 1080×1920, then the size of the preview playback interface can be set to 1080×1600.
[0057] Step S102: Based on the first resolution information, the second resolution information, and the size information of the preview playback interface, determine the size information of the cropping frame used to crop each video frame on the preview playback interface.
[0058] The size of the cropping frame is determined by the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface. Specifically, the first aspect ratio of the source video and the second aspect ratio of the current playback device are calculated based on the first and second resolution information, respectively. Then, the width and height of the cropping frame are determined based on the magnitude of the first and second aspect ratios.
[0059] If the first aspect ratio is greater than the second aspect ratio, the size information of the cutting frame is obtained through formula (1) and formula (2):
[0060]
[0061]
[0062] If the first aspect ratio is less than the second aspect ratio, the size information of the cutting frame is obtained through formulas (3) and (4):
[0063]
[0064]
[0065] For example, the source video has a first resolution of 500×200, the current playback device has a second resolution of 1080×1920, and the preview playback interface has a size of 1080×1600. Calculations show that the source video has a first aspect ratio of 5:2, and the current playback device has a second aspect ratio of 9:16. Since the first aspect ratio is greater than the second, the cropping frame height = (1080×200) / 500 = 432, and the cropping frame width = (432×1080) / 1920 = 243. Therefore, the cropping frame size is 243×432.
[0066] Step S103: The source video is decoded into video frame data and displayed on the preview playback interface, and the cropping frame is displayed on the playback screen of the video frame based on the size information of the cropping frame.
[0067] Specifically, source videos of various formats are decoded into YUV data format video frames and played in the preview playback interface. A cropping frame is displayed on the playback screen based on its size information. The size of the cropping frame can be calculated in step S102, and its initial position can be set to the center of the playback screen by default. It can be understood that when the first aspect ratio is greater than the second aspect ratio, the height of the cropping frame equals the height of the video playback screen; when the first aspect ratio is less than the second aspect ratio, the width of the cropping frame equals the width of the video playback screen. Therefore, when the first aspect ratio is greater than the second aspect ratio, the initial position of the cropping frame is centered horizontally on the video playback screen; when the first aspect ratio is less than the second aspect ratio, the initial position of the cropping frame is centered vertically on the video playback screen.
[0068] like Figure 2 As shown, after decoding a 6-second source video into several video frames, the current video frame is displayed in the preview playback interface located at the top of the screen, and a dashed cropping frame is displayed on the playback screen of the video frame. In addition, a thumbnail status bar for each video frame is displayed at the bottom of the preview playback interface, showing the position of the current video frame in the source video. Figure 2 In this case, because the first aspect ratio of the source video is significantly larger than the second aspect ratio of the current playback device, the height of the cropping frame is the same as the height of the video playback screen, but the width of the cropping frame is much smaller than the width of the video playback screen.
[0069] Step S104: Obtain the position of the cropping area of each video frame in the first part, obtained by the user dragging the cropping frame on the playback screen of each video frame in the first part.
[0070] Generally, a source video contains a large number of video frames. Optionally, when cropping the video frames of a source video, the user selects a first portion of video frames from all the video frames in the source video and uses a cropping box to select the corresponding cropping area, where the cropping area is the area contained within the cropping box.
[0071] As mentioned above, when the first aspect ratio is greater than the second aspect ratio, the height of the cropping frame equals the height of the video playback screen; when the first aspect ratio is less than the second aspect ratio, the width of the cropping frame equals the width of the video playback screen. Therefore, users only need to drag the cropping frame horizontally or vertically on the playback screen of each video frame in the preview playback interface to select the corresponding cropping area. Specifically, dragging the cropping frame provides the position information of the cropping frame in the playback screen of each video frame. Furthermore, based on the scaling relationship between the size of the video frame in the playback screen of the preview playback interface and the first resolution of the video frame, the position of the cropping frame in each video frame can be determined, that is, the position of the cropping area of each video frame in the first part can be determined.
[0072] like Figure 2 As shown in (a), on the first video frame, the user drags the cropping box horizontally to a position slightly to the right of the center of the playback screen of the first video frame to obtain the position of the cropping area of the first video frame; as shown in (a). Figure 2 As shown in (b), on the second video frame, the user drags the cropping box horizontally to the left of the middle of the playback screen of the second video frame to obtain the position of the cropping area of the second video frame.
[0073] In one embodiment of the present invention, the playback duration and playback time period of the source video can also be edited according to user needs. In some embodiments, the user-selected start time and end time of the edit are obtained; video frame data located between the start time and end time of the edit in the source video are edited out and displayed in the preview playback interface, and a cropping frame is displayed on the playback screen of the video frame based on the size information of the cropping frame, so that the user can crop the edited video frame data according to the playback screen of the video frame. In other embodiments, multiple sets of start times and end times of the edit selected by the user are obtained, the source video is edited based on the multiple sets of start times and end times of the edit, multiple edited videos with different playback time periods are obtained, and then the multiple edited videos with different playback time periods are spliced into one video. The video frame data corresponding to the spliced video is displayed in the preview playback interface, so that the user can crop the edited video frame data according to the playback screen of the video frame.
[0074] Step S105: Determine the cropping area corresponding to each video frame contained in the source video based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame.
[0075] Specifically, the positions of the cropping regions for the second part of the video frames are first determined based on the positions of the cropping regions for each video frame in the first part. The second part consists of video frames in the source video that were not selected by the user by dragging the cropping frame. Then, the cropping region corresponding to each video frame in the source video is determined based on the positions of the cropping regions in the first part, the second part, and the size information of the cropping frame. It can be understood that the size of the cropping region corresponding to each video frame in the source video can be obtained based on the size information of the cropping frame and the scaling relationship between the playback screen size of the video frame in the preview interface and the first resolution of the video frame.
[0076] Optionally, the position of the cropped area of each video frame in the second part can be determined by the following method: based on each video frame in the second part, find the closest preceding and following video frames from the video frames in the first part; determine the position of the cropped area of the video frame according to the position of the cropped area of the preceding video frame or the position of the cropped area of the following video frame.
[0077] In some embodiments of the present invention, for videos with small frame movement, the position of the cropped area of the previous video frame or the position of the cropped area of the subsequent video frame is taken as the position of the cropped area of the video frame for each video frame in the second part.
[0078] In other embodiments of the present invention, for videos with large frame movement, based on each video frame of the second part, a first sequence difference between the sequence number of the video frame and the sequence number of the previous video frame, and a second sequence difference between the sequence number of the video frame and the sequence number of the subsequent video frame are calculated. The position of the cropped area in the video frame is determined based on the first sequence difference, the second sequence difference, and the positions of the cropped areas of the previous and subsequent video frames.
[0079] The following is based on Figure 2 Taking a medium-length video as an example, we will describe the method for determining the cropping area corresponding to each video frame. Figure 2The source video is 6 seconds long. Assuming a frame rate of 30 FPS, the source video contains a total of 180 video frames, numbered 1 to 180. The user selects 10 video frames numbered 1, 20, 25, 40, 60, 85, 105, 130, 158, and 170 from these 10 frames and selects the cropping area of these 10 frames by dragging a cropping box on the playback screen. Therefore, the first part of the video frames consists of these 10 frames, and the second part consists of the remaining 170 frames. For each video frame numbered 2-19, the preceding video frame is always frame number 1, and the following video frame is always frame number 20. Therefore, the position of the cropping area in each video frame numbered 2-19 can be determined by the position of the cropping area in the video frame numbered 1 or the video frame numbered 20. When the video frame movement is small, the position of the cropped area in video frame number 1 can be used as the position of the cropped area in video frames numbered 2-19. When the video frame movement is large, the position of the cropped area in video frames numbered 2-19 can be determined based on the positions of the cropped areas in video frame number 1 and video frame number 20. For example, if the position of the cropped area in video frame number 1 is (x1, y1) and the position of the cropped area in video frame number 20 is (x2, y1), then x3 in the position (x3, y1) of the cropped area in video frames numbered 2-19 can be calculated using formula (5):
[0080]
[0081] Where i is a number between 2 and 19.
[0082] Step S106: Based on the cropping region corresponding to each video frame contained in the source video, each video frame of the source video is cropped, and the cropped video frames are re-encoded to form the target video.
[0083] Specifically, each cropped video frame is re-encoded according to the source video's encoding format to form the target video. The aspect ratio of the processed target video is consistent with that of the current playback device, thus preventing stretching and distortion during playback and improving the display effect.
[0084] The video processing method provided in this invention determines the size information of the cropping frame based on the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface. The source video is decoded into video frame data and displayed on the preview playback interface. The user drags the cropping frame on the video frame playback screen of the preview playback interface to obtain the position of the cropping area for each video frame in the first part. Based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame, the cropping area corresponding to each video frame is determined. Each video frame of the source video is cropped based on the cropping area corresponding to each video frame, and then the cropped video frames are re-encoded to form the target video. Using the solution of this invention, when the aspect ratio of the source video is different from the aspect ratio of the current playback device display, the video frames of the source video can be cropped simply and efficiently according to user needs, so that the cropped video will not exhibit stretching distortion during playback, thus improving the display effect.
[0085] Example 2
[0086] According to an embodiment of the present invention, a method for setting a dynamic wallpaper is provided, such as... Figure 3 The diagram shown is a flowchart of an optional dynamic wallpaper setting method according to Embodiment 2 of the present invention. This method is applied to the various electronic devices described above. The method includes:
[0087] Step S301: Obtain the Uniform Resource Identifier (URI) of the source video.
[0088] A Uniform Resource Identifier (URI) is a string used to identify the name of a specific internet resource. Various resources available on the web, such as HTML documents, images, video clips, and programs, can all be located using a single URI.
[0089] Step S302: Obtain the source video through the URI and parse out the first resolution information of the source video.
[0090] Step S303: Perform video processing on the source video according to any one of the video processing methods in Embodiment 1 to obtain the target video.
[0091] Step S304: Set the target video as a live wallpaper.
[0092] Specifically, the target video is set as a live wallpaper by calling the live wallpaper setting interface.
[0093] The above-described method for setting dynamic wallpapers includes the steps of the video processing method described in any one of Embodiment 1, and has the corresponding processing flow and beneficial effects of the video processing method. For technical details not described in detail in this embodiment, please refer to the video processing method provided in Embodiment 1 of the present invention.
[0094] Example 3
[0095] According to embodiments of the present invention, an electronic device is provided, such as... Figure 4 The diagram shown is a schematic diagram of an optional electronic device provided in Embodiment 3 of the present invention. The electronic device may include a processor 401, a communication interface 402, a memory 403, and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404. The processor 401 can call logical instructions in the memory 403 to execute a video processing method and a dynamic wallpaper setting method. The video processing method includes: acquiring first resolution information of the source video, second resolution information of the current playback device, and size information of the preview playback interface; determining the size information of a cropping frame for cropping video frames on the preview playback interface based on the first resolution information, the second resolution information, and the size information of the preview playback interface; decoding the source video into video frame data displayed on the preview playback interface, and displaying the cropping frame on the playback screen of the video frames based on the size information of the cropping frame; acquiring the position of the cropping area of each video frame in the first part obtained by the user dragging the cropping frame on the playback screen of each video frame in the first part; determining the cropping area corresponding to each video frame contained in the source video based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame; cropping each video frame of the source video based on the cropping area corresponding to each video frame contained in the source video; and re-encoding the cropped video frames to form a target video.
[0096] Furthermore, the logical instructions in the aforementioned memory 403 can be implemented as software functional units and sold or used as independent products, and can be stored in several computer-readable storage media. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of any of the methods described in Embodiment 1 of the present invention. The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0097] The above-mentioned product can perform the video processing method described in any of Embodiment 1 or the dynamic wallpaper setting method described in Embodiment 2, and has the corresponding functional modules and beneficial effects of the method. For technical details not described in detail in this embodiment, please refer to the video processing method provided in Embodiment 1 or the dynamic wallpaper setting method provided in Embodiment 2 of this invention.
[0098] Example 4
[0099] According to an embodiment of the present invention, a computer-readable storage medium of the type described in Embodiment 3 is provided. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor performs the steps of the video processing method described in Embodiment 1 or the steps of the dynamic wallpaper setting method described in Embodiment 2.
[0100] The above-mentioned product can perform the video processing method described in any of Embodiment 1 or the dynamic wallpaper setting method described in Embodiment 2, and has the corresponding functional modules and beneficial effects of the method. For technical details not described in detail in this embodiment, please refer to the video processing method provided in Embodiment 1 or the dynamic wallpaper setting method provided in Embodiment 2 of this invention.
[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; under the concept of the present invention, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the present invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A video processing method, characterized in that, The method includes: Obtain the first resolution information of the source video, the second resolution information of the current playback device, and the size information of the preview playback interface; Based on the first resolution information, the second resolution information, and the size information of the preview playback interface, the size information of the cropping frame used to crop video frames in the preview playback interface is determined. The source video is decoded into video frame data and displayed on the preview playback interface, and the cropping frame is displayed on the playback screen of the video frame based on the size information of the cropping frame; The position of the cropping area of each video frame in the first part is obtained by the user dragging the cropping frame on the playback screen of each video frame in the first part; The cropping area corresponding to each video frame contained in the source video is determined based on the position of the cropping area of each video frame in the first part and the size information of the cropping frame. Each video frame of the source video is cropped based on the cropping region corresponding to each video frame contained in the source video, and the cropped video frames are re-encoded to form the target video. in, The positions of the cropping regions of each video frame in the second part are determined based on the positions of the cropping regions of each video frame in the first part. Each video frame in the second part is a video frame in the source video that has not been selected by the user by dragging the cropping frame. The cropping region corresponding to each video frame contained in the source video is determined based on the position of the cropping region of each video frame in the first part, the position of the cropping region of each video frame in the second part, and the size information of the cropping frame.
2. The video processing method according to claim 1, characterized in that, The step of determining the size information of the cropping frame used to crop each video frame in the preview playback interface based on the first resolution information, the second resolution information, and the size information of the preview playback interface includes: The first aspect ratio of the source video and the second aspect ratio of the current playback device are calculated based on the first resolution information and the second resolution information, respectively. If the first aspect ratio is greater than the second aspect ratio, the size information of the cutting frame is obtained by formula (1) and formula (2): (1) (2) If the first aspect ratio is less than the second aspect ratio, the size information of the cutting frame is obtained by formula (3) and formula (4): (3) (4)。 3. The method according to claim 1, characterized in that, Determining the position of the cropped area of each video frame in the second part based on the position of the cropped area of each video frame in the first part includes: Based on each video frame of the second part, find the closest preceding and following video frames from each video frame of the first part. The position of the cropped area of the video frame is determined based on the position of the cropped area of the preceding video frame or the position of the cropped area of the following video frame.
4. The method according to claim 3, characterized in that, Determining the position of the cropped area of the video frame based on the position of the cropped area of the previous video frame or the position of the cropped area of the subsequent video frame includes: The position of the cropped region of the video frame is determined by either the position of the cropped region of the preceding video frame or the position of the cropped region of the following video frame; or... Calculate the first sequence difference between the sequence number of the video frame and the sequence number of the preceding video frame, and the second sequence difference between the sequence number of the video frame and the sequence number of the following video frame. Based on the first sequence difference, the second sequence difference, and the positions of the cropped regions of the preceding and following video frames, determine the position of the cropped region in the video frame.
5. The video processing method according to any one of claims 1 to 4, characterized in that, The video frames are in YUV data format.
6. The video processing method according to any one of claims 1 to 4, characterized in that, The method further includes: Get the start and end times of the clip selected by the user; The video frame data located between the start and end times of the clipping in the source video is clipped out and displayed in the preview playback interface. The clipping frame is also displayed on the playback screen of the video frame based on the size information of the clipping frame, so that the user can clip the clipped video frame data according to the playback screen of the video frame.
7. A method for setting a live wallpaper, characterized in that, The method includes: Obtain the Uniform Resource Identifier (URI) of the source video; The source video is obtained through the URI, and the first resolution information of the source video is parsed out. The source video is processed using the video processing method according to any one of claims 1 to 6 to obtain the target video; Set the target video as a live wallpaper.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running thereon, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Video processing method, video processing device and storage medium
CN111356016A
Video processing method and electronic device
WO2021121374A1
