Video Processing Method, Apparatus, Computer Device, and Storage Medium
By cropping the original video frames and converting them into screen video frames, the problem that the receiver device does not support playing horizontal video frames is solved, and the compatibility and effect of video playback are improved.
Patent Information
- Application Number
- CN202110357629.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-01
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2041-04-01
AI Technical Summary
When the receiving device does not support playing horizontal video frames, there will be problems such as screen loss or black screen, which will affect the video playback effect.
By obtaining the width and height of the original video frame, the target proportion is determined, and the video frames that do not meet this proportion are cropped, converted into vertical video frames, and sent to the receiving device to play.
It realizes the conversion of horizontal video frames in the original video into vertical video frames, avoiding the playback problem caused by the receiving device not supporting playback of horizontal video frames, and improving the effect and compatibility of video playback.
Smart Images

Figure CN115174994B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of computer technology, and in particular, to a video processing method, apparatus, computer device, and storage medium. Background Art
[0002] With the rapid development of computer technology and Internet technology, watching live videos or making video calls has become a common operation in people's life, study, and work. Such operations all require video transmission. Usually, the sending device collects the video and sends it to the receiving device, and the receiving device plays the video.
[0003] In the related art, the sending device sends the collected video to the receiving device, and the receiving device plays the video. Among them, when the sending device is in the portrait state, the video includes portrait video frames, and when the sending device is in the landscape state, the video includes landscape video frames. However, if the receiving device does not support playing landscape video frames, problems such as a flower screen or a black screen may occur on the receiving device, affecting the playback effect. Summary of the Invention
[0004] Embodiments of the present application provide a video processing method, apparatus, computer device, and storage medium, which can improve the video playback effect. The technical solutions are as follows:
[0005] On the one hand, a video processing method is provided. The method includes:
[0006] Obtain an original video, where the original video includes a plurality of original video frames;
[0007] Based on the width and height of at least one original video frame in the original video, determine a target ratio, where the target ratio is greater than 0 and less than 1;
[0008] Crop a first video frame in the original video to obtain a target video, so that each video frame in the target video meets a target condition. The first video frame is an original video frame that does not meet the target condition, and the target condition is that the ratio between the width and height of the video frame is the target ratio;
[0009] Send the target video to a receiving device, and the receiving device is used to play the target video.
[0010] Optionally, the determining the target ratio based on the width and height of at least one original video frame in the original video includes:
[0011] In response to the current device switching from the portrait state to the landscape state, determine the target ratio based on the width and height of the currently collected original video frame; or,
[0012] In response to the current device switching from the landscape screen state to the portrait screen state, determine the target ratio based on the width and height of the currently captured original video frame.
[0013] Optionally, the determining the target area in the first video frame based on the origin, the target width, and the target height includes:
[0014] In the first video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0015] In the first video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0016] In the first video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0017] Determine the area formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target area.
[0018] On the other hand, a video processing method is provided, and the method includes:
[0019] Obtain an original video, where the original video includes a plurality of original video frames;
[0020] Determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1;
[0021] Crop the landscape video frames in the original video to obtain target video frames corresponding to the landscape video frames, so that the ratio between the width and the height of the target video frames is the target ratio;
[0022] Send the target video to the receiving-end device, where the target video includes the target video frames, and the receiving-end device is used to play the target video.
[0023] Optionally, the determining the target area in the landscape video frame according to the target height and the target width includes:
[0024] Establish a coordinate system in the landscape video frame, where the origin of the coordinate system is one of the four vertices of the landscape video frame;
[0025] Determine the target area in the landscape video frame based on the origin, the target width, and the target height.
[0026] Optionally, the determining the target area in the landscape video frame based on the origin, the target width, and the target height includes:
[0027] In the landscape video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of the landscape video frame and the target width, and the second difference is determined based on the difference between the height of the landscape video frame and the target height;
[0028] In the landscape video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0;
[0029] In the landscape video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0;
[0030] In the landscape video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height;
[0031] Determine the area formed by the first key point, the second key point, the third key point, and the fourth key point as the target area.
[0032] Optionally, the determining the target area in the landscape video frame based on the origin, the target width, and the target height includes:
[0033] In the landscape video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0034] In the landscape video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0035] In the landscape video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0036] Determine the area formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target area.
[0037] Optionally, the obtaining of the original video includes:
[0038] Collecting the original video through a live application client;
[0039] The sending of the target video to the receiving-end device includes:
[0040] Determining at least one viewer identifier in the live room corresponding to the host identifier currently logged in;
[0041] Sending the target video to the receiving-end devices corresponding to the at least one viewer identifier.
[0042] On the other hand, a video processing device is provided, and the device includes:
[0043] A video obtaining module, configured to obtain an original video, where the original video includes a plurality of original video frames;
[0044] A ratio determining module, configured to determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1;
[0045] A cropping module, configured to crop a first video frame in the original video to obtain a target video, so that each video frame in the target video meets a target condition, where the first video frame is an original video frame that does not meet the target condition, and the target condition is that the ratio between the width and height of the video frame is the target ratio;
[0046] A video sending module, configured to send the target video to a receiving-end device, where the receiving-end device is configured to play the target video.
[0047] Optionally, the ratio determining module includes:
[0048] A ratio obtaining unit, configured to obtain a first ratio between the height and width of a reference video frame, and a second ratio between the width and height of the reference video frame, where the reference video frame is any one of the plurality of original video frames;
[0049] A first ratio determining unit, configured to determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
[0050] Optionally, the device further includes:
[0051] A height determining module, configured to obtain the height and width of a reference video frame, where the reference video frame is any one of the plurality of original video frames; determining a target height based on the minimum value of the height and width of the reference video frame, where the target height is not greater than the minimum value;
[0052] A width determination module, configured to determine a target width, and the ratio between the target width and the target height is the target ratio;
[0053] The cropping module includes:
[0054] An area determination unit, configured to determine a target area in the first video frame according to the target height and the target width;
[0055] A first cropping unit, configured to crop the target area in the first video frame to obtain the target video.
[0056] Optionally, the ratio determination module includes:
[0057] A second ratio determination unit, configured to, in response to the current device switching from the portrait state to the landscape state, determine the target ratio based on the width and height of the currently captured original video frame; or,
[0058] The second ratio determination unit, configured to, in response to the current device switching from the landscape state to the portrait state, determine the target ratio based on the width and height of the currently captured original video frame.
[0059] Optionally, the area determination unit is configured to:
[0060] Establish a coordinate system in the first video frame, and the origin of the coordinate system is one of the four vertices of the first video frame;
[0061] Determine the target area in the first video frame based on the origin, the target width, and the target height.
[0062] Optionally, the area determination unit is configured to:
[0063] In the first video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of the first video frame and the target width, and the second difference is determined based on the difference between the height of the first video frame and the target height;
[0064] In the first video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0;
[0065] In the first video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0;
[0066] In the first video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height;
[0067] Determine the region formed by the first key point, the second key point, the third key point, and the fourth key point as the target region.
[0068] Optionally, the region determination unit is configured to:
[0069] In the first video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0070] In the first video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0071] In the first video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0072] Determine the region formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target region.
[0073] Optionally, the cropping module includes:
[0074] A second cropping unit for cropping the first video frame to obtain a second video frame such that the ratio between the width and the height of the second video frame is the target ratio;
[0075] A size magnification unit for magnifying the size of the second video frame to the target size to obtain the target video; or,
[0076] The size magnification unit is configured to magnify the height of the second video frame to be the same as the maximum value of the width and height of any original video frame, and magnify the width of the second video frame to be the same as the minimum value of the width and height of any original video frame to obtain the target video.
[0077] Optionally, the video acquisition module is configured to collect the original video through a live application client;
[0078] The video sending module includes:
[0079] An identifier determination unit for determining at least one viewer identifier in the live room corresponding to the currently logged-in host identifier;
[0080] A video sending unit, configured to send the target video to a receiving end device corresponding to the at least one viewer.
[0081] On the other hand, a video processing device is provided, and the device includes:
[0082] A video acquisition module, configured to acquire an original video, where the original video includes a plurality of original video frames;
[0083] A ratio determination module, configured to determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1;
[0084] A cropping module, configured to crop a landscape video frame in the original video to obtain a target video frame corresponding to the landscape video frame, so that a ratio between the width and the height of the target video frame is the target ratio;
[0085] A video sending module, configured to send a target video to a receiving end device, where the target video includes the target video frame, and the receiving end device is configured to play the target video.
[0086] Optionally, the ratio determination module includes:
[0087] A ratio acquisition unit, configured to acquire a first ratio between the height and the width of a reference video frame, and a second ratio between the width and the height of the reference video frame, where the reference video frame is any one of the plurality of original video frames;
[0088] A ratio determination unit, configured to determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
[0089] Optionally, the device further includes:
[0090] A height determination module, configured to determine a target height based on the height of the landscape video frame, where the target height is not greater than the height of the landscape video frame;
[0091] A width determination module, configured to determine a target width, where a ratio between the target width and the target height is the target ratio;
[0092] The cropping module includes:
[0093] An area determination unit, configured to determine a target area in the landscape video frame according to the target height and the target width;
[0094] A first cropping unit, configured to crop the target area in the landscape video frame to obtain the target video frame.
[0095] Optionally, the region determination unit is configured to:
[0096] Establish a coordinate system in the landscape video frame, where the origin of the coordinate system is one of the four vertices of the landscape video frame;
[0097] Based on the origin, the target width, and the target height, determine the target region in the landscape video frame.
[0098] Optionally, the region determination unit is configured to:
[0099] In the landscape video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of the landscape video frame and the target width, and the second difference is determined based on the difference between the height of the landscape video frame and the target height;
[0100] In the landscape video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0;
[0101] In the landscape video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0;
[0102] In the landscape video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height;
[0103] Determine the region formed by the first key point, the second key point, the third key point, and the fourth key point as the target region.
[0104] Optionally, the region determination unit is configured to:
[0105] In the landscape video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0106] In the landscape video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0107] In the landscape video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0108] Determine the area formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target area.
[0109] Optionally, the cropping module includes:
[0110] A second cropping unit for cropping the landscape video frame to obtain a second video frame, so that the ratio between the width and the height of the second video frame is the target ratio;
[0111] A size magnification unit for magnifying the size of the second video frame to a target size to obtain the target video frame; or,
[0112] The size magnification unit is further configured to magnify the height of the second video frame to be the same as the width of the landscape video frame, and magnify the width of the second video frame to be the same as the height of the landscape video frame to obtain the target video frame.
[0113] Optionally, the video acquisition module is configured to acquire the original video through a live application client;
[0114] The video sending module includes:
[0115] An identification determination unit for determining at least one viewer identification in the live room corresponding to the currently logged-in host identification;
[0116] A video sending unit for sending the target video to the receiving end devices corresponding to the at least one viewer identification.
[0117] On the other hand, a computer device is provided. The computer device includes a processor and a memory. At least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor to implement the operations performed in the video processing method as described in the above aspect.
[0118] On the other hand, a computer-readable storage medium is provided. At least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to implement the operations performed in the video processing method as described in the above aspect.
[0119] On the other hand, a computer program product or a computer program is provided. The computer program product or the computer program includes computer program code stored in a computer-readable storage medium. A processor of a computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, so that the computer device implements the operations performed in the video processing method as described in the above aspects.
[0120] The method, device, computer device, and storage medium provided by the embodiments of the present application crop the first video frame in the original video to obtain a target video. Since the ratio between the width and the height of each video frame in the target video is less than 1, each video frame in the target video is a portrait video frame. That is, the video frames in the original video are converted into portrait video frames and sent to a receiving-end device for playing. Therefore, when the original video includes landscape video frames, the situation where the receiving-end device does not support playing landscape video frames and affects video playback can be avoided, and the video playback effect is improved.
[0121] Moreover, regardless of whether the captured original video frames are landscape video frames or portrait video frames, they can be cropped into portrait video frames with the same aspect ratio and played normally in the receiving-end device. The video playback process is compatible with both the situation of capturing landscape video frames and the situation of capturing portrait video frames, improving the compatibility of video playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0122] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0123] Figure 1 It is a schematic diagram of an implementation environment provided by the embodiments of the present application.
[0124] Figure 2 It is a flowchart of a video processing method provided by the embodiments of the present application.
[0125] Figure 3 It is a flowchart of a video processing method provided by the embodiments of the present application.
[0126] Figure 4 It is a flowchart of a video processing method provided by the embodiments of the present application.
[0127] Figure 5 It is a schematic diagram of cropping a video frame provided by the embodiments of the present application.
[0128] Figure 6 It is a flowchart of a video processing method provided by an embodiment of the present application.
[0129] Figure 7 It is a flowchart of a video processing method provided by an embodiment of the present application.
[0130] Figure 8 It is a schematic structural diagram of a video processing device provided by an embodiment of the present application.
[0131] Figure 9 It is a schematic structural diagram of another video processing device provided by an embodiment of the present application.
[0132] Figure 10 It is a schematic structural diagram of another video processing device provided by an embodiment of the present application.
[0133] Figure 11 It is a schematic structural diagram of another video processing device provided by an embodiment of the present application.
[0134] Figure 12 It is a schematic structural diagram of a terminal provided by an embodiment of the present application.
[0135] Figure 13 It is a schematic structural diagram of a server provided by an embodiment of the present application. Detailed implementation manners
[0136] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.
[0137] It can be understood that the terms "first", "second", etc. used in the present application may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the present application, the first video frame may be referred to as the second video frame, and similarly, the second video frame may be referred to as the first video frame.
[0138] Among them, at least one means one or more than one. For example, at least one video frame may be one video frame, two video frames, three video frames, etc., any integer greater than or equal to one. A plurality means two or more than two. For example, a plurality of video frames may be two video frames, three video frames, etc., any integer greater than or equal to two. Each means each one in at least one. For example, each video frame refers to each one of a plurality of video frames. If a plurality of video frames are 3 video frames, then each video frame refers to each one of the 3 video frames.
[0139] Figure 1It is a schematic diagram of an implementation environment provided by an embodiment of the present application. Refer to Figure 1 , the implementation environment includes: a sending device 101 and a receiving device 102. Among them, the receiving device 102 is a terminal. For example, the terminal is a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a smart TV, a smart vehicle terminal, etc., but is not limited thereto. Optionally, the sending device 101 is also a terminal, or the sending device 101 is a server. For example, the server is an independent physical server, or can also be a server cluster or a distributed system composed of multiple physical servers, or can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0140] The sending device 101 and the receiving device 102 can be directly or indirectly connected through wired or wireless communication methods, and the present application does not limit this. The sending device 101 is used to obtain a video and push it to the receiving device 102, and the receiving device 102 is used to play the video pushed by the sending device 101.
[0141] In a possible implementation manner, application clients are installed in both the sending device 101 and the receiving device 102, and the application client can implement functions such as video acquisition and video playback. Optionally, the application client is an application client in the operating systems of the sending device 101 and the receiving device 102, or is an application client provided by a third party. For example, the application client is a social application client, a content sharing application client, a video playback application client, or a live broadcast application client, etc. The embodiments of the present application do not limit this.
[0142] The video processing method provided by the embodiments of the present application can be applied to any scenario of transmitting videos.
[0143] For example, in the scenario of video live broadcast, the host terminal sends a video to the audience terminal, and the audience terminal plays the video sent by the host terminal. Among them, the original video collected by the host terminal includes original video frames. When the host terminal is in the portrait state, the collected original video frames are portrait video frames, and when in the landscape state, the collected original video frames are landscape video frames. The host terminal crops the middle area of the collected original video frames so that the cropped video frames are portrait video frames, and then generates a target video including the cropped portrait video frames, and then pushes the target video to the audience terminal for playback.
[0144] Among them, the aspect ratios of the portrait video frames cropped when the original video frame is a portrait video frame and the portrait video frames cropped when the original video frame is a landscape video frame are the same, so that regardless of whether the host terminal is in the portrait state or the landscape state, portrait video frames with the same aspect ratio can be pushed to the viewer terminal.
[0145] Figure 2 FIG. is a flowchart of a video processing method provided by an embodiment of the present application. The execution subject of the embodiment of the present application is a sending device, and the sending device may be the sending device provided in the above Figure 1 execution environment, see Figure 2 , and the method includes:
[0146] 201. The sending device acquires an original video.
[0147] The sending device acquires an original video, and the original video includes a plurality of original video frames. When the sending device is in the landscape state, the original video frames are landscape video frames, and the width of the landscape video frame is greater than the height of the landscape video frame. For example, the ratio between the width and the height of the landscape video frame is 16:9, etc. When the sending device is in the portrait state, the original video frames are portrait video frames, and the width of the portrait video frame is less than the height of the portrait video frame. For example, the ratio between the width and the height of the portrait video frame is 9:16, etc.
[0148] Optionally, the sending device includes a camera, and the sending device acquires the original video through the camera. When the sending device is in the landscape state, the original video frames in the original video acquired by the camera shooting are landscape video frames. When the sending device is in the portrait state, the original video frames in the original video acquired by the camera shooting are portrait video frames. For example, when the longer side of the screen of the sending device is parallel to the vertical direction, the sending device is in the portrait state. When the longer side of the screen of the sending device is perpendicular to the vertical direction, the sending device is in the landscape state.
[0149] Optionally, the original video is stored in the sending device, and the original video is a video acquired by the sending device or a video received by the sending device, etc. The embodiment of the present application does not limit this.
[0150] 202. The sending device determines a target ratio based on the width and height of at least one original video frame in the original video.
[0151] The sending device determines the width and height of at least one original video frame in the original video, and determines a target ratio based on the width and height of the at least one original video frame. Among them, the target ratio is greater than 0 and less than 1.
[0152] 203. The sending device crops the first video frame in the original video to obtain a target video, so that each video frame in the target video meets the target condition.
[0153] Among them, the first video frame is the original video frame that does not meet the target condition. The target condition is that the ratio between the width and height of the video frame is the target ratio, and the target ratio is greater than 0 and less than 1.
[0154] The sending device obtains the original video, determines the first video frame in the original video that does not meet the target condition, and crops the first video frame in the original video to obtain a target video, so that each video frame in the target video meets the target condition. Among them, since the target condition is that the ratio between the width and height of the video frame is greater than 0 and less than 1, the width of each video frame in the target video is less than the height, that is, the video frames in the target video are all portrait video frames. Among them, the target video frames include the video frames obtained by cropping the first video frame. Optionally, the original video also includes the original video frames that meet the target condition, and the target video also includes the original video frames that meet the target condition.
[0155] 204. The sending device sends the target video to the receiving device.
[0156] After the sending device obtains the target video, it sends the target video to the receiving device. After the receiving device receives the target video, it plays the target video. Therefore, after the sending device obtains the original video, by cropping the first video frame that does not meet the target condition, a target video including only portrait video frames is obtained. Therefore, if the original video includes landscape video frames, and the receiving device does not support playing landscape video frames, the original video is converted into a target video, so that the receiving device can play the target video normally, improving the video playback effect and compatibility.
[0157] Among them, video communication is carried out between the sending device and the receiving device. For example, in the video live broadcast scenario, the sending device is the host terminal, and the receiving device is the viewer terminal. Therefore, the host terminal will send the collected video to the viewer terminal for playback, so as to conduct video live broadcast. For example, in the video call scenario, the first terminal sends the collected video to the second terminal for playback, and the second terminal can also send the collected video to the first terminal for playback.
[0158] The method provided by the embodiment of the present application crops the first video frame in the original video to obtain a target video. Since the ratio between the width and height of each video frame in the target video is less than 1, each video frame in the target video is a portrait video frame. That is, it realizes the automatic conversion of the video frames in the original video into portrait video frames and sends them to the receiving device for playback. Therefore, when the original video includes landscape video frames, it can avoid the situation that the receiving device does not support playing landscape video frames and affects video playback, improving the video playback effect.
[0159] Moreover, regardless of whether the collected original video frames are landscape video frames or portrait video frames, they can be cropped into portrait video frames with the same aspect ratio, enabling normal playback on the receiving device. The video playback process is compatible with both the cases of collecting landscape video frames and collecting portrait video frames, improving the video playback compatibility.
[0160] Figure 3 It is a flowchart of a video processing method provided by the embodiment of the present application. The execution subject of the embodiment of the present application is a sending device, and this sending device can be the sending device provided in the above Figure 1 implementation environment. Refer to Figure 3 This method includes:
[0161] 301. The sending device acquires an original video.
[0162] The sending device acquires an original video, which includes at least one landscape video frame. The width of the landscape video frame is greater than the height of the landscape video frame. For example, the ratio between the width and height of this landscape video frame is 16:9, etc. Optionally, the original video also includes portrait video frames, and the width of the portrait video frame is less than the height of the portrait video frame. For example, the ratio between the width and height of the portrait video frame is 9:16, etc.
[0163] Optionally, the sending device includes a camera, and the sending device acquires the original video through this camera. When the sending device is in the landscape state, the video frames in the original video obtained by the camera shooting are landscape video frames. When the sending device is in the portrait state, the video frames in the original video obtained by the camera shooting are portrait video frames. For example, when the longer side of the screen of the sending device is parallel to the vertical direction, the sending device is in the portrait state. When the longer side of the screen of the sending device is perpendicular to the vertical direction, the sending device is in the landscape state.
[0164] 302. The sending device determines a target ratio based on the width and height of at least one original video frame in the original video.
[0165] The sending device determines the width and height of at least one original video frame in the original video, and determines a target ratio based on the width and height of the at least one original video frame. The target ratio is greater than 0 and less than 1.
[0166] 303. The sending device crops the landscape video frames in the original video to obtain target video frames corresponding to the landscape video frames, so that the ratio between the width and the height of the target video frames is the target ratio.
[0167] After the sending device obtains the original video, it crops the landscape video frames in the original video to obtain target video frames, so that the ratio between the width and the height of the target video frames is the target ratio. The target ratio is greater than 0 and less than 1. Therefore, the width of the target video frame is less than the height of the target video frame, that is, the target video frame is a portrait video frame. The target video frame is cropped from the landscape video frame. Therefore, the size of the target video frame is smaller than the size of the landscape video frame, and the target video frame includes part of the picture information in the landscape video frame.
[0168] 304. The sending device sends the target video to the receiving device.
[0169] After the sending device obtains the target video frame, it generates a target video including the target video frame and sends the target video to the receiving device. After the receiving device receives the target video, it plays the target video. Therefore, when the sending device captures a landscape video frame and the receiving device does not support playing the landscape video frame, by cropping the landscape video frame into a portrait video frame and enabling the receiving device to play the portrait video frame, normal video playback is realized, and the video playback effect and compatibility are improved.
[0170] Video communication is performed between the sending device and the receiving device. For example, in a video live broadcast scenario, the sending device is the host terminal and the receiving device is the viewer terminal. Therefore, the host terminal will send the captured video to the viewer terminal for playback, thereby performing video live broadcast. For example, in a video call scenario, the first terminal sends the captured video to the second terminal for playback, and the second terminal can also send the captured video to the first terminal for playback.
[0171] The method provided in the embodiment of the present application crops the landscape video frames in the original video to obtain target video frames. Since the width of the target video frame is less than the height, the target video frame is a portrait video frame. Then, the target video including the portrait video frame is sent to the receiving device for playback, thereby realizing the automatic conversion of the landscape video frame into a portrait video frame, which can avoid the situation that the video playback is affected due to the receiving device not supporting the playback of the landscape video frame, and improves the video playback effect.
[0172] Moreover, since the landscape video frames can be cropped into portrait video frames and sent to the receiving device for playback, the video can be played normally on the receiving device regardless of whether the captured video frames are landscape video frames or portrait video frames. The video playback process is compatible with both the cases of capturing landscape video frames and capturing portrait video frames, improving the compatibility of video playback.
[0173] Figure 4 It is a flowchart of a video processing method provided by an embodiment of the present application. The execution subject of the embodiment of the present application is a sending device. Refer to Figure 4 and the method includes:
[0174] 401. The sending device acquires an original video.
[0175] The sending device acquires an original video, and the original video includes a plurality of original video frames. When the sending device is in the landscape state, the original video frames are landscape video frames, and the width of the landscape video frames is greater than the height of the landscape video frames. For example, the ratio between the width and the height of the landscape video frames is 16:9, etc. When the sending device is in the portrait state, the original video frames are portrait video frames, and the width of the portrait video frames is less than the height of the portrait video frames. For example, the ratio between the width and the height of the portrait video frames is 9:16, etc.
[0176] Among them, there are various scenarios for video communication between the sending device and the receiving device. For example, in a video live broadcast scenario, the sending device is the host terminal, and the receiving device is the viewer terminal. Therefore, the host terminal will send the captured video to the viewer terminal for playback, thereby conducting a video live broadcast. For example, in a video call scenario, the first terminal sends the captured video to the second terminal for playback, and the second terminal can also send the captured video to the first terminal for playback.
[0177] 402. The sending device determines a target ratio based on the width and height of at least one original video frame in the original video.
[0178] The sending device determines the width and height of at least one original video frame in the original video, and determines a target ratio based on the width and height of the at least one original video frame. Among them, the target ratio is greater than 0 and less than 1.
[0179] In a possible implementation manner, the sending device acquires a first ratio between the height and the width of a reference video frame, and a second ratio between the width and the height of the reference video frame. The reference video frame is any one of the plurality of original video frames, and determines the ratio less than 1 among the first ratio and the second ratio as the target ratio.
[0180] The sending device determines the width and height of the reference video frame, determines a first ratio between the height and width of the reference video frame, and a second ratio between the width and height of the reference video frame, determines the ratio less than 1 from the first ratio and the second ratio, and uses the determined ratio as the target ratio. Among them, after the sending device obtains the reference video frame, without determining whether the reference video frame is a landscape video frame or a portrait video frame, it directly determines the first ratio and the second ratio according to the width and height of the reference video frame, so as to determine the target ratio greater than 0 and less than 1 according to the first ratio and the second ratio. For example, if the reference video frame is a landscape video frame, the first ratio between the height and width of the landscape video frame is a ratio greater than 0 and less than 1, and the second ratio between the width and height of the landscape video frame is a ratio greater than 1. Therefore, the first ratio corresponding to the landscape video frame is determined as the target ratio. If the reference video frame is a portrait video frame, the first ratio between the height and width of the portrait video frame is a ratio greater than 1, and the second ratio between the width and height of the portrait video frame is a ratio greater than 0 and less than 1. Therefore, the second ratio corresponding to the portrait video frame is determined as the target ratio.
[0181] Optionally, when the reference video frame is a landscape video frame, the ratio between the height and width of the landscape video frame is determined as the target ratio. Optionally, when the reference video frame is a portrait video frame, the ratio between the width and height of the portrait video frame is determined as the target ratio.
[0182] 403. The sending device crops the first video frame in the original video according to the target ratio to obtain a target video, so that each video frame in the target video meets the target condition.
[0183] The first video frame is an original video frame that does not meet the target condition. The target condition is that the ratio between the width and height of the video frame is the target ratio, and the target ratio is greater than 0 and less than 1. After the sending device obtains the target ratio, it determines the first video frame in the original video that does not meet the target condition, crops the first video frame in the original video according to the target ratio to obtain a target video, so that each video frame in the target video meets the target condition. Among them, since the target condition is that the ratio between the width and height of the video frame is greater than 0 and less than 1, the width of each video frame in the target video is less than the height, that is, the video frames in the target video are all portrait video frames. For example, if the target ratio is 9:16, the ratio between the width and height of each video frame in the target video is 9:16.
[0184] Among them, the target video includes video frames obtained by cropping the first video frame. Optionally, the original video further includes original video frames that meet the target conditions, and then the target video further includes such original video frames that meet the target conditions. Among them, since the ratio between the width and the height of a landscape video frame is greater than 1, all landscape video frames in the original video are the first video frames that do not meet the target conditions. Optionally, the original video further includes portrait video frames, and then the portrait video frames with the ratio between the width and the height being the target ratio are the original video frames that meet the target conditions, and the portrait video frames with the ratio between the width and the height not being the target ratio are the first video frames that do not meet the target conditions.
[0185] In a possible implementation manner, after determining the target ratio, each time the sending device obtains an original video frame in the original video, it first determines whether the original video frame meets the target conditions. When the sending device determines that the ratio between the width and the height of the original video frame is not equal to the target ratio, it indicates that the original video frame does not meet the target conditions, and then the original video frame is determined as the first video frame and cropped according to the target ratio. In addition, it is also possible to crop the first video frames according to the target ratio after confirming multiple or all of the first video frames. When the sending device determines that the ratio between the width and the height of the original video frame is equal to the target ratio, it indicates that the original video frame meets the target conditions and there is no need to process the original video frame. Then the sending device obtains the next original video frame in the original video and determines whether the next original video frame meets the target conditions. In addition, it is also possible to confirm whether multiple or all of the original video frames in the original video meet the target conditions after obtaining multiple or all of the original video frames, and crop the determined first video frames according to the target ratio. It can be understood that after obtaining the original video frame, there is no limit on the timing of determining whether the original video frame meets the target conditions and cropping the determined first video frames according to the target ratio.
[0186] In a possible implementation manner, the sending device obtains the height and width of a reference video frame, where the reference video frame is any one of at least one original video frame. The target height is determined based on the minimum value of the height and width of the reference video frame, and the target height is not greater than the minimum value; the target width is determined, and the ratio between the target width and the target height is the target ratio. According to the target height and the target width, a target area is determined in the first video frame; the target area in the first video frame is cropped to obtain the target video.
[0187] Among them, when the reference video frame is a landscape video frame, the height of the landscape video frame is the minimum value. Therefore, the target height is not greater than the height of the landscape video frame. Optionally, when the reference video frame is a landscape video frame, the sending device determines the height of the landscape video frame as the target height. Since the sending device needs to crop a video frame that meets the target conditions from the landscape video frame, when the target height of the cropped video frame is equal to the height of the landscape video frame, the size of the video frame cropped by the sending device is the largest, so as to retain more picture information in the landscape video frame in the cropped video frame, thereby increasing the information content of the cropped video frame.
[0188] Among them, when the reference video frame is a portrait video frame, the width of the portrait video frame is the minimum value. Therefore, the target height is not greater than the width of the portrait video frame. Optionally, when the reference video frame is a portrait video frame, the width of the portrait video frame is determined as the target height. Since when the reference video frame is a landscape video frame, the maximum height of the video frame that can be cropped is the height of the landscape video frame, that is, the width of the portrait video frame. In order to keep the size of the cropped video frame the same when the first video frame is a landscape video frame and a portrait video frame, the sending device determines the width of the portrait video frame as the target height of the cropped video frame.
[0189] In a possible implementation, the sending device determines a target ratio based on the width and height of the currently captured original video frame in response to the current device switching from the portrait state to the landscape state. Or the sending device determines a target ratio based on the width and height of the currently captured original video frame in response to the current device switching from the landscape state to the portrait state.
[0190] Among them, whenever the sending device detects a change in the state of the current device, such as switching from the portrait state to the landscape state or from the landscape state to the portrait state, it determines a target ratio based on the width and height of the currently captured original video frame. That is, every time the state of the current device changes, the target ratio is re-determined, and the first video frame is cropped according to the target ratio.
[0191] In a possible implementation, the sending device establishes a coordinate system in the first video frame, and the origin of the coordinate system is one of the four vertices of the first video frame; based on the origin, the target width, and the target height, a target area is determined in the first video frame.
[0192] Among them, the origin of the coordinate system is one of the four vertices of the first video frame. The first video frame includes four vertices, namely the vertex in the upper left corner, the vertex in the lower left corner, the vertex in the upper right corner, and the vertex in the lower right corner. The sending device selects any one of the four vertices as the origin of the coordinate system. Then, based on the position of the origin of the coordinate point, the target width, and the target height, the sending device determines a target area in the first video frame. The height of the target area is the target height, and the width of the target area is the target width.
[0193] Optionally, the process by which the sending device determines the target area in the first video frame based on the origin, the target width, and the target height includes:
[0194] (1) The sending device determines a first key point in the first video frame whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference. The first difference is determined based on the difference between the width of the first video frame and the target width, and the second difference is determined based on the difference between the height of the first video frame and the target height.
[0195] For example, the sending device determines half of the difference between the width of the first video frame and the target width as the first difference, and determines half of the difference between the height of the first video frame and the target height as the second difference. In the first video frame, the sending device determines a first key point whose horizontal distance from the origin is the first difference and whose vertical distance from the origin is the second difference. Optionally, the sending device selects the first key point according to the position of the origin. For example, if the origin is the vertex in the upper left corner of the first video frame, then the first key point is located in the lower right of the origin; if the origin is the vertex in the lower right corner of the first video frame, then the first key point is located in the upper left of the origin, etc. It only needs to ensure that the first key point is in the first video frame.
[0196] (2) The sending device determines a second key point in the first video frame whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0.
[0197] (3) The sending device determines a third key point in the first video frame whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0.
[0198] (4) The sending device determines a fourth key point in the first video frame whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height.
[0199] After the sending device determines the first key point, it selects the second key point, the third key point, and the fourth key point. For example, taking the vertex at the upper left corner of the first video frame as the origin, the sending device determines the second key point that is to the right of the first key point, with a horizontal distance from the first key point equal to the target width and a vertical distance from the first key point equal to 0, determines the third key point that is below the first key point, with a vertical distance from the first key point equal to the target height and a horizontal distance from the first key point equal to 0, and determines the fourth key point that is at the lower right of the first key point, with a horizontal distance from the first key point equal to the target width and a vertical distance from the first key point equal to the target height.
[0200] (5) The sending device determines the area formed by the first key point, the second key point, the third key point, and the fourth key point as the target area.
[0201] After the sending device determines the first key point, the second key point, the third key point, and the fourth key point, it determines the area formed by the first key point, the second key point, the third key point, and the fourth key point in the first video frame and determines this area as the target area. Then, the four vertices of the target area are the first key point, the second key point, the third key point, and the fourth key point, the height of the target area is the target height, and the width of the target area is the target width.
[0202] Optionally, the process by which the sending device determines the target area in the first video frame based on the origin, the target width, and the target height includes:
[0203] (1) The sending device determines, in the first video frame, a fifth key point whose horizontal distance from the origin is equal to the target width and whose vertical distance from the origin is equal to 0.
[0204] (2) The sending device determines, in the first video frame, a sixth key point whose vertical distance from the origin is equal to the target height and whose horizontal distance from the origin is equal to 0.
[0205] (3) The sending device determines, in the first video frame, a seventh key point whose horizontal distance from the origin is equal to the target width and whose vertical distance from the origin is equal to the target height.
[0206] (4) The sending device determines the area formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target area. Then, the four vertices of the target area are the origin, the fifth key point, the sixth key point, and the seventh key point, the height of the target area is the target height, and the width of the target area is the target width.
[0207] Among them, the process by which the sending device determines the target area based on the origin, the fifth key point, the sixth key point, and the seventh key point is the same as the process of determining the target area based on the first key point, the second key point, the third key point, and the fourth key point in the above steps. The difference is that one is to determine the first key point based on the origin and use the first key point as one of the vertices of the target area, and the other is to directly use the origin as one of the vertices of the target area.
[0208] It should be noted that the above steps 402-403 are only described by taking the example of cropping the first video frame according to the target ratio to obtain the target video. In another embodiment, other methods may also be used to crop the first video frame to obtain the target video.
[0209] In a possible implementation manner, the sending device crops the first video frame to obtain a second video frame so that the ratio between the width and the height of the second video frame is the target ratio; the size of the second video frame is enlarged to the target size to obtain the target video.
[0210] When the sending device crops the first video frame to obtain the second video frame, since the size of the second video frame is smaller than that of the first video frame, if the video including the second video frame is directly sent to the receiving device for playback, the size of the played video frame is small and the playback effect is not good. Therefore, after the sending device obtains the second video frame, the size of the second video frame is enlarged to the target size to obtain the target video. Since the size of the video frame is enlarged, the enlarged video frame is subsequently sent to the receiving device for playback, and the video frame played by the receiving device is clearer, thereby improving the playback effect. Optionally, the target size is sent by the receiving device. By enlarging the size of the second video frame to the target size sent by the receiving device, the receiving device is enabled to control the size of the video frame, improving the flexibility of setting the size of the video frame.
[0211] In another possible implementation, the sending device crops the first video frame to obtain a second video frame such that the ratio between the width and the height of the second video frame is the target ratio; the height of the second video frame is enlarged to be the same as the maximum value of the width and the height of any original video frame, and the width of the second video frame is enlarged to be the same as the minimum value of the width and the height of any original video frame, thereby obtaining a target video. For example, when the first video frame is a landscape video frame with a size of 1280*720, the size of the video frame obtained after enlarging the second video frame is 720*1280. For example, when the first video frame is a portrait video frame with a size of 720*1280, the size of the video frame obtained after enlarging the second video frame is 720*1280. By enlarging the size of the second video frame, the clarity of the subsequent played video frame can be improved.
[0212] In the embodiments of the present application, the sending device crops all the first video frames in the original video that do not meet the target conditions to obtain a target video, and the target video includes portrait video frames with the same aspect ratio. The embodiments of the present application adopt the method of cropping the first video frames in the original video, maintaining the output of portrait video frames when both landscape video frames and portrait video frames are captured, and keeping the format of the output video unchanged, which can improve the compatibility of video playback. In a possible implementation, the original video includes landscape video frames and portrait video frames, and the sizes of the video frames cropped when the first video frame is a portrait video frame and the video frames cropped when the first video frame is a landscape video frame are the same, so that regardless of whether the sending device is in the portrait state or the landscape state, video frames of the same size can be sent to the receiving device, thereby ensuring that the size of the picture in the video frames played by the receiving device remains unchanged and avoiding the situation where the picture in the video frames played by the receiving device is suddenly large or small, and improving the video playback effect.
[0213] In a possible implementation, the sending device uses OpenGL ES (OpenGL for Embedded Systems, a three-dimensional graphics library for embedded systems) to crop the first video frame in the original video to obtain a target video such that the ratio between the width and the height of each video frame in the target video is the target ratio. Alternatively, the sending device can also use other tools with cropping functions to crop the first video frame, and the embodiments of the present application do not limit this.
[0214] In a possible implementation, the sending device crops the first video frame in the original video to obtain a target video frame, and the ratio between the width and height of the target video frame is the target ratio. The sending device encodes the target video frame to obtain a target video including the target video frame. In another possible implementation, the original video further includes an original video frame that meets the target condition. The sending device crops the first video frame in the original video to obtain a target video frame, and the ratio between the width and height of the target video frame is the target ratio. The sending device encodes the target video frame and the original video frame that meets the target condition to obtain a target video including the target video frame and the original video frame that meets the target condition.
[0215] Optionally, the sending device uses a hardware encoder to encode the target video frame to obtain a target video, and the target video is a portrait-format video.
[0216] Figure 5 is a schematic diagram of cropping a video frame provided by an embodiment of the present application. Refer to Figure 5 , the original video includes a portrait video frame 501, and the portrait video frame 501 does not meet the target condition. The sending device determines a target area 511 in the portrait video frame 501, crops and enlarges the target area 511 to obtain a target video frame 502. The original video further includes a landscape video frame 503, and the landscape video frame 503 does not meet the target condition. The sending device determines a target area 513 in the landscape video frame 503, crops and enlarges the target area 513 to obtain a target video frame 504.
[0217] 404. The sending device sends the target video to the receiving device.
[0218] After obtaining the target video, the sending device sends the target video to the receiving device.
[0219] In a possible implementation, a live application client runs on the sending device, and the live application client has a live function. In step 401 above, the sending device captures the original video through the live application client. Then in this step 404, the sending device determines at least one audience identifier in the live room corresponding to the currently logged-in host identifier, and sends the target video to the receiving devices corresponding to the at least one audience identifier. The currently logged-in host identifier is used to indicate the identity of the host in the live room, and at least one audience identifier in the live room is used to indicate at least one audience in the live room. The user of the sending device is the host, and the host captures the original video through the live application client in the computing device. Optionally, during the process of capturing the original video, the host can place the sending device vertically, then the sending device is in the vertical screen state, and the captured video frames are vertical screen video frames. The host can also switch the sending device to the horizontal screen state, then the sending device is in the horizontal screen state, and the captured video frames are horizontal screen video frames. Therefore, the original video captured by the sending device includes horizontal screen video frames and vertical screen video frames. The sending device uses the method provided in the embodiment of the present application to crop the video frames in the original video into vertical screen video frames, so as to push the target video including the vertical screen video frames to the receiving device corresponding to the audience, thus avoiding the situation that the video playback is affected because the receiving device does not support playing the horizontal screen video frames.
[0220] 405. The receiving device plays the target video on the display interface.
[0221] After the receiving device receives the target video, it plays the target video on the display interface. Therefore, in the case where the original video obtained by the sending device includes horizontal screen video frames and the receiving device does not support playing the horizontal screen video frames, by cropping the horizontal screen video frames into vertical screen video frames and enabling the receiving device to play the vertical screen video frames, normal video playback is achieved, improving the video playback effect and compatibility.
[0222] 406. The sending device plays the target video on the display interface.
[0223] After the sending device obtains the target video, it plays the target video on the display interface. Then, after the user of the sending device sees the target video, the user can adjust the picture in the target video by adjusting the position of the sending device or adjusting his own position, so as to achieve that even in the case where part of the picture information is discarded due to the cropping of the first video frame, the picture information expected by the user can still be displayed in the target video. For example, in a video live broadcast scenario, the sending device is the host terminal, the display interface is the live broadcast interface, and the host terminal will display the live broadcast interface during the live broadcast. After the host terminal crops the first video frame in the original video to obtain the target video, it displays the target video in the live broadcast interface instead of the original video.
[0224] It should be noted that the embodiments of the present application are only described by taking the execution of step 404 first and then step 406 as an example. In another embodiment, steps 404 and 406 are executed simultaneously. In addition, the embodiments of the present application are only described by taking the sending-end device playing the target video as an example. In another embodiment, the sending-end device may not execute the above step 406. For example, the sending-end device directly displays the acquired original video, etc.
[0225] It should be noted that the embodiments of the present application are only described by taking the sending-end device cropping the first video frame in the original video to obtain the target video frame as an example. In another embodiment, the sending-end device crops each original video frame in the original video according to the target height and target width to obtain the target video. The height of each video frame in the target video is the target height, the width of each video frame in the target video is the target width, and the ratio between the target width and the target height is the target ratio.
[0226] Figure 6 is a flowchart of a video processing method provided by the embodiments of the present application. This method is applied to a video live broadcast scenario, such as Figure 6 shown, the method includes:
[0227] 601. The host terminal turns on the camera to collect the original video;
[0228] 602. The host terminal determines the target height and target width according to the original video frames in the original video;
[0229] 603. The host terminal crops in the original video frame according to the target height and target width to obtain the second video frame;
[0230] 604. The host terminal enlarges the second video frame to obtain the target video frame;
[0231] 605. The host terminal pushes the target video including the target video frame.
[0232] Among them, as Figure 6 shown, after the host terminal processes a certain original video frame to obtain the second video frame, it determines whether to switch the state, such as switching from the landscape state to the portrait state, or from the portrait state to the landscape state. If the state is not switched, it continues to process the next acquired original video frame based on the target height and target width. If the state is switched, it re-determines the target height and target width and processes the next acquired original video frame based on the re-determined target height and target width. Among them, as Figure 6 shown, when the host terminal pushes the target video, it determines whether to end the live broadcast. If the live broadcast is not ended, it continues to collect the original video and process it. If the live broadcast is ended, it ends the video processing process.
[0233] The method provided by the embodiment of the present application crops the first video frame in the original video to obtain a target video. Since the ratio between the width and height of each video frame in the target video is less than 1, the video frames in the target video are all portrait video frames. That is, it realizes the automatic conversion of the video frames in the original video into portrait video frames and sends them to the receiving device for playback. Therefore, when the original video includes landscape video frames, it can avoid the situation that the receiving device does not support playing landscape video frames and affects video playback, improving the video playback effect.
[0234] Moreover, regardless of whether the collected original video frames are landscape video frames or portrait video frames, they can be cropped into portrait video frames with the same aspect ratio, realizing normal playback on the receiving device. The video playback process is compatible with both the case of collecting landscape video frames and the case of collecting portrait video frames, improving the compatibility of video playback.
[0235] Moreover, since the sending device needs to crop a video frame from the landscape video frame, when the target height of the cropped video frame is equal to the height of the landscape video frame, the size of the video frame cropped by the sending device is the largest, so that more picture information in the landscape video frame is retained in the cropped video frame, thereby increasing the amount of information in the cropped video frame.
[0236] Moreover, after the sending device obtains the second video frame, it acquires the target size sent by the receiving device and enlarges the size of the second video frame to the target size. Since the size of the video frame is enlarged, the video frame with the enlarged size is subsequently sent to the receiving device for playback, and the video frame played by the receiving device is clearer, thereby improving the playback effect.
[0237] Moreover, by enlarging the size of the second video frame to the target size sent by the receiving device, it realizes the control of the video frame size by the receiving device, improving the flexibility of setting the video frame size.
[0238] Moreover, the sizes of the video frames cropped when the original video frame is a portrait video frame and the video frames cropped when the original video frame is a landscape video frame are the same, so that regardless of whether the sending device is in a portrait state or a landscape state, video frames of the same size can be sent to the receiving device, thereby ensuring that the size of the picture in the video frame played by the receiving device remains unchanged and avoiding the situation that the picture in the video frame played by the receiving device is suddenly large or small, improving the video playback effect.
[0239] Figure 7 It is a flowchart of a video processing method provided by the embodiment of the present application. The execution subject of the embodiment of the present application is the sending device. Refer to Figure 7 , the method includes:
[0240] 701. The sending device acquires the original video.
[0241] The sending device acquires the original video, which includes multiple original video frames. The original video frames are either landscape video frames or portrait video frames. The width of a landscape video frame is greater than its height. For example, the ratio of the width to the height of the landscape video frame is 16:9, etc. Optionally, the original video also includes portrait video frames, and the width of a portrait video frame is less than its height. For example, the ratio of the width to the height of the portrait video frame is 9:16, etc.
[0242] 702. The sending device determines a target ratio based on the width and height of at least one original video frame in the original video.
[0243] The sending device determines the width and height of at least one original video frame in the original video and determines a target ratio based on the width and height of the at least one original video frame. The target ratio is greater than 0 and less than 1.
[0244] In a possible implementation, since the height of a landscape video frame is less than its width, the ratio of the height to the width of the landscape video frame is greater than 0 and less than 1. Then the sending device determines the ratio of the height to the width of the landscape video frame as the target ratio.
[0245] 703. The sending device crops the landscape video frame according to the target ratio to obtain a target video frame, so that the ratio of the width to the height of the target video frame is the target ratio.
[0246] After obtaining the target ratio, the sending device crops the landscape video frame to obtain a target video frame, so that the ratio of the width to the height of the target video frame is the target ratio. The width of the target video frame is less than its height, so the target video frame is a portrait video frame.
[0247] In a possible implementation, every time the sending device obtains an original video frame from the original video, it first determines whether the original video frame is a landscape video frame, that is, determines whether the width of the original video frame is greater than the height. If the width of the original video frame is greater than the height, then the original video frame is a landscape video frame, and the landscape video frame needs to be cropped subsequently. Additionally, it is also possible to crop the landscape video frames according to the target ratio after identifying multiple or all of the landscape video frames. If the width of the original video frame is not greater than the height, then the original video frame is a portrait video frame and does not need to be cropped. Then the sending device obtains the next original video frame of the original video frame and determines whether the next original video frame is a landscape video frame. Additionally, it is also possible to confirm whether multiple or all of the original video frames in the original video are landscape video frames after obtaining multiple or all of the original video frames in the original video, and crop the identified landscape video frames according to the target ratio. It can be understood that after obtaining the original video frame, there is no restriction on the timing of determining whether the original video frame is a landscape video frame and cropping the identified landscape video frames according to the target ratio.
[0248] In a possible implementation, the sending device establishes a coordinate system in the landscape video frame, and the origin of the coordinate system is one of the four vertices of the landscape video frame; based on the origin, the target width, and the target height, the target area is determined in the landscape video frame.
[0249] Among them, the process of determining the target area in the landscape video frame is the same as the process of determining the target area in the original landscape video frame in step 403 above, and will not be elaborated here one by one.
[0250] In a possible implementation, the sending device determines the target height based on the height of the landscape video frame, and the target height is not greater than the height of the landscape video frame; determines the target width, and the ratio between the target width and the target height is the target ratio; determines the target area in the landscape video frame according to the target height and the target width; crops the target area in the landscape video frame to obtain the target video frame.
[0251] Optionally, the sending device determines the height of the landscape video frame as the target height. This target height is the height of the target video frame. Since the sending device needs to crop a target video frame in the landscape video frame, when the target height of the target video frame is equal to the height of the landscape video frame, the size of the target video frame cropped by the sending device is the largest, so that more picture information in the original landscape video frame is retained in the target video frame, thereby increasing the information volume of the target video frame.
[0252] In a possible implementation, the sending device crops the landscape video frame to obtain a second video frame, where the width of the second video frame is less than the height of the second video frame; and enlarges the size of the second video frame to the target size to obtain the target video frame.
[0253] In a possible implementation, the sending device crops the landscape video frame to obtain a second video frame, where the width of the second video frame is less than the height of the second video frame; enlarges the height of the second video frame to be the same as the width of the landscape video frame, and enlarges the width of the second video frame to be the same as the height of the landscape video frame to obtain the target video frame.
[0254] 704. The sending device sends the target video to the receiving device.
[0255] After obtaining the target video frame, the sending device generates a target video including the target video frame and sends the target video to the receiving device.
[0256] 705. The receiving device plays the target video on the display interface.
[0257] 706. The sending device plays the target video on the display interface.
[0258] After obtaining the target video including the target video frame, the sending device synchronously plays the target video on the display interface.
[0259] It should be noted that in the embodiments of the present application, only the example of first executing step 704 and then executing step 706 is used for illustration. In another embodiment, step 704 and step 706 are executed simultaneously. In addition, only the example of the sending device synchronously playing the target video is used for illustration in the embodiments of the present application. In another embodiment, the sending device may not execute the above step 705. For example, the sending device directly displays the acquired original video, etc.
[0260] In the method provided by the embodiments of the present application, after collecting the original video, first crop the landscape video frame in the original video to obtain the target video frame. Since the width of the target video frame is less than the height, the target video frame is a portrait video frame. Then send the target video including the portrait video frame to the receiving device for playing, thereby realizing the automatic conversion of the landscape video frame to the portrait video frame, and being able to avoid the situation that the video playback is affected due to the receiving device not supporting the playback of the landscape video frame, improving the video playback effect.
[0261] Moreover, since the landscape video frame can be cropped into a portrait video frame and sent to the receiving device for playing, no matter whether the collected video frame is a landscape video frame or a portrait video frame, it can be normally played on the receiving device. The video playback process is compatible with both the case of collecting landscape video frames and the case of collecting portrait video frames, improving the compatibility of video playback.
[0262] Moreover, since the sending device needs to crop a target video frame from a landscape video frame, when the target height of the target video frame is equal to the height of the landscape video frame, the size of the target video frame cropped by the sending device is the largest, so that more picture information in the original landscape video frame is retained in the target video frame, thereby increasing the information content of the target video frame.
[0263] Moreover, after the sending device obtains the second video frame, it acquires the target size sent by the receiving device, enlarges the size of the second video frame to the target size to obtain the target video frame. Since the size of the video frame is enlarged, the enlarged video frame is subsequently sent to the receiving device for playback, and the video frame played by the receiving device is clearer, thereby improving the playback effect.
[0264] Moreover, by enlarging the size of the second video frame to the target size sent by the receiving device, the receiving device is enabled to control the size of the video frame, improving the flexibility of setting the video frame size.
[0265] Figure 8 It is a schematic structural diagram of a video processing device provided by an embodiment of the present application. Refer to Figure 8 , the device includes:
[0266] A video acquisition module 801, configured to acquire an original video, where the original video includes a plurality of original video frames;
[0267] A ratio determination module 802, configured to determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1;
[0268] A cropping module 803, configured to crop a first video frame in the original video to obtain a target video, so that each video frame in the target video meets a target condition, the first video frame is an original video frame that does not meet the target condition, and the target condition is that the ratio between the width and height of the video frame is the target ratio;
[0269] A video sending module 804, configured to send the target video to a receiving device, and the receiving device is configured to play the target video.
[0270] The video processing device provided by the embodiment of the present application crops the first video frame in the original video to obtain a target video. Since the ratio between the width and the height of each video frame in the target video is less than 1, the video frames in the target video are all portrait video frames. That is, it realizes the conversion of the video frames in the original video into portrait video frames and sends them to the receiving device for playback. Therefore, when the original video includes landscape video frames, it can avoid the situation that the receiving device does not support playing landscape video frames and affects video playback, improving the video playback effect. Moreover, regardless of whether the collected original video frames are landscape video frames or portrait video frames, they can be cropped into portrait video frames with the same aspect ratio, realizing normal playback in the receiving device. The video playback process is compatible with both the situation of collecting landscape video frames and the situation of collecting portrait video frames, improving the compatibility of video playback.
[0271] Optionally, referring to Figure 9 , the ratio determination module 802 includes:
[0272] The ratio acquisition unit 812 is configured to acquire a first ratio between the height and the width of a reference video frame, and a second ratio between the width and the height of the reference video frame, where the reference video frame is any one of multiple original video frames;
[0273] The first ratio determination unit 822 is configured to determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
[0274] Optionally, referring to Figure 9 , the device further includes:
[0275] The height determination module 805 is configured to acquire the height and width of a reference video frame, where the reference video frame is any one of multiple original video frames; determine the target height based on the minimum value of the height and width of the reference video frame, and the target height is not greater than the minimum value;
[0276] The width determination module 806 is configured to determine the target width, and the ratio between the target width and the target height is the target ratio;
[0277] The cropping module 803 includes:
[0278] The area determination unit 813 is configured to determine a target area in the first video frame according to the target height and the target width;
[0279] The first cropping unit 823 is configured to crop the target area in the first video frame to obtain the target video.
[0280] Optionally, referring to Figure 9 , the ratio determination module 802 includes:
[0281] A second ratio determination unit 832, configured to, in response to the current device switching from the portrait state to the landscape state, determine a target ratio based on the width and height of the currently captured original video frame; or,
[0282] The second ratio determination unit 832, configured to, in response to the current device switching from the landscape state to the portrait state, determine a target ratio based on the width and height of the currently captured original video frame.
[0283] Optionally, refer to Figure 9 , the region determination unit 813 is configured to:
[0284] Establish a coordinate system in the first video frame, where the origin of the coordinate system is one of the four vertices of the first video frame;
[0285] Determine a target region in the first video frame based on the origin, the target width, and the target height.
[0286] Optionally, refer to Figure 9 , the region determination unit 813 is configured to:
[0287] In the first video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of the first video frame and the target width, and the second difference is determined based on the difference between the height of the first video frame and the target height;
[0288] In the first video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0;
[0289] In the first video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0;
[0290] In the first video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height;
[0291] Determine the region formed by the first key point, the second key point, the third key point, and the fourth key point as the target region.
[0292] Optionally, refer to Figure 9 , the region determination unit 813 is configured to:
[0293] In the first video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0294] In the first video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0295] In the first video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0296] Determine the area formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target area.
[0297] Optionally, refer to Figure 9 , the cropping module 803 includes:
[0298] A second cropping unit 833 for cropping the first video frame to obtain a second video frame so that the ratio between the width and the height of the second video frame is the target ratio;
[0299] A size magnification unit 843 for magnifying the size of the second video frame to the target size to obtain the target video; or,
[0300] A size magnification unit 843 for magnifying the height of the second video frame to be the same as the maximum value of the width and height of any original video frame, and magnifying the width of the second video frame to be the same as the minimum value of the width and height of any original video frame to obtain the target video.
[0301] Optionally, refer to Figure 9 , the video acquisition module 801 for acquiring the original video through the live application client;
[0302] The video sending module 804 includes:
[0303] An identification determination unit 814 for determining at least one viewer identification in the live room corresponding to the currently logged-in host identification;
[0304] A video sending unit 824 for sending the target video to the receiving end devices corresponding to at least one viewer identification.
[0305] It should be noted that: when the video processing device provided in the above embodiments processes the video, only the above division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the video processing device provided in the above embodiments and the embodiments of the video processing method belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0306] Figure 10It is a schematic structural diagram of a video processing device provided by an embodiment of the present application. Refer to Figure 10 , the device includes:
[0307] A video acquisition module 1001, configured to acquire an original video, where the original video includes a plurality of original video frames;
[0308] A ratio determination module 1002, configured to determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1;
[0309] A cropping module 1003, configured to crop the landscape video frames in the original video to obtain target video frames corresponding to the landscape video frames, so that the ratio between the width and height of the target video frames is the target ratio;
[0310] A video sending module 1004, configured to send the target video to a receiving device, where the target video includes the target video frames, and the receiving device is configured to play the target video.
[0311] For the video processing device provided by the embodiment of the present application, the landscape video frames in the original video are cropped to obtain target video frames. Since the width of the target video frames is less than the height, the target video frames are portrait video frames. Then, the target video including the portrait video frames is sent to the receiving device for playing, thereby realizing the conversion from landscape video frames to portrait video frames, which can avoid the situation that the video playback is affected due to the receiving device not supporting the playback of landscape video frames and improve the video playback effect. Moreover, since the landscape video frames can be cropped into portrait video frames and sent to the receiving device for playing, the video can be normally played on the receiving device regardless of whether the captured video frames are landscape video frames or portrait video frames. The video playback process is compatible with both the cases of capturing landscape video frames and capturing portrait video frames, improving the compatibility of video playback.
[0312] Optionally, refer to Figure 11 , the ratio determination module 1002 includes:
[0313] A ratio acquisition unit 1012, configured to acquire a first ratio between the height and width of a reference video frame, and a second ratio between the width and height of the reference video frame, where the reference video frame is any one of the plurality of original video frames;
[0314] A ratio determination unit 1022, configured to determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
[0315] Optionally, refer to Figure 11 , the device further includes:
[0316] A height determination module 1005, configured to determine a target height based on the height of a landscape video frame, where the target height is not greater than the height of the landscape video frame;
[0317] A width determination module 1006, configured to determine a target width, where the ratio between the target width and the target height is a target ratio;
[0318] A cropping module 1003, including:
[0319] A region determination unit 1013, configured to determine a target region in the landscape video frame according to the target height and the target width;
[0320] A first cropping unit 1023, configured to crop the target region in the landscape video frame to obtain a target video frame.
[0321] Optionally, referring to Figure 11 , the region determination unit 1013 is configured to:
[0322] Establish a coordinate system in the landscape video frame, where the origin of the coordinate system is one of the four vertices of the landscape video frame;
[0323] Determine the target region in the landscape video frame based on the origin, the target width, and the target height.
[0324] Optionally, referring to Figure 11 , the region determination unit 1013 is configured to:
[0325] In the landscape video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of the landscape video frame and the target width, and the second difference is determined based on the difference between the height of the landscape video frame and the target height;
[0326] In the landscape video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0;
[0327] In the landscape video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0;
[0328] In the landscape video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height;
[0329] Determine the region formed by the first key point, the second key point, the third key point, and the fourth key point as the target region.
[0330] Optionally, referring to Figure 11, the region determination unit 1013 is configured to:
[0331] In the landscape video frame, determine a fifth key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is 0;
[0332] In the landscape video frame, determine a sixth key point whose vertical distance from the origin is the target height and whose horizontal distance from the origin is 0;
[0333] In the landscape video frame, determine a seventh key point whose horizontal distance from the origin is the target width and whose vertical distance from the origin is the target height;
[0334] Determine the region formed by the origin, the fifth key point, the sixth key point, and the seventh key point as the target region.
[0335] Optionally, refer to Figure 11 , the cropping module 1003 includes:
[0336] The second cropping unit 1033 is configured to crop the landscape video frame to obtain a second video frame such that the ratio between the width and the height of the second video frame is the target ratio;
[0337] The size enlargement unit 1043 is configured to enlarge the size of the second video frame to the target size to obtain a target video frame; or,
[0338] The size enlargement unit 1043 is further configured to enlarge the height of the second video frame to be the same as the width of the landscape video frame and enlarge the width of the second video frame to be the same as the height of the landscape video frame to obtain a target video frame.
[0339] Optionally, refer to Figure 11 , the video acquisition module 1001 is configured to acquire an original video through a live application client;
[0340] The video sending module 1004 includes:
[0341] The identifier determination unit 1014 is configured to determine at least one viewer identifier in the live room corresponding to the currently logged-in host identifier;
[0342] The video sending unit 1024 is configured to send the target video to the receiving end devices corresponding to at least one viewer identifier.
[0343] It should be noted that when the video processing device provided in the above embodiment processes a video, only the division of the above functional modules is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the video processing device provided in the above embodiment and the embodiment of the video processing method belong to the same concept. For the specific implementation process, please refer to the method embodiment, which will not be elaborated here.
[0344] An embodiment of the present application also provides a computer device, which includes a processor and a memory. At least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor to implement the operations performed in the video processing method of the above embodiment.
[0345] Optionally, the computer device is provided as a terminal. Figure 12 FIG. shows a schematic structural diagram of a terminal 1200 provided by an exemplary embodiment of the present application.
[0346] The terminal 1200 includes a processor 1201 and a memory 1202.
[0347] The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1201 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1201 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 1201 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1201 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computing operations related to machine learning.
[0348] The memory 1202 may include one or more computer-readable storage media, which may be non-transitory. The memory 1202 may further include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1202 is used to store at least one computer program, and the at least one computer program is used to be possessed by the processor 1201 to implement the video processing method provided in the method embodiments of the present application.
[0349] In some embodiments, the terminal 1200 may further optionally include: a peripheral device interface 1203 and at least one peripheral device. The processor 1201, the memory 1202, and the peripheral device interface 1203 may be connected by a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 1203 through a bus, signal lines, or a circuit board. Optionally, the peripheral device includes at least one of a radio frequency circuit 1204, a display screen 1205, a camera assembly 1206, and a gyroscope sensor 1207.
[0350] The peripheral device interface 1203 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1201 and the memory 1202. In some embodiments, the processor 1201, the memory 1202, and the peripheral device interface 1203 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1201, the memory 1202, and the peripheral device interface 1203 may be implemented on a separate chip or circuit board, and this embodiment does not limit this.
[0351] The radio frequency circuit 1204 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1204 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1204 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1204 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 1204 may communicate with other devices through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: a metropolitan area network, each generation of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1204 may further include a circuit related to NFC (Near Field Communication), and this application does not limit this.
[0352] The display screen 1205 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1205 is a touch display screen, the display screen 1205 also has the ability to collect touch signals on or above the surface of the display screen 1205. The touch signals can be input to the processor 1201 as control signals for processing. At this time, the display screen 1205 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be one display screen 1205, which is disposed on the front panel of the terminal 1200; in other embodiments, there can be at least two display screens 1205, which are respectively disposed on different surfaces of the terminal 1200 or are in a foldable design; in other embodiments, the display screen 1205 can be a flexible display screen, which is disposed on the curved surface or the folding surface of the terminal 1200. Even further, the display screen 1205 can be set to an irregular non-rectangular shape, that is, an irregular-shaped screen. The display screen 1205 can be prepared using materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0353] The camera assembly 1206 is used to collect images or videos. Optionally, the camera assembly 1206 includes a front camera and a rear camera. The front camera is disposed on the front panel of the terminal 1200, and the rear camera is disposed on the back of the terminal 1200. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth camera, a wide-angle camera, and a telephoto camera, so as to implement functions such as background blurring by fusing the main camera and the depth camera, panoramic shooting by fusing the main camera and the wide-angle camera, and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, the camera assembly 1206 can also include a flash. The flash can be a single-color temperature flash or a two-color temperature flash. A two-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
[0354] The gyroscope sensor 1207 can detect the body direction and rotation angle of the terminal 1200. The gyroscope sensor 1207 can cooperate with the acceleration sensor 1211 to collect the 3D actions of the user on the terminal 1200. Based on the data collected by the gyroscope sensor 1207, the processor 1201 can implement the following functions: motion sensing (such as changing the UI according to the user's tilting operation), image stabilization during shooting, game control, and inertial navigation.
[0355] Those skilled in the art can understand that Figure 12 the structure shown in Figure 12 does not constitute a limitation on the terminal 1200, and it may include more or fewer components than shown in the figure, or combine some components, or adopt a different component arrangement.
[0356] Optionally, the computer device is provided as a server. Figure 13 FIG. Figure 13 is a schematic structural diagram of a server provided by an embodiment of the present application. The server 1300 may vary greatly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPUs) 1301 and one or more memories 1302. Among them, at least one computer program is stored in the memory 1302, and the at least one computer program is loaded and executed by the processor 1301 to implement the methods provided in the above-mentioned method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input / output. The server may also include other components for implementing device functions, which will not be elaborated here.
[0357] An embodiment of the present application also provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is loaded and executed by a processor to implement the operations performed in the video processing method of the above embodiment.
[0358] An embodiment of the present application also provides a computer program product or a computer program. The computer program product or the computer program includes computer program code. The computer program code is stored in a computer-readable storage medium. The processor of the computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, so that the computer device implements the operations performed in the video processing method of the above embodiment. In some embodiments, the computer program involved in the embodiments of the present application may be deployed to be executed on one computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected through a communication network. The multiple computer devices distributed at multiple locations and interconnected through a communication network may form a blockchain system.
[0359] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium, and the above-mentioned storage medium can be a read-only memory, a disk, or an optical disc, etc.
[0360] The above are only alternative embodiments of the embodiments of the present application and are not intended to limit the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the embodiments of the present application shall be included within the protection scope of the present application.
Claims
1. A video processing method, characterized in that, Executed by a sending device, the method includes: Obtain an original video, where the original video includes a plurality of original video frames, and the plurality of original video frames include at least one of landscape video frames or portrait video frames; Based on the width and height of at least one original video frame in the original video, determine a target ratio, where the target ratio is greater than 0 and less than 1; Based on the minimum value of the height and width of a reference video frame, determine a target height, where the target height is not greater than the minimum value, and the reference video frame is any one of the plurality of original video frames; determine a target width, where the ratio between the target width and the target height is the target ratio; According to the target height and the target width, determine a target area in each original video frame in the original video, and crop the target area in each original video frame in the original video to obtain a target video, so that the width of each video frame in the target video is equal to the target width and the height is equal to the target height; Send the target video to a receiving device, and the receiving device is used to play the target video.
2. The method according to claim 1, wherein The determining the target ratio based on the width and height of at least one original video frame in the original video includes: Obtain a first ratio between the height and width of a reference video frame, and a second ratio between the width and height of the reference video frame, where the reference video frame is any one of the plurality of original video frames; Determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
3. The method according to claim 1, characterized in that, The determining the target area in each original video frame in the original video according to the target height and the target width includes: Establish a coordinate system in each original video frame, and the origin of the coordinate system is one of the four vertices of each original video frame; Based on the origin, the target width, and the target height, determine the target area in each original video frame.
4. The method according to claim 3, wherein The determining the target area in each original video frame based on the origin, the target width, and the target height includes: In each original video frame, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of each original video frame and the target width, and the second difference is determined based on the difference between the height of each original video frame and the target height; In each original video frame, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0; In each original video frame, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0; In each original video frame, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height; Determine the area formed by the first key point, the second key point, the third key point, and the fourth key point as the target area.
5. The method according to claim 1, characterized in that Determining the target area in each original video frame of the original video according to the target height and the target width, and cropping the target area in each original video frame of the original video to obtain a target video, includes: Determining the target area in each of the original video frames according to the target height and the target width, and cropping the target area in each of the original video frames to obtain a plurality of second video frames, so that the ratio between the width and the height of the plurality of second video frames is the target ratio; Enlarging the size of the plurality of second video frames to a target size to obtain the target video; or, Enlarging the height of the plurality of second video frames to be the same as the maximum value of the width and height of any one of the original video frames, and enlarging the width of the plurality of second video frames to be the same as the minimum value of the width and height of any one of the original video frames to obtain the target video.
6. The method according to claim 1, characterized in that, Obtaining the original video includes: Collecting the original video through a live application client; Sending the target video to the receiving end device includes: Determining at least one viewer identifier in the live room corresponding to the currently logged-in host identifier; Sending the target video to the receiving end devices corresponding to the at least one viewer identifier.
7. A video processing device, characterized in that, The device includes: A video acquisition module, configured to acquire an original video, where the original video includes a plurality of original video frames, and the plurality of original video frames include at least one of landscape video frames or portrait video frames; A ratio determination module, configured to determine a target ratio based on the width and height of at least one original video frame in the original video, where the target ratio is greater than 0 and less than 1; A height determination module, configured to determine a target height based on the minimum value of the height and width of a reference video frame, where the target height is not greater than the minimum value, and the reference video frame is any one of the plurality of original video frames; A width determination module, configured to determine a target width, where the ratio between the target width and the target height is the target ratio; A cropping module, configured to determine a target area in each video frame of the original video according to the target height and the target width, and crop the target area in each original video frame of the original video to obtain a target video, so that the width of each video frame in the target video is equal to the target width and the height is equal to the target height; A video sending module, configured to send the target video to a receiving end device, where the receiving end device is configured to play the target video.
8. The device according to claim 7, characterized in that, The ratio determination module includes: A ratio acquisition unit, configured to acquire a first ratio between the height and width of a reference video frame, and a second ratio between the width and height of the reference video frame, where the reference video frame is any one of the plurality of original video frames; A first ratio determination unit, configured to determine the ratio less than 1 among the first ratio and the second ratio as the target ratio.
9. The device according to claim 7, wherein The cropping module includes: An area determination unit for establishing a coordinate system in each of the original video frames, with the origin of the coordinate system being one of the four vertices of each of the original video frames; The area determination unit is further configured to determine the target area in each of the original video frames based on the origin, the target width, and the target height.
10. The device according to claim 9, characterized in that, The area determination unit is configured to: In each of the original video frames, determine a first key point whose horizontal distance from the origin is a first difference and whose vertical distance from the origin is a second difference, where the first difference is determined based on the difference between the width of each of the original video frames and the target width, and the second difference is determined based on the difference between the height of each of the original video frames and the target height; In each of the original video frames, determine a second key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is 0; In each of the original video frames, determine a third key point whose vertical distance from the first key point is the target height and whose horizontal distance from the first key point is 0; In each of the original video frames, determine a fourth key point whose horizontal distance from the first key point is the target width and whose vertical distance from the first key point is the target height; Determine the area formed by the first key point, the second key point, the third key point, and the fourth key point as the target area.
11. The device according to claim 8, characterized in that, The cropping module includes: A second cropping unit for determining the target area in each of the original video frames according to the target height and the target width, cropping the target area in each of the original video frames to obtain a plurality of second video frames, so that the ratio between the width and the height of the plurality of second video frames is the target ratio; A size magnification unit for magnifying the size of the plurality of second video frames to a target size to obtain the target video; or, magnifying the height of the plurality of second video frames to be the same as the maximum value of the width and height of any one of the original video frames, and magnifying the width of the plurality of second video frames to be the same as the minimum value of the width and height of any one of the original video frames to obtain the target video.
12. The device according to claim 8, characterized in that, The video acquisition module is configured to acquire the original video through a live application client; The video sending module includes: An identifier determination unit for determining at least one viewer identifier in the live room corresponding to the currently logged-in host identifier; A video sending unit for sending the target video to the receiving end devices corresponding to the at least one viewer identifier.
13. A computer device, characterized in that, The computer device includes a processor and a memory, and at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor to implement the operations performed in the video processing method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that, At least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to implement the operations performed in the video processing method according to any one of claims 1 to 6.
15. A computer program product, characterized in that, The computer program product includes computer program code, the computer program code is stored in a computer-readable storage medium, a processor of a computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code so that the computer device implements the operations performed in the video processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Live broadcast data transmission method and device thereof and computer readable storage medium
CN111479162A