Video fragmentation method and device, equipment and storage medium
By dynamically adjusting the logical shard size and storage method of video, the longer the video time, the more shards are the problem, and the more video playback efficiency and user experience are improved.
Patent Information
- Application Number
- CN202510216585.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-05-30
AI Technical Summary
In the prior art, the longer the video time, the more logical shards are, which leads to the longer the video providing platform processing video playback requests and generating broadcast description information, the longer the user wait time, the worse experience, and the platform's processing burden.
By obtaining the total duration of the video, dynamically adjust the size of the logical shards, so that videos with longer durations can be sliced with larger shard sizes, thereby reducing the number of shards. The specific method includes determining the logical shard size based on the video duration, dividing the logical shards into multiple video files, storing them on different servers, and adding the number and playback order of the logical shards when generating the download address of the logical shards.
It reduces the number of fragments of videos with longer-lasting duration, shortens the time for video providing platforms to generate broadcast description information, reduces resource consumption, reduces the time for users to wait for video playback, and improves the video broadcast speed and user experience.
Smart Images

Figure CN120075527A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of video segmentation, and in particular to a video segmentation method, apparatus, device, and storage medium. Background Art
[0002] In the prior art, a video providing platform (i.e., a platform that can provide video resources to users) generally divides a complete video into multiple logical segments for storage. When a user requests to play a certain video, the video providing platform sends the video's start-up description information to the user. The video's start-up description information includes information on the download addresses of all the video's logical segments. The user downloads the corresponding logical segments from the corresponding server based on the download addresses of the logical segments. However, there is currently a situation where the longer the video, the more logical segments there will be. The longer it takes for the video providing platform to process the video playback request and generate the start-up description information, which in turn causes the user to wait longer for the video to play and have a poor experience. Moreover, the more logical segments there are, the more processing resources the video providing platform will consume when generating the start-up description information, thereby increasing the processing burden of the platform. Summary of the Invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a video segmentation method, apparatus, device and storage medium.
[0004] In a first aspect, an embodiment of the present disclosure provides a video segmentation method, the method comprising:
[0005] Obtaining a first duration of the video, where the first duration refers to the total duration of the video;
[0006] Determining, based on the first duration, the size of the logical segments of the video, wherein the size of the logical segments is positively correlated with the size of the first duration, the logical segments are the smallest data units into which the video is divided, and the number of the logical segments of the video is negatively correlated with the start speed of the video;
[0007] The video is segmented according to the size of the logical segments to obtain the logical segments of the video.
[0008] Optionally, determining the size of the logical segment of the video based on the first duration includes:
[0009] Based on the first duration, determining a target time range to which the first duration belongs from a plurality of preset time ranges;
[0010] Determine the shard size corresponding to the target time range based on a mapping relationship between the target time range and the shard size;
[0011] The segment size corresponding to the target time range is determined as the size of the logical segment of the video.
[0012] Optionally, determining the size of the logical segment of the video based on the first duration includes:
[0013] Based on the first duration and a preset first number of segments, the size of the logical segments of the video is determined, where the first number of segments refers to the total number of the logical segments of the video.
[0014] Optionally, determining the size of the logical segments of the video based on the first duration and a preset first number of segments includes:
[0015] Performing a division operation on the first duration and the first number of shards to obtain a second duration of a single logical shard;
[0016] The second duration is determined as the size of the logical segment of the video.
[0017] Optionally, before performing the division operation on the first duration and the first number of shards to obtain the second duration of a single logical shard, the method further includes:
[0018] Determining a total duration of the second number of logical shards based on a preset second number of shards and a preset third duration of a single shard, where the second number of shards is less than the first number of shards;
[0019] Subtracting the first duration from the total duration to obtain a fourth duration, and subtracting the first number of shards from the second number of shards to obtain a third number of shards;
[0020] Performing a division operation on the fourth duration and the third number of shards to obtain a fifth duration of a single logical shard;
[0021] In response to the fifth duration being greater than or equal to the third duration, determining, in accordance with the playback order of the logical segments, the sizes of the first second number of logical segments of the video as the third duration, and determining the sizes of the remaining logical segments of the video as the fifth duration;
[0022] In response to the fifth duration being smaller than the third duration, the step of dividing the first duration and the first number of fragments is performed to obtain a second duration of a single logical fragment, and determining the second duration as the size of the logical fragment of the video.
[0023] Optionally, the method of the first aspect further includes:
[0024] Dividing the logical segments of the video into one or more video files based on the playback order of the logical segments of the video in the video, wherein the video files include one or more logical segments with a continuous playback order;
[0025] The one or more video files are stored on one or more servers, wherein different video files are stored on different servers.
[0026] Optionally, the method of the first aspect further includes:
[0027] For any logical segment in the video file, the number of logical segments contained in the video file and the playback order of the logical segment among the number of logical segments are added to the storage address of the video file to generate a download address for the logical segment.
[0028] In a second aspect, an embodiment of the present disclosure provides a video segmentation device, the device comprising:
[0029] An acquisition module, configured to acquire a first duration of a video, where the first duration refers to the total duration of the video;
[0030] a determination module, configured to determine, based on the first duration, a size of a logical segment of the video, wherein the size of the logical segment is positively correlated with the size of the first duration, the logical segment being the smallest data unit into which the video is divided, and the number of logical segments of the video being negatively correlated with a playback speed of the video;
[0031] An execution module is used to slice the video according to the size of the logical slices to obtain the logical slices of the video.
[0032] Optionally, determine the module for:
[0033] Based on the first duration, determining a target time range to which the first duration belongs from a plurality of preset time ranges;
[0034] Determine the shard size corresponding to the target time range based on a mapping relationship between the target time range and the shard size;
[0035] The segment size corresponding to the target time range is determined as the size of the logical segment of the video.
[0036] Optionally, determine the module for:
[0037] Based on the first duration and a preset first number of segments, the size of the logical segments of the video is determined, where the first number of segments refers to the total number of the logical segments of the video.
[0038] Optionally, determine the module for:
[0039] Performing a division operation on the first duration and the first number of shards to obtain a second duration of a single logical shard;
[0040] The second duration is determined as the size of the logical segment of the video.
[0041] Optionally, determine the module for:
[0042] Determining a total duration of the second number of logical shards based on a preset second number of shards and a preset third duration of a single shard, where the second number of shards is less than the first number of shards;
[0043] Subtracting the first duration from the total duration to obtain a fourth duration, and subtracting the first number of shards from the second number of shards to obtain a third number of shards;
[0044] Performing a division operation on the fourth duration and the third number of shards to obtain a fifth duration of a single logical shard;
[0045] In response to the fifth duration being greater than or equal to the third duration, determining, in accordance with the playback order of the logical segments, the sizes of the first second number of logical segments of the video as the third duration, and determining the sizes of the remaining logical segments of the video as the fifth duration;
[0046] In response to the fifth duration being smaller than the third duration, the step of dividing the first duration and the first number of fragments is performed to obtain a second duration of a single logical fragment, and determining the second duration as the size of the logical fragment of the video.
[0047] Optionally, the video slicing device may further include:
[0048] a partitioning module, configured to partition the logical segments of the video into one or more video files based on the playback order of the logical segments of the video in the video, wherein the video files include one or more logical segments with a continuous playback order;
[0049] The execution module is further configured to store the one or more video files on one or more servers, wherein different video files are stored on different servers.
[0050] Optionally, the video slicing device may further include:
[0051] A generation module is used to add the number of logical segments contained in the video file and the playback order of the logical segment among the number of logical segments to the storage address of the video file for any logical segment in the video file, and generate a download address for the logical segment.
[0052] In a third aspect, an embodiment of the present disclosure provides a computer device, the computer device comprising:
[0053] Memory;
[0054] processor; and
[0055] computer programs;
[0056] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0057] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.
[0058] The video segmentation method, apparatus, device and storage medium provided by the embodiments of the present disclosure obtain the first duration of the video (i.e., the total duration of the video), determine the size of the logical segmentation of the video based on the first duration of the video, and segment the video according to the size of the logical segmentation to obtain the logical segmentation of the video. In the embodiment of the present disclosure, the first duration of the video and the size of the logical segment are positively correlated. The longer the first duration, the larger the size of the logical segment. In this case, determining the size of the logical segment according to this relationship and segmenting the video can reduce the number of segments of videos with longer durations. As the number of segments of the video decreases, the number of download addresses of the logical segments contained in the start-up description information of the video will also decrease accordingly, thereby reducing the amount of data required for the video providing platform to generate the start-up description information, shortening the time for the video providing platform to generate the start-up description information, and reducing the resource consumption of the video providing platform to generate the start-up description information. In addition, the reduction in the number of download addresses of the logical segments contained in the start-up description information of the video will reduce the data amount of the start-up description information, shorten the time required for the start-up description information to be transmitted to the user, thereby reducing the time the user waits for the video to play, improving the video start-up speed, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0060] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0061] Figure 1 This is a flowchart of a video segmentation method provided by an embodiment of the present disclosure;
[0062] Figure 2 This is a flow chart of a method for determining the size of a logical slice provided by an embodiment of the present disclosure;
[0063] Figure 3 is a flowchart of another method for determining the size of a logical slice provided by an embodiment of the present disclosure;
[0064] Figure 4 This is a flowchart of another method for determining the size of a logical slice provided by an embodiment of the present disclosure;
[0065] Figure 5 1 is a structural diagram of a video slicing device provided by an embodiment of the present disclosure;
[0066] Figure 6 A schematic diagram of the structure of a computer device embodiment provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0067] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.
[0068] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0069] In the prior art, users can select the playback position of a video by dragging the playback progress bar in the player. The purpose of the prior art to segment a video is also to quickly send the logical segment containing the playback position to the user after the user selects the playback position, thereby shortening the time the user waits for playback. For the same purpose, when the prior art segments a video, regardless of the length of the video, the video is segmented according to a fixed and smaller segment size. For example, if segmented according to a segment size of 2 seconds, a 60-minute video can be divided into 1,800 logical segments, while a 120-minute video can be divided into 3,600 logical segments. Therefore, the longer the video is, the more logical segments there are, and the more time and resources are required to generate the corresponding start-of-play description information.
[0070] However, in reality, users have different tolerances for waiting times for videos of different lengths. For longer videos, users are often more willing to accept a longer wait time. For example, in the prior art, the player size on the same playback page (e.g., both full-screen and half-screen) is fixed. The length of the corresponding player's progress bar is also fixed. For example, for a 46-minute video, the player's progress bar on the full-screen page is 10 centimeters long, while the progress bar on a 121-minute video is also 10 centimeters long. When playing the 121-minute video, if a user drags the progress bar by 1 centimeter, approximately 12.1 minutes of video will be skipped. On the other hand, when playing a 46-minute video, if the user drags the progress bar by 1 centimeter, approximately 4.6 minutes of video will be skipped. For both cases, when the total length of the video being watched is longer, users are generally more willing to accept a longer wait time because more video content is skipped. Based on this, the embodiment of the present disclosure provides a video segmentation method, which can dynamically adjust the size of the logical segments of the video, so that videos with longer durations are segmented with larger segment sizes, thereby reducing the number of segments of videos with longer durations, shortening the generation time of the start-up description information, reducing the resource consumption of generating the start-up description information, shortening the time users wait for the video to start, and improving the video start-up speed.
[0071] The video segmentation method, apparatus, device, and storage medium provided by the embodiments of the present disclosure are described below with reference to exemplary embodiments.
[0072] For example, Figure 1This is a flow chart of a video segmentation method provided by an embodiment of the present disclosure. The method can be executed by a computer device. The computer device can be exemplarily any device with computing power and video processing capabilities, such as a computer, a distributed computing node, and a server for providing video resources to users, but is not limited to the devices listed here. Figure 1 As shown, in some implementations, the video segmentation method provided by the embodiment of the present disclosure may include steps 101 to 103.
[0073] Step 101: Obtain a first duration of the video, where the first duration refers to the total duration of the video.
[0074] The video referred to in the embodiments of the present disclosure can be understood as a video obtained by a video producer, a video production device, or other video owners from other channels and uploaded to a video providing platform. The video can be a complete video, or it can be a portion of video content divided from a complete video with a larger granularity, such as the first half or the second half of a movie. When the video referred to in the embodiments of the present disclosure is a complete video, the first duration referred to in the embodiments of the present disclosure refers to the complete duration of the video. When the video referred to in the embodiments of the present disclosure is a portion of video content divided from a complete video with a larger granularity, the first duration referred to in the embodiments of the present disclosure refers to the duration of the portion of video content, such as the duration of the first half or the second half of the above-mentioned movie.
[0075] In the disclosed embodiments, the first duration can be obtained from the video data of a video. For example, the video data generally includes the image data of all frames in the video, the timestamps of all frames, and audio data. In some embodiments, the frames in the video data can be sequentially traversed, and the timestamp of the currently traversed frame can be compared with the traversal result of the previous traversal, where the traversal result of the previous traversal is the maximum timestamp among all timestamps traversed before the current moment. If the currently traversed timestamp is greater than the traversal result of the previous traversal, the currently traversed timestamp is used as the traversal result of the current traversal. If it is less than the traversal result of the previous traversal, the traversal result of the previous traversal is used as the traversal result of the current traversal. This process continues in this manner until the last frame is traversed. Alternatively, in other embodiments, the frames in the video can be sorted in chronological order based on the timestamps of the frames, and the timestamp of the last frame in the order can be obtained as the first duration. Of course, the above is merely an example of a method for obtaining the first duration, and is not intended to be the only limitation.
[0076] Step 102: Based on the first duration, determine the size of the logical segment of the video, where the size of the logical segment is positively correlated with the size of the first duration.
[0077] The logical segments referred to in the embodiments of the present disclosure can be understood as the smallest data unit for video segmentation. The size of a logical segment can be understood as the data size of the logical segment, or the duration of the content in the logical segment. The number of logical segments of a video is negatively correlated with the speed at which the video is played.
[0078] In some embodiments, a mapping relationship between video duration and segment size can be pre-set. Based on the mapping relationship, the size of the logical segment corresponding to the first duration is determined. In the above mapping relationship, there is a positive correlation between the video duration and the segment size, that is, the longer the video duration, the larger the size of the logical segment determined based on the mapping relationship. In the embodiment of the present disclosure, the mapping relationship between the video duration and the segment size can be set as needed, and the embodiment of the present disclosure does not make any specific limitations, as long as there is a positive correlation between the video duration and the segment size in the mapping relationship.
[0079] In some embodiments, the embodiments disclosed herein may also pre-set a minimum logical segment size and / or a maximum logical segment size. When the video duration is less than or equal to a first preset duration, the size of the logical segment is determined to be the preset minimum logical segment size, and / or when the video duration is greater than or equal to a second preset duration, the size of the logical segment is determined to be the preset maximum logical segment size.
[0080] By setting the minimum logical slice size and / or the maximum logical slice size, when the video length is less than or equal to the first preset length, the size of the logical slice is determined to be the preset minimum logical slice size, and / or, when the video length is greater than or equal to the second preset length, the size of the logical slice is determined to be the preset maximum logical slice size, thereby ensuring that the logical slice is neither too small nor too large.
[0081] Step 103: Segment the video according to the determined size of the logical segments to obtain logical segments of the video.
[0082] For example, assuming that the first duration is 120 minutes, and the size of the logical segment determined based on step 102 is 6 minutes, then starting from the start time of the video, the segment is divided into one segment every 6 minutes. A 120-minute video can be divided into 20 logical segments.
[0083] In some embodiments, after obtaining logical slices of the video, the logical slices can be further divided into one or more video files according to the playback order of the logical slices in the video, so that each video file includes one or more logical slices with a continuous playback order. Different video files are then stored on different servers, and the storage addresses of each video file are obtained. In the disclosed embodiments, a video file can be understood as a physical slice. This is equivalent to first slicing the video at a smaller granularity in some embodiments to obtain multiple logical slices of the video. These multiple logical slices can then be grouped at a larger granularity to obtain physical slices with a larger granularity. For example, if 15 logical slices are obtained based on the method of steps 101 to 103 above, after sorting these 15 logical slices according to the playback order, the first five can be divided into a single video file, the last five into another single video file, and the middle five into yet another single video file. These three video files can then be stored separately on different servers.
[0084] Multiple logical segments of a video are divided into one or more video files, and different video files are stored on different servers, making it easier to manage and search the logical segments of the same video on the server.
[0085] Furthermore, in some embodiments, after the video file is stored on the server, a step of generating a download address for each logical segment in the video file based on the storage address of the video file may be included. For example, in some embodiments, the number of logical segments contained in the video file and the playback order of the logical segments among all logical segments of the video file may be added as parameters to the download address of the video file to generate the download address of the logical segments. For example, if the download address of the video file is http: / / example.com / movie / segment1.ts and the video file contains 10 logical segments, the download address of the first logical segment in the video file may be expressed as: http: / / example.com / movie / segment1.ts?no=1&sum=10, where no=1 indicates the first logical segment in the video file, and sum=10 indicates that the video file contains 10 logical segments. Similarly, the download address of each logical segment in the video file may be obtained. When a user requests all logical segments in the video file, the download addresses of the logical segments contained in the video file can be sent to the user via an M3U8 file (an index file format). For example, the format of the M3U8 file can be exemplarily represented as follows:
[0086] #EXT-X-VERSION:3
[0087] #EXT-X-TARGETDURATION:10
[0088] #EXTINF:10.000,
[0089] http: / / example.com / movie / segment1.ts?no=1&sum=10
[0090] #EXTINF:10.000,
[0091] http: / / example.com / movie / segment1.ts?no=2&sum=10
[0092] #EXTINF:10.000,
[0093] http: / / example.com / movie / segment1.ts?no=3&sum=10
[0094] #EXTINF:10.000,
[0095] http: / / example.com / movie / segment1.ts?no=4&sum=10
[0096] #EXTINF:10.000,
[0097] http: / / example.com / movie / segment1.ts?no=5&sum=10
[0098] #EXTINF:10.000,
[0099] http: / / example.com / movie / segment1.ts?no=6&sum=10
[0100] #EXTINF:10.000,
[0101] http: / / example.com / movie / segment1.ts?no=7&sum=10
[0102] #EXTINF:10.000,
[0103] http: / / example.com / movie / segment1.ts?no=8&sum=10
[0104] #EXTINF:10.000,
[0105] http: / / example.com / movie / segment1.ts?no=9&sum=10
[0106] #EXTINF:10.000,
[0107] http: / / example.com / movie / segment1.ts?no=10&sum=10
[0108] Of course, the above is only an example of the format of the M3U8 file and not the only limitation.
[0109] It should be noted that in other implementations, the download addresses of the logical segments in the video file can also be sent to the user via a Media Presentation Description (MPD) file. The format of the MPD file can be found in related art and will not be described in detail here.
[0110] The disclosed embodiments generate download addresses for the logical segments by adding the playback order of the logical segments in the video file and the number of logical segments contained in the video file as parameters to the storage address of the video file. This improves the efficiency of generating download addresses. Upon receiving a user's playback request, the efficiency of obtaining the logical segment download addresses is also improved, shortening the time it takes to generate playback description information.
[0111] In the embodiment of the present disclosure, by obtaining the first duration of the video (i.e., the total duration of the video), the size of the logical segments of the video is determined based on the first duration of the video, and the video is segmented according to the size of the logical segments to obtain the logical segments of the video. In the embodiment of the present disclosure, the first duration of the video and the size of the logical segments are positively correlated. The longer the first duration, the larger the size of the logical segments. In this case, determining the size of the logical segments according to this relationship and segmenting the video can reduce the number of segments of videos with longer durations. As the number of segments of the video decreases, the number of download addresses of the logical segments contained in the start-up description information of the video will also decrease accordingly, thereby reducing the amount of data required to be processed by the video providing platform to generate the start-up description information, shortening the time for the video providing platform to generate the start-up description information, and reducing the resource consumption of the video providing platform to generate the start-up description information. In addition, the reduction in the number of download addresses of the logical segments contained in the start-up description information of the video will reduce the amount of data in the start-up description information, shorten the time required for the start-up description information to be transmitted to the user, thereby reducing the time the user waits for the video to play, increasing the start-up speed of the video, and improving the user experience.
[0112] Figure 2This is a flow chart of a method for determining the size of a logical slice provided by an embodiment of the present disclosure. Figure 2 As shown, in some implementations, the size of the logical slice can be determined by the method of steps 201 to 203.
[0113] Step 201: Based on a first duration, determine a target time range to which the first duration belongs from a plurality of preset time ranges.
[0114] Step 202: Based on the mapping relationship between the target time range and the fragment size, determine the fragment size corresponding to the target time range.
[0115] Step 203: Determine the segment size corresponding to the target time range as the size of the logical segment of the video.
[0116] Among them, the multiple time ranges referred to in the embodiment of the present disclosure can be divided as needed, and the embodiment of the present disclosure does not make specific limitations.
[0117] In some embodiments, a time range can correspond to a logical segment size. For example, in one example, the video duration can be divided into three time ranges: [0-60] minutes, [61-180] minutes, and [181-540] minutes. The logical segment size corresponding to [0-60] minutes can be 6 seconds, the logical segment size corresponding to [61-180] minutes can be 18 seconds, and the logical segment size corresponding to [181-540] minutes can be 54 seconds. Thus, if the video duration is 60 minutes, the video can be segmented based on a segment size of 6 seconds to obtain 600 logical segments. If the video duration is 180 minutes, the video can be segmented based on a segment size of 18 seconds to obtain 600 logical segments. Similarly, if the video duration is 540 minutes, the video can be segmented based on a segment size of 54 seconds to obtain 600 logical segments. That is, in some embodiments, within each of the multiple time ranges, the number of video segments may be a set value. Of course, this is merely an example and not a sole limitation.
[0118] By setting multiple time ranges and the logical segment size corresponding to each time range, a positive correlation is established between the video duration and the logical segment size. When determining the size of the logical segment, the size of the logical segment is determined according to the time range to which the video duration belongs. This can reduce the number of segments of videos with longer durations, improve the efficiency of generating playback description information, and reduce resource consumption when generating playback description information.
[0119] For example, in some embodiments, the disclosed embodiments may also determine the size of the logical segments based on the first duration of the video and the preset first number of segments. The first number of segments refers to the total number of logical segments into which the video is divided. Specifically, Figure 3 This is a flow chart of another method for determining the size of a logical slice provided by an embodiment of the present disclosure. Figure 3 As shown, in some implementations, the size of the logical slice can be determined through the method of steps 301 and 302.
[0120] Step 301: Perform a division operation on the first duration and the first number of shards to obtain a second duration of a single logical shard.
[0121] Step 302: Determine the second duration as the size of the logical slice.
[0122] For example, the total duration of the video, that is, the first duration is 60 minutes, and the number of first segments is 6 seconds. Then, the size of the logical segment is 60 multiplied by 60 divided by 600, which equals 6 seconds.
[0123] Of course, this is only an example and not a limitation.
[0124] By setting the first number of segments, dividing the first duration of the video by the first number of segments, and using the calculated result as the size of the logical segment, it can be ensured that all videos have a uniform number of segments, which facilitates management.
[0125] For example, Figure 4 This is a flow chart of another method for determining the size of a logical slice provided by an embodiment of the present disclosure. Figure 4 As shown, in some implementations, on the premise of setting the first number of shards, the size of the logical shards can also be determined through the method of steps 401 to 405.
[0126] Step 401: Based on a preset second number of shards and a preset third duration of a single shard, determine the total duration of the second number of logical shards.
[0127] In the embodiment of the present disclosure, the third duration of a single fragment, the second number of fragments, and the first number of fragments are all set values, and the second number of fragments is smaller than the first number of fragments.
[0128] In some implementations, the total duration of the second number of logical shards can be obtained by multiplying the second number of shards by the third duration. For example, if the second number of shards is 5 and the third duration of a single shard is 3 seconds, the total duration of the five logical shards is 15 seconds.
[0129] Step 402: Subtract the first duration from the total duration to obtain a fourth duration, and subtract the first number of slices from the second number of slices to obtain a third number of slices.
[0130] Assuming the first duration is 3600 seconds, the first number of shards is 600, the second number of shards is 5, and the third duration of a single shard is 3 seconds, then the total duration of the second number of shards (i.e., 5) is 15 seconds. Subtracting 15 seconds from 3600 seconds yields a fourth duration of 3585 seconds. Subtracting the first and second numbers of shards yields a third number of shards of 595.
[0131] Step 403: Perform a division operation on the fourth duration and the third number of shards to obtain a fifth duration of a single logical shard.
[0132] Continuing with the previous example, dividing 3585 by 595 gives a fifth duration of approximately 6 seconds.
[0133] Step 404: In response to the fifth duration being greater than or equal to the third duration, according to the playback order of the logical segments, the size of the second number of logical segments before the video is determined as the third duration, and the size of the remaining logical segments of the video is determined as the fifth duration.
[0134] Continuing with the above example, the fifth duration is 6 seconds, the third duration is 3 seconds, and the fifth duration is greater than the third duration. Therefore, the size of the first 5 logical segments of the video is determined to be 3 seconds, and the size of the remaining 3585 logical segments is determined to be 6 seconds.
[0135] Step 405: In response to the fifth duration being smaller than the third duration, the first duration and the first number of segments are divided to obtain a second duration of a single logical segment, and the second duration is determined as the size of the logical segment of the video.
[0136] The disclosed embodiment pre-sets the third duration of a single segment and the second number of segments, calculates the fifth duration of a single logical segment, and, when the third duration is less than or equal to the fifth duration, determines the size of the first second number of logical segments of the video as the third duration, and determines the size of the remaining logical segments of the video as the fifth duration. This can reduce the number of segments of a video with a longer duration and shorten the waiting time before initial playback.
[0137] Figure 5 FIG. 1 is a structural diagram of a video slicing device provided by an embodiment of the present disclosure. Figure 5 As shown, the slicing device 50 includes:
[0138] An acquisition module 51 is configured to acquire a first duration of a video, where the first duration refers to the total duration of the video;
[0139] a determination module 52 configured to determine, based on the first duration, a size of a logical segment of the video, wherein the size of the logical segment is positively correlated with the first duration, the logical segment being the smallest data unit into which the video is divided, and the number of logical segments of the video being negatively correlated with a playback speed of the video;
[0140] The execution module 53 is configured to segment the video according to the size of the logical segments to obtain the logical segments of the video.
[0141] Optionally, the determination module 52 is configured to:
[0142] Based on the first duration, determining a target time range to which the first duration belongs from a plurality of preset time ranges;
[0143] Determine the shard size corresponding to the target time range based on a mapping relationship between the target time range and the shard size;
[0144] The segment size corresponding to the target time range is determined as the size of the logical segment of the video.
[0145] Optionally, the determination module 52 is configured to:
[0146] Based on the first duration and a preset first number of segments, the size of the logical segments of the video is determined, where the first number of segments refers to the total number of the logical segments of the video.
[0147] Optionally, the determination module 52 is configured to:
[0148] Performing a division operation on the first duration and the first number of shards to obtain a second duration of a single logical shard;
[0149] The second duration is determined as the size of the logical segment of the video.
[0150] Optionally, the determination module 52 is configured to:
[0151] Determining a total duration of the second number of logical shards based on a preset second number of shards and a preset third duration of a single shard, where the second number of shards is less than the first number of shards;
[0152] Subtracting the first duration from the total duration to obtain a fourth duration, and subtracting the first number of shards from the second number of shards to obtain a third number of shards;
[0153] Performing a division operation on the fourth duration and the third number of shards to obtain a fifth duration of a single logical shard;
[0154] In response to the fifth duration being greater than or equal to the third duration, determining, in accordance with the playback order of the logical segments, the sizes of the first second number of logical segments of the video as the third duration, and determining the sizes of the remaining logical segments of the video as the fifth duration;
[0155] In response to the fifth duration being smaller than the third duration, the step of dividing the first duration and the first number of fragments is performed to obtain a second duration of a single logical fragment, and determining the second duration as the size of the logical fragment of the video.
[0156] Optionally, the video slicing device may further include:
[0157] a partitioning module, configured to partition the logical segments of the video into one or more video files based on the playback order of the logical segments of the video in the video, wherein the video files include one or more logical segments with a continuous playback order;
[0158] The execution module is further configured to store the one or more video files on one or more servers, wherein different video files are stored on different servers.
[0159] Optionally, the video slicing device may further include:
[0160] A generation module is used to add the number of logical segments contained in the video file and the playback order of the logical segment among the number of logical segments to the storage address of the video file for any logical segment in the video file, and generate a download address for the logical segment.
[0161] The device provided in the embodiments of the present disclosure can execute the method of any of the above method embodiments, and its execution method and beneficial effects are similar and will not be repeated here.
[0162] It should also be noted that the division of modules in the above-mentioned sharding device in the embodiments of the present disclosure is illustrative and is merely a logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in the various embodiments of the present application may be integrated into a single processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules.
[0163] If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a processor-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present disclosure.
[0164] Figure 6 This is a schematic diagram of the structure of a computer device embodiment provided by the present disclosure. Figure 6 As shown, the computer device includes a memory 121 and a processor 122 .
[0165] Memory 121 is used to store programs. In addition to the aforementioned programs, memory 121 may also be configured to store various other data to support operations on the computer device. Examples of such data include instructions for any application or method operating on the computer device, contact member data, phonebook member data, messages, images, videos, etc.
[0166] The memory 121 can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0167] The processor 122 is coupled to the memory 121 and executes the program stored in the memory 121 to implement the method of any of the above method embodiments.
[0168] Further, if Figure 6 As shown, the computer device may further include: a communication component 123, a power component 124, an audio component 125, a display 126 and other components. Figure 6 Only some components are shown schematically, which does not mean that the computer equipment only includes Figure 6 Components shown.
[0169] The communication component 123 is configured to facilitate wired or wireless communication between the computer device and other devices. The computer device can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 123 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 123 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared member data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0170] The power supply component 124 provides power to various components of the computer device. The power supply component 124 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the computer device.
[0171] The audio component 125 is configured to output and / or input audio signals. For example, the audio component 125 includes a microphone (MIC), which is configured to receive external audio signals when the computer device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 121 or transmitted via the communication component 123. In some embodiments, the audio component 125 also includes a speaker for outputting audio signals.
[0172] The display 126 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0173] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the method described in any of the above method embodiments.
[0174] In the embodiments of the present disclosure, the above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drives (SSDs)), etc.
[0175] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage and optical storage) containing computer-usable program code.
[0176] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0177] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.
Claims
1. A video segmentation method, characterized in that: The method comprises: Obtaining a first duration of a video, where the first duration refers to a total duration of the video; Based on the first duration, determine the size of the logical segment of the video, the size of the logical segment is positively correlated with the size of the first duration, the logical segment refers to the smallest data unit into which the video is divided, and the number of the logical segments of the video is negatively correlated with the start speed of the video; The video is segmented according to the size of the logical segments to obtain logical segments of the video.
2. The method according to claim 1, characterized in that The determining, based on the first duration, the size of the logical segment of the video includes: Based on the first duration, determining a target time range to which the first duration belongs from a plurality of preset time ranges; Determine the shard size corresponding to the target time range based on the mapping relationship between the target time range and the shard size; The segment size corresponding to the target time range is determined as the size of the logical segment of the video.
3. The method according to claim 1, characterized in that The determining, based on the first duration, the size of the logical segment of the video includes: Based on the first duration and a preset first number of segments, the size of the logical segments of the video is determined, where the first number of segments refers to the total number of the logical segments of the video.
4. The method according to claim 3, characterized in that The determining, based on the first duration and a preset first number of segments, the size of the logical segments of the video includes: Performing a division operation on the first duration and the first number of shards to obtain a second duration of a single logical shard; The second duration is determined as the size of the logical segment of the video.
5. The method according to claim 4, characterized in that The method of dividing the first duration by the first number of shards to obtain a second duration of a single logical shard includes: Determine the total duration of the second number of logical shards based on a preset second number of shards and a preset third duration of a single shard, where the second number of shards is less than the first number of shards; Subtracting the first duration from the total duration to obtain a fourth duration, and subtracting the first number of slices from the second number of slices to obtain a third number of slices; Performing a division operation on the fourth duration and the third number of shards to obtain a fifth duration of a single logical shard; In response to the fifth duration being greater than or equal to the third duration, according to the playback order of the logical segments, the sizes of the logical segments of the first second segment of the video are determined as the third duration, and the sizes of the remaining logical segments of the video are determined as the fifth duration; In response to the fifth duration being smaller than the third duration, the step of dividing the first duration and the first number of segments to obtain a second duration of a single logical segment and determining the second duration as the size of the logical segment of the video is performed.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Based on the playback order of the logical segments of the video in the video, dividing the logical segments of the video into one or more video files, wherein the video files include one or more logical segments with a continuous playback order; The one or more video files are stored on one or more servers, wherein different video files are stored on different servers.
7. The method according to claim 6, characterized in that The method further comprises: For any logical segment in the video file, the number of logical segments contained in the video file and the playback order of any logical segment among the number of logical segments are added to the storage address of the video file to generate a download address for the any logical segment.
8. A video slicing device, characterized in that: include: An acquisition module, used to acquire a first duration of a video, where the first duration refers to a total duration of the video; A determination module, configured to determine the size of the logical slice of the video based on the first duration, wherein the size of the logical slice is positively correlated with the size of the first duration, the logical slice refers to the smallest data unit into which the video is divided, and the number of the logical slices of the video is negatively correlated with the start speed of the video; The execution module is used to slice the video according to the size of the logical slices to obtain the logical slices of the video.
9. A computer device, characterized in that: The computer device comprises: Memory; Processor; and Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.