Video processing method and device, electronic equipment and storage medium
By obtaining and calculating the resolution difference of video materials, the export resolution of videos is automatically determined, which solves the problem of poor resolution adjustment during video merging in the prior art, and improves the video export effect and user experience.
Patent Information
- Application Number
- CN202411348213.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2024-12-27
AI Technical Summary
When existing video editing software merges multiple video materials, it is impossible to automatically determine the resolution of the final video, making it difficult for users to choose the appropriate resolution, affecting the video export effect.
By obtaining the number and resolution of the original material in the target video, the resolution difference between the video materials is calculated, and the resolution of the target video is automatically determined according to the export type, so as to achieve accurate adjustment of the resolution of the video material.
Improve the video export effect, ensure that the video is fully displayed on different devices, reduce the complexity of user manual resolution selection, and improve the accuracy and picture quality of video processing.
Smart Images

Figure CN119211606A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing technology, and in particular to a video processing method, device, electronic device and storage medium. Background Art
[0002] With the growing development of short video business, more and more video creators have emerged. Some creators will use mobile phones to edit videos. When editing videos, they usually merge multiple video materials or picture materials into a final exported video. Since the resolutions of multiple materials are not uniform, how to determine the resolution of the final exported video is an urgent problem to be solved. In the prior art, when multiple materials are merged into a target video for export, the editing software will provide users with different resolution options, allowing users to manually select the resolution of the target video when exporting. The resolution is not automatically determined based on the resolution characteristics of the video material itself. On the one hand, the user may not be able to select a suitable resolution because they do not understand the resolution of the original material. On the other hand, the options for selecting the resolution are relatively single, usually only providing 480p, 720p, 1080p, 2k / 4k and several fixed-ratio resolution options, and the width and height cannot be flexibly adjusted. The degree of refinement is insufficient, resulting in poor export video effects. Summary of the invention
[0003] The present disclosure provides a video processing method, device, electronic device and storage medium.
[0004] According to one aspect of the present disclosure, there is provided a video processing method, comprising:
[0005] Acquire the number of original materials contained in the target video, the original resolution of each of the original materials, and the type of each of the original materials; wherein the types of the original materials include video materials and picture materials;
[0006] Determining whether the number of the original material is greater than one;
[0007] In response to the number of the original materials being greater than one, judging, according to the type of the original materials, whether the target video contains at least two of the video materials;
[0008] In response to the target video containing at least two of the video materials, calculating a resolution difference between the video materials according to an original resolution of each of the video materials;
[0009] The export resolution of the target video is determined according to the resolution difference between the video materials and the export type of the target video.
[0010] According to another aspect of the present disclosure, there is provided a video processing device, comprising:
[0011] An acquisition module, configured to acquire the number of original materials contained in the target video, the original resolution of each of the original materials, and the type of each of the original materials; wherein the type of the original materials includes video materials and picture materials;
[0012] A first determination module is configured to determine whether the number of the original material is greater than one;
[0013] A second determination module is configured to determine, in response to the number of the original materials being greater than one, whether the target video contains at least two of the video materials according to the type of the original materials;
[0014] A calculation module, configured to calculate a resolution difference between the video materials according to an original resolution of each of the video materials in response to the target video containing at least two of the video materials;
[0015] The first determination module is configured to determine the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video.
[0016] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method in any of the above technical solutions.
[0020] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods described in the above technical solutions.
[0021] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program, wherein the computer program implements any one of the methods described in the above technical solutions when executed by a processor.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0024] Figure 1 is a schematic diagram of the steps of the video processing method in an embodiment of the present disclosure;
[0025] Figure 2 is a flowchart of a video processing method in an embodiment of the present disclosure;
[0026] Figure 3 is a principle block diagram of a video processing device in an embodiment of the present disclosure;
[0027] Figure 4 The block diagram is a block diagram of an electronic device for implementing the video processing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0029] With regard to the video processing methods in the prior art, when multiple materials are merged into a target video for export, different resolution options are provided to the user, allowing the user to manually select the resolution of the target video when exporting. The resolution is not automatically determined based on the resolution characteristics of the video material itself, resulting in poor target video export effect and may cause technical problems such as incomplete display of some video clips.
[0030] In view of the above technical problems, the present disclosure provides a video processing method, such as Figure 1 As shown, including:
[0031] Step S101, obtaining the number of original materials contained in the target video, the original resolution of each original material, and the type of each original material; wherein the type of original material includes video material and picture material.
[0032] Specifically, in the video editing process, a video or a picture can be obtained as the original material, and the target video can be composed of multiple videos, or multiple pictures, or a video and a picture.
[0033] Step S102, determining whether the number of original materials is greater than one.
[0034] First, you need to determine whether the original material is one or more. If there is only one original material, you can export it according to the original resolution. There is no problem of unified resolution.
[0035] Step S103 , in response to the number of original materials being greater than one, judging whether the target video contains at least two video materials according to the type of the original materials.
[0036] Specifically, when the target video includes at least two original materials, it is necessary to determine whether there are two or more video materials. If there are two or more video materials with different resolutions, the video resolutions need to be unified. If two or more original materials include only one video material and the others are all picture materials, the original resolution of the original material is used as the export resolution of the target video.
[0037] Step S104, in response to the target video containing at least two video materials, calculating the resolution difference between the video materials according to the original resolution of each video material.
[0038] Specifically, if the resolution difference between the video materials is 0, the video materials can be exported according to their original resolutions, without unifying the resolutions of the multiple video materials.
[0039] Step S105, determining the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video.
[0040] The export type of the target video in this embodiment includes vertical screen or horizontal screen. According to whether the target video is vertical screen or horizontal screen, combined with the resolution difference between the video materials, different calculation methods are adopted to determine the export resolution. For video materials with a small difference in resolution, the original resolution can be maintained as much as possible, and only fine-tuning can be performed; for video materials with a large difference in resolution, the resolution of each video material can be adjusted according to a pre-set fixed aspect ratio, so that the target video can be finally exported at a uniform resolution. In this way, after the target video is processed, the export resolution can be automatically adjusted according to the resolution characteristics of the original material itself and the export type of the target video. Compared with allowing the user to manually select the resolution, the resolution adjustment method is more precise and the exported video display effect is better.
[0041] As an optional implementation, after step S102, determining whether the number of the original materials is greater than one, further includes:
[0042] Step S106 , in response to the number of the original material being one, determining an export resolution of the target video according to the type of the original material.
[0043] Specifically, when the target video has only one original material, there is no fine-tuning of inconsistent resolutions, and different methods can be used to determine the export resolution for the picture material and the video material.
[0044] As an optional implementation, in step S106, in response to the number of the original material being one, determining the export resolution of the target video according to the type of the original material includes:
[0045] If the type of the original material is video material, the original resolution of the video material will be used as the export resolution of the target video.
[0046] Specifically, when the target video contains only one video material, the original resolution of the video material can be directly used as the export resolution without system adjustment.
[0047] As an optional implementation, in step S106, in response to the number of the original material being one, determining the export resolution of the target video according to the type of the original material includes:
[0048] Step S106a: if the type of the original material is a picture material, determine whether the original resolution of the picture material is greater than a preset resolution.
[0049] Step S106b: In response to the original resolution of the image material being greater than the preset resolution, the preset resolution is used as the export resolution of the target video.
[0050] Step S106c: in response to the original resolution of the picture material being not greater than the preset resolution, the original resolution of the picture material is used as the export resolution of the target video.
[0051] Specifically, since the original resolution of some image materials is relatively large, such as 2k*4k, generating a target video with this resolution may cause the target video to occupy too much storage space. Therefore, in this embodiment, an upper limit value is set for the image material. For example, the preset resolution can be set to 1080p. When the original resolution of the image material is greater than 1080p, 1080p is used as the export resolution of the target video; when the original resolution of the image material is not greater than 1080p, the original resolution of the image material (such as 720p) is used as the export resolution of the target video. In this way, the storage space occupied by the target video is reduced as much as possible while ensuring the display effect of the target video.
[0052] As an optional implementation, after step S103, determining whether the target video contains at least two video materials, further includes:
[0053] Step S107, in response to the target video containing a video material and one or more picture materials, the original resolution of the video material is used as the export resolution of the target video.
[0054] Specifically, when the target video contains only one video material and the other materials are all picture materials, the original resolution of the video material is used as the export resolution, and the system automatically adjusts the resolution of other picture materials to be consistent with the resolution of the video material.
[0055] As an optional implementation, after step S103, determining whether the target video contains at least two video materials, further includes:
[0056] In response to the target video containing multiple picture materials, the resolution difference between the picture materials is calculated according to the original resolution of each picture material.
[0057] The export resolution of the target video is determined according to the resolution difference between the image materials and the export type of the target video.
[0058] Specifically, the target video export type includes horizontal or vertical. Depending on whether the target video is vertical or horizontal, combined with the resolution difference between the image materials, different calculation methods are used to determine the export resolution. For image materials with a small resolution difference, the original resolution can be maintained as much as possible, and only fine-tuned; for image materials with a large resolution difference, the resolution of each image material can be unified according to a pre-set fixed resolution.
[0059] As an optional implementation manner, determining the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video includes:
[0060] If the export type of the target video is vertical, determine whether the resolution difference between the video materials is greater than the preset difference.
[0061] In response to the resolution difference between the video materials being greater than a preset difference, the export resolution is determined according to a maximum width of a first preset aspect ratio and original resolutions of the video materials.
[0062] Specifically, the preset difference value can be set to x (x = 0.005f, where f is a floating point number). If the resolution difference between the two videos is greater than x, it is considered that the resolution difference between the two videos is large. Then, the aspect ratio of the final exported resolution is determined to be 16:9 according to the preset fixed aspect ratio, where the width of the exported resolution is the maximum width w1 of all video materials. According to the maximum width w1 and the first preset aspect ratio 16:9, the height of the exported resolution h1 = w1*16f / 9 can be calculated. By retaining the maximum width in the video material, it is ensured that all videos can be fully displayed without affecting the export effect of the target video. Retaining the maximum width can ensure that the vertical screen type target video is fully displayed on the device screen, avoiding compression or stretching of the video content due to insufficient screen width, thereby ensuring the clarity and integrity of the picture quality.
[0063] As an optional implementation manner, after determining whether the resolution difference between the video materials is greater than a preset difference, the method further includes:
[0064] In response to the resolution difference between the video materials being not greater than a preset difference, the export resolution is determined according to a maximum width and a maximum aspect ratio in the original resolutions of the video materials.
[0065] If the difference between the original resolutions of two video materials is less than or equal to x, the resolutions of the video materials are considered to be similar, and the maximum width of the original resolutions of all video materials is used as the width of the exported resolution, and the aspect ratio is the maximum aspect ratio of all video materials. In this way, the resolutions of videos with similar resolutions can be fine-tuned, the aspect ratio of the original resolutions of the video materials is retained, and the maximum width of the video materials is retained, so as to ensure that all videos can be fully displayed without affecting the export effect of the target video.
[0066] In a vertical video, since the main display direction of the video is vertical, its width is usually smaller than its height. When making or publishing a vertical video, you need to consider the aspect ratio of the video to ensure that the video is displayed correctly during playback and avoid stretching or compression. For example, if the aspect ratio of the video is set to 16:9, this means that at the same height, the maximum height of the video is determined by its maximum width and the aspect ratio of 16:9. This is because if the height of the video is set to the maximum value (for example, 1080 pixels), then according to the ratio of 16:9, the maximum height of the video will also be determined accordingly. By first determining the maximum width and aspect ratio, and then determining the corresponding maximum height on this basis, the highest resolution of the target video when exported can be calculated as the final export resolution.
[0067] As an optional implementation manner, determining the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video includes:
[0068] If the export type of the target video is horizontal screen, determine whether the resolution difference between the video materials is greater than the preset difference.
[0069] In response to the resolution difference between the video materials being greater than a preset difference, the export resolution is determined according to a second preset aspect ratio and a maximum height of the original resolutions of the video materials.
[0070] Specifically, the preset difference value can be set to x (x=0.005f, where f is a floating point number). If the resolution difference between the two videos is greater than x, it is considered that the resolution difference between the two videos is large. The aspect ratio of the final exported resolution is determined to be 9:16 according to the preset fixed aspect ratio, where the height of the exported resolution is the maximum height h2 of all video materials. Based on the maximum width w2 and the second preset aspect ratio 9:16, the height of the exported resolution can be calculated to be w2=h2 / (16f / 9).
[0071] When the target video to be exported is horizontal, the maximum height of the video material is retained to ensure that all video materials can be fully displayed without affecting the display effect of the target video after export. Retaining the maximum height can ensure that the target video of the horizontal screen type is fully displayed on the device screen, avoiding video content compression or stretching due to insufficient screen width, thereby ensuring the clarity and integrity of the image quality.
[0072] As an optional implementation manner, determining whether the resolution difference between the video materials is greater than a preset difference further includes:
[0073] In response to the resolution difference between the video materials being not greater than a preset difference, the export resolution is determined according to a maximum height and a maximum aspect ratio in the original resolutions of the video materials.
[0074] As mentioned above, the preset difference can be set to x. If the difference between the original resolutions of two video materials is less than or equal to x, the resolutions of the video materials are considered to be similar. The maximum height h2 in the original resolution of all video materials is used as the height of the exported resolution, and the aspect ratio is the maximum aspect ratio of all video materials. After determining the height and aspect ratio, the corresponding width can be calculated. In this way, the resolution of videos with similar resolutions can be fine-tuned, the aspect ratio of the original resolution in the video material is retained, and the maximum height in the video material is retained, thereby ensuring that all video materials can be fully displayed in the horizontal screen without affecting the export effect of the target video.
[0075] In a horizontal video, since the main display direction of the video is horizontal, its width is usually greater than its height. When making or publishing a horizontal video, you need to consider the aspect ratio of the video to ensure that the video can be displayed correctly during playback and avoid stretching or compression. For example, if the aspect ratio of the video is set to 9:16, this means that at the same height, the maximum width of the video is determined by its maximum height and the ratio of 9:16. This is because if the height of the video is set to the maximum value (for example, 1080 pixels), then based on the aspect ratio of 9:16, the maximum width of the video will also be determined accordingly. By first determining the maximum height and aspect ratio, and then determining the corresponding maximum width on this basis, the highest resolution of the target video when exported can be calculated as the final export resolution.
[0076] Figure 2 The figure shows a complete flow chart of the video processing method, including: step S201, first determine whether the number of original materials contained in the target video is greater than 1 (i.e., one or more); if the number of original materials is not greater than 1 (only 1), jump to step S202, continue to determine whether the original material is a video material, if so, jump to step S203, export according to the original resolution of the video material, if not, jump to step S204, determine whether the original resolution of the picture material is greater than the preset resolution (for example, 1080p): if it is greater than the preset resolution 1080p, jump to step S204a, export according to the preset resolution; if it is not greater than the preset resolution 1080p, jump to step S204b, export according to the original resolution of the picture material.
[0077] After executing step S201, jump to step S205. If the number of original materials is greater than 1, continue to determine whether the number of video materials in the multiple original materials is greater than 1; if the number of video materials is greater than 1, jump to step S206, obtain the original resolutions of the multiple video materials for difference calculation (based on the original resolution of the first video material or the original resolution of any video material); step S207, determine whether the resolution difference between the video materials is greater than a preset difference x (for example, x = 0.005f): if the resolution difference is greater than x, it is considered that the resolution difference between the videos is large, jump to step S208a, first determine the maximum width or maximum height, and then determine the other side according to the preset aspect ratio, and calculate the highest resolution as the export resolution; if the resolution difference is not greater than x, it is considered that the resolution difference between the videos is small, jump to step S208b, first determine the maximum width or maximum height, and then determine the other side according to the maximum aspect ratio in the video material, and calculate the highest resolution as the export resolution. If step S205 determines that the number of video materials is not greater than 1, that is, the target video contains only one video material and the others are picture materials, then jump to step S209, and adjust the original resolution of all picture materials based on the original resolution of the video material to be consistent with the video material, and finally use the original resolution of the video material as the export resolution.
[0078] The present disclosure also provides a video processing device 300, such as Figure 3 As shown, including:
[0079] The acquisition module 301 is configured to acquire the number of original materials contained in the target video, the original resolution of each original material, and the type of each original material; wherein the type of original material includes video material and picture material.
[0080] Specifically, in the video editing process, a video or a picture can be obtained as the original material, and the target video can be composed of multiple videos, or multiple pictures, or a video and a picture.
[0081] The first determination module 302 is configured to determine whether the number of the original material is greater than one.
[0082] First, you need to determine whether the original material is one or more. If there is only one original material, you can export it according to the original resolution. There is no problem of unified resolution.
[0083] The second determination module 303 is configured to determine, in response to the number of the original materials being greater than one, whether the target video contains at least two video materials according to the types of the original materials.
[0084] Specifically, when the target video includes at least two original materials, it is necessary to determine whether there are two or more video materials. If there are two or more video materials with different resolutions, the video resolutions need to be unified. If two or more original materials include only one video material and the others are all picture materials, the original resolution of the original material is used as the export resolution of the target video.
[0085] The calculation module 304 is configured to calculate the resolution difference between the video materials according to the original resolution of each video material in response to the target video containing at least two video materials.
[0086] Specifically, if the resolution difference between the video materials is 0, the video materials can be exported according to their original resolutions, without unifying the resolutions of the multiple video materials.
[0087] The first determination module 305 is configured to determine the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video.
[0088] The export type of the target video in this embodiment includes vertical screen or horizontal screen. According to whether the target video is vertical screen or horizontal screen, combined with the resolution difference between the video materials, different calculation methods are adopted to determine the export resolution. For video materials with a small difference in resolution, the original resolution can be maintained as much as possible, and only fine-tuning can be performed; for video materials with a large difference in resolution, the resolution of each video material can be adjusted according to a pre-set fixed aspect ratio, so that the target video can be finally exported at a uniform resolution. In this way, after the target video is processed, the export resolution can be automatically adjusted according to the resolution characteristics of the original material itself and the export type of the target video. Compared with allowing the user to manually select the resolution, the resolution adjustment method is more precise and the exported video display effect is better.
[0089] As an optional implementation, the video processing device 300 further includes:
[0090] The second determination module is configured to determine the export resolution of the target video according to the type of the original material in response to the number of the original material being one after the first determination module determines whether the number of the original material is greater than one.
[0091] Specifically, when the target video has only one original material, there is no fine-tuning of inconsistent resolutions, and different methods can be used to determine the export resolution for the picture material and the video material.
[0092] As an optional implementation, the second determining module includes:
[0093] The second determining unit is configured to use the original resolution of the video material as the export resolution of the target video if the type of the original material is video material.
[0094] Specifically, when the target video contains only one video material, the original resolution of the video material can be directly used as the export resolution without system adjustment.
[0095] As an optional implementation, the second determining module includes:
[0096] The second judgment unit is configured to judge whether the original resolution of the picture material is greater than the preset resolution if the type of the original material is picture material.
[0097] The second determining unit is configured to use the preset resolution as the export resolution of the target video in response to the original resolution of the picture material being greater than the preset resolution.
[0098] In response to the original resolution of the picture material being not greater than the preset resolution, the second determining unit uses the original resolution of the picture material as the export resolution of the target video.
[0099] Specifically, since the original resolution of some image materials is relatively large, such as 2k*4k, generating a target video with this resolution may cause the target video to occupy too much storage space. Therefore, in this embodiment, an upper limit value is set for the image material. For example, the preset resolution can be set to 1080p. When the original resolution of the image material is greater than 1080p, 1080p is used as the export resolution of the target video; when the original resolution of the image material is not greater than 1080p, the original resolution of the image material (such as 720p) is used as the export resolution of the target video. In this way, the storage space occupied by the target video is reduced as much as possible while ensuring the display effect of the target video.
[0100] As an optional implementation, the video processing device 300 further includes:
[0101] The third determination module is configured to use the original resolution of the video material as the export resolution of the target video in response to the target video containing one video material and one or more picture materials after the second determination module determines whether the target video contains at least two video materials.
[0102] Specifically, when the target video contains only one video material and the other materials are all picture materials, the original resolution of the video material is used as the export resolution, and the system automatically adjusts the resolution of other picture materials to be consistent with the resolution of the video material.
[0103] As an optional implementation, the video processing device 300 further includes:
[0104] The second calculation module is configured as a second judgment module, after judging whether the target video contains at least two video materials, in response to the target video containing multiple picture materials, to calculate the resolution difference between the picture materials according to the original resolution of each picture material and the export type of the target video.
[0105] The fourth determination module is configured to determine the export resolution of the target video according to the resolution difference between the image materials.
[0106] Specifically, the target video export type includes horizontal or vertical. Depending on whether the target video is vertical or horizontal, combined with the resolution difference between the image materials, different calculation methods are used to determine the export resolution. For image materials with a small resolution difference, the original resolution can be maintained as much as possible, and only fine-tuned; for image materials with a large resolution difference, the resolution of each image material can be unified according to a pre-set fixed resolution.
[0107] As an optional implementation, the first determining module includes:
[0108] The first judgment unit is configured to judge whether the resolution difference between the video materials is greater than a preset difference if the export type of the target video is vertical screen.
[0109] The first determining unit is configured to determine the derived resolution according to a first preset aspect ratio and a maximum width of original resolutions of the video materials in response to a resolution difference between the video materials being greater than a preset difference.
[0110] Specifically, the preset difference value can be set to x (x = 0.005f, where f is a floating point number). If the resolution difference between the two videos is greater than x, it is considered that the resolution difference between the two videos is large. Then, the aspect ratio of the final exported resolution is determined to be 16:9 according to the preset fixed aspect ratio, where the width of the exported resolution is the maximum width w1 of all video materials. According to the maximum width w1 and the first preset aspect ratio 16:9, the height of the exported resolution h1 = w1*16f / 9 can be calculated. By retaining the maximum width in the video material, it is ensured that all videos can be fully displayed without affecting the export effect of the target video. Retaining the maximum width can ensure that the vertical screen type target video is fully displayed on the device screen, avoiding compression or stretching of the video content due to insufficient screen width, thereby ensuring the clarity and integrity of the picture quality.
[0111] As an optional implementation manner, after the second determination unit determines whether the resolution difference between the video materials is greater than a preset difference, the method further includes:
[0112] In response to the resolution difference between the video materials being not greater than a preset difference, the first determining unit determines the derived resolution according to the maximum width and the maximum aspect ratio in the original resolution of the video materials.
[0113] If the difference between the original resolutions of two video materials is less than or equal to x, the resolutions of the video materials are considered to be similar, and the maximum width of the original resolutions of all video materials is used as the width of the exported resolution, and the aspect ratio is the maximum aspect ratio of all video materials. In this way, the resolutions of videos with similar resolutions can be fine-tuned, the aspect ratio of the original resolutions of the video materials is retained, and the maximum width of the video materials is retained, so as to ensure that all videos can be fully displayed without affecting the export effect of the target video.
[0114] In a vertical video, since the main display direction of the video is vertical, its width is usually smaller than its height. When making or publishing a vertical video, you need to consider the aspect ratio of the video to ensure that the video is displayed correctly during playback and avoid stretching or compression. For example, if the aspect ratio of the video is set to 16:9, this means that at the same height, the maximum height of the video is determined by its maximum width and the aspect ratio of 16:9. This is because if the height of the video is set to the maximum value (for example, 1080 pixels), then according to the ratio of 16:9, the maximum height of the video will also be determined accordingly. By first determining the maximum width and aspect ratio, and then determining the corresponding maximum height on this basis, the highest resolution of the target video when exported can be calculated as the final export resolution.
[0115] As an optional implementation, the first determining module includes:
[0116] The first judgment unit is configured to judge whether the resolution difference between the video materials is greater than a preset difference if the export type of the target video is horizontal screen.
[0117] The first determining unit is configured to determine the derived resolution according to a second preset aspect ratio and a maximum height of original resolutions of the video materials in response to a resolution difference between the video materials being greater than a preset difference.
[0118] Specifically, the preset difference value can be set to x (x=0.005f, where f is a floating point number). If the resolution difference between the two videos is greater than x, it is considered that the resolution difference between the two videos is large. The aspect ratio of the final exported resolution is determined to be 9:16 according to the preset fixed aspect ratio, where the height of the exported resolution is the maximum height h2 of all video materials. Based on the maximum width w2 and the second preset aspect ratio 9:16, the height of the exported resolution can be calculated to be w2=h2 / (16f / 9).
[0119] When the target video to be exported is horizontal, the maximum height of the video material is retained to ensure that all video materials can be fully displayed without affecting the display effect of the target video after export. Retaining the maximum height can ensure that the target video of the horizontal screen type is fully displayed on the device screen, avoiding video content compression or stretching due to insufficient screen width, thereby ensuring the clarity and integrity of the image quality.
[0120] As an optional implementation manner, the first determining unit determines whether the resolution difference between the video materials is greater than a preset difference, further comprising:
[0121] In response to the resolution difference between the video materials being not greater than a preset difference, the first determining unit determines the derived resolution according to the maximum height and the maximum aspect ratio in the original resolution of the video materials.
[0122] As mentioned above, the preset difference can be set to x. If the difference between the original resolutions of two video materials is less than or equal to x, the resolutions of the video materials are considered to be similar. The maximum height h2 in the original resolution of all video materials is used as the height of the exported resolution, and the aspect ratio is the maximum aspect ratio of all video materials. After determining the height and aspect ratio, the corresponding width can be calculated. In this way, the resolution of videos with similar resolutions can be fine-tuned, the aspect ratio of the original resolution in the video material is retained, and the maximum height in the video material is retained, thereby ensuring that all video materials can be fully displayed in the horizontal screen without affecting the export effect of the target video.
[0123] In a horizontal video, since the main display direction of the video is horizontal, its width is usually greater than its height. When making or publishing a horizontal video, you need to consider the aspect ratio of the video to ensure that the video can be displayed correctly during playback and avoid stretching or compression. For example, if the aspect ratio of the video is set to 9:16, this means that at the same height, the maximum width of the video is determined by its maximum height and the ratio of 9:16. This is because if the height of the video is set to the maximum value (for example, 1080 pixels), then based on the aspect ratio of 9:16, the maximum width of the video will also be determined accordingly. By first determining the maximum height and aspect ratio, and then determining the corresponding maximum width on this basis, the highest resolution of the target video when exported can be calculated as the final export resolution.
[0124] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0125] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0126] Figure 4 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0127] like Figure 4 As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0128] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0129] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as video processing methods. For example, in some embodiments, the video processing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the video processing method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the video processing method in any other appropriate manner (e.g., by means of firmware).
[0130] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0131] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0132] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0133] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0134] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0135] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0136] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of this disclosure can be achieved, and this document is not limited here.
[0137] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A video processing method, comprising: Acquire the number of original materials contained in the target video, the original resolution of each of the original materials, and the type of each of the original materials; wherein the types of the original materials include video materials and picture materials; Determining whether the number of the original material is greater than one; In response to the number of the original materials being greater than one, judging, according to the type of the original materials, whether the target video contains at least two of the video materials; In response to the target video containing at least two of the video materials, calculating a resolution difference between the video materials according to an original resolution of each of the video materials; The export resolution of the target video is determined according to the resolution difference between the video materials and the export type of the target video.
2. The method according to claim 1, wherein: After determining whether the number of the original materials is greater than one, the method further includes: In response to the number of the original material being one, the export resolution of the target video is determined according to the type of the original material.
3. The method according to claim 2, wherein: In response to the number of the original material being one, determining the export resolution of the target video according to the type of the original material includes: If the type of the original material is the video material, the original resolution of the video material is used as the export resolution of the target video.
4. The method according to claim 2, wherein: In response to the number of the original material being one, determining the export resolution of the target video according to the type of the original material includes: If the type of the original material is the picture material, determining whether the original resolution of the picture material is greater than a preset resolution; In response to the original resolution of the picture material being greater than the preset resolution, using the preset resolution as the export resolution of the target video; In response to the original resolution of the picture material being not greater than the preset resolution, the original resolution of the picture material is used as the export resolution of the target video.
5. The method according to claim 1, wherein: After determining whether the target video contains at least two of the video materials, the method further includes: In response to the target video containing one of the video materials and one or more of the picture materials, the original resolution of the video material is used as the export resolution of the target video.
6. The method according to claim 1, wherein: After determining whether the target video contains at least two of the video materials, the method further includes: In response to the target video containing a plurality of the picture materials, calculating a resolution difference between the picture materials according to an original resolution of each of the picture materials; The export resolution of the target video is determined according to the resolution difference between the image materials and the export type of the target video.
7. The method according to claim 1, wherein: Determining the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video includes: If the export type of the target video is vertical screen, determine whether the resolution difference between the video materials is greater than a preset difference; In response to the resolution difference between the video materials being greater than the preset difference, the export resolution is determined according to a first preset aspect ratio and a maximum width of original resolutions of the video materials.
8. The method according to claim 7, wherein: The determining whether the resolution difference between the video materials is greater than a preset difference further includes: In response to the resolution difference between the video materials being not greater than the preset difference, the export resolution is determined according to a maximum width and a maximum aspect ratio in the original resolutions of the video materials.
9. The method according to claim 1, wherein: Determining the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video includes: If the export type of the target video is horizontal screen, determine whether the resolution difference between the video materials is greater than a preset difference; In response to the resolution difference between the video materials being greater than the preset difference, the export resolution is determined according to a second preset aspect ratio and a maximum height of the original resolutions of the video materials.
10. The method according to claim 9, wherein: The determining whether the resolution difference between the video materials is greater than a preset difference further includes: In response to the resolution difference between the video materials being not greater than the preset difference, the export resolution is determined according to a maximum height and a maximum aspect ratio in the original resolutions of the video materials.
11. A video processing device, comprising: An acquisition module, configured to acquire the number of original materials contained in the target video, the original resolution of each of the original materials, and the type of each of the original materials; wherein the type of the original materials includes video materials and picture materials; A first determination module is configured to determine whether the number of the original material is greater than one; A second determination module is configured to determine, in response to the number of the original materials being greater than one, whether the target video contains at least two of the video materials according to the type of the original materials; A calculation module, configured to calculate a resolution difference between the video materials according to an original resolution of each of the video materials in response to the target video containing at least two of the video materials; The first determination module is configured to determine the export resolution of the target video according to the resolution difference between the video materials and the export type of the target video.
12. The device according to claim 11, wherein Also includes: The second determination module is configured to determine the export resolution of the target video according to the type of the original material in response to the number of the original material being one after the first determination module determines whether the number of the original materials is greater than one.
13. The device according to claim 12, wherein: The second determining module comprises: The second determining unit is configured to use the original resolution of the video material as the export resolution of the target video if the type of the original material is the video material.
14. The device according to claim 12, wherein: The second determining module comprises: A second judgment unit is configured to judge whether the original resolution of the picture material is greater than a preset resolution if the type of the original material is the picture material; A second determining unit is configured to use the preset resolution as the export resolution of the target video in response to the original resolution of the picture material being greater than the preset resolution; In response to the original resolution of the picture material being not greater than the preset resolution, the second determining unit uses the original resolution of the picture material as the export resolution of the target video.
15. The device according to claim 11, wherein Also includes: The third determination module is configured to use the original resolution of the video material as the export resolution of the target video in response to the target video containing one video material and one or more picture materials after the second determination module determines whether the target video contains at least two of the video materials.
16. The device according to claim 11, wherein Also includes: A second calculation module is configured to calculate the resolution difference between the picture materials according to the original resolution of each picture material and the export type of the target video in response to the target video containing a plurality of the picture materials after the second judgment module determines whether the target video contains at least two of the video materials; The fourth determination module is configured to determine the export resolution of the target video according to the resolution difference between the image materials.
17. The device according to claim 11, wherein: The first determining module comprises: A first judgment unit is configured to judge whether the resolution difference between the video materials is greater than a preset difference if the export type of the target video is vertical screen; The first determining unit is configured to determine the export resolution according to a maximum width of a first preset aspect ratio and original resolutions of the video materials in response to the resolution difference between the video materials being greater than the preset difference.
18. The device according to claim 17, wherein: After the second judging unit judges whether the resolution difference between the video materials is greater than a preset difference, the method further includes: In response to the resolution difference between the video materials being not greater than the preset difference, the first determining unit determines the export resolution according to a maximum width and a maximum aspect ratio in the original resolution of the video materials.
19. The device according to claim 11, wherein: The first determining module comprises: A first judgment unit is configured to judge whether the resolution difference between the video materials is greater than a preset difference if the export type of the target video is horizontal screen; The first determining unit is configured to determine the export resolution according to a second preset aspect ratio and a maximum height of the original resolutions of the video materials in response to the resolution difference between the video materials being greater than the preset difference.
20. The device according to claim 19, wherein The first determining unit determines whether the resolution difference between the video materials is greater than a preset difference, and further includes: In response to the resolution difference between the video materials being not greater than the preset difference, the first determining unit determines the export resolution according to a maximum height and a maximum aspect ratio in the original resolution of the video materials.
21. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.
23. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.
