A chunking method and apparatus based on block storage
By creating allocation indexes for storage blocks and using red-black trees (RBTrees) to manage storage block allocation, the performance loss and data loss issues during the block slicing process in the monitoring storage scheme are resolved, achieving efficient utilization of storage blocks and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-30
- Publication Date
- 2026-05-15
AI Technical Summary
Existing surveillance storage solutions suffer from problems such as significant performance loss, high risk of data loss, storage blocks not being allocated under ideal conditions, and wasted hard disk space during the block partitioning process, and cannot improve the read and write efficiency of the read and write heads.
By pre-establishing allocation indexes for multiple storage blocks and pre-allocating storage blocks to multiple channels based on channel parameters of audio and video storage channels and changes in storage disks, and by using Red-Black Trees (RBTrees) to manage storage block allocation and reclamation, the allocation strategy for storage blocks is optimized.
It eliminates the time consumed by block selection, avoids the loss of recorded data, improves the utilization of storage blocks, enhances the integrity and stability of the monitoring storage system, and improves read and write efficiency.
Smart Images

Figure CN114579035B_ABST
Abstract
Description
Technical Field
[0001] This article relates to data storage technology, and more particularly to a block storage-based slicing method and apparatus. Background Technology
[0002] Current monitoring systems typically allocate a certain amount of memory space as a buffer for each connected front-end camera to assemble the received data streams into a specific format for easy storage. The system's storage management module manages storage resources, such as integrating all connected hard drives and organizing them in a structured manner. It provides interfaces for the data stream receiving modules to request free storage space and to store the received data streams on the hard drives. This organization often utilizes a specific file system.
[0003] In the current backend monitoring storage solution, the overall file switching process is serial; that is, the currently written file is closed first, and then a new file is requested. The entire process is executed serially. Common optimization solutions for the current storage solution include the following:
[0004] 1. Increase the buffer size of the receiving module, or reduce the number of steps in closing old files and opening new files to increase tolerance for data accumulation from the front-end camera;
[0005] 2. Dynamically adjust storage units. By comparing the size of the file to be stored with the remaining space of the storage unit, if the file to be stored is less than or equal to the remaining space of the storage unit, the storage unit size is kept unchanged for storage; otherwise, the storage unit size is expanded or reduced to accommodate the size of the file to be stored.
[0006] 3. By dividing the hard disk space, setting up management blocks and multiple storage blocks, the hard disk and storage blocks are managed separately through the management blocks, and the storage blocks are independent of each other and do not affect each other.
[0007] 4. Currently, in block storage, when a storage block in a channel has finished storing data and needs to be split into new blocks, the next storage block is searched for for subsequent storage.
[0008] The current solution has the following problems:
[0009] 1. Increasing the buffer of the receiving module will occupy more device memory and increase the cost of the device; while simplifying the file switching process is usually quite difficult and may even sacrifice data integrity.
[0010] 2. Dynamically adjusting storage units has the drawback of being difficult to manage and maintain when overwriting after the disk is full. For example, if a large storage block was previously allocated for storage, should the block be overwritten directly or divided into smaller blocks during overwriting? Therefore, there are many issues to be resolved and discussed when overwriting after the disk is full.
[0011] 3. Divide the hard drive space. Although this method divides the space in advance, it cannot dynamically adjust the retention period of each channel, which will result in a waste of hard drive space.
[0012] 4. The search for or selection of subsequent storage blocks (block selection) only occurs when the current storage block has finished storing data. On one hand, this incurs significant system performance overhead (the closing operation of the current storage block, the subsequent block selection operation, and the processing of new block header information all add up to a considerable cost). On the other hand, since block selection requires processing some data and parameters, if multiple channels are processing simultaneously, and a subsequent storage block is not selected in time, resulting in data not being promptly flushed to that block, the data stored in the buffer is highly likely to be discarded, leading to the risk of lost recordings.
[0013] 5. None of the aforementioned solutions address how to mitigate performance loss during block slicing, or how the storage blocks are not allocated under ideal conditions, thus failing to improve read / write efficiency of the magnetic head. Summary of the Invention
[0014] This application provides a block-based storage segmentation method and apparatus that can eliminate the time consumed by block selection, avoid the loss of recorded audio and video, improve the utilization rate of storage blocks, improve the integrity and stability of the monitoring storage system, and improve read and write efficiency.
[0015] This application provides a block-based storage-based segmentation method, which may include:
[0016] Retrieve multiple storage blocks to be allocated;
[0017] The multiple storage blocks are numbered according to a preset order, and an allocation index is established for the multiple storage blocks according to the numbering.
[0018] The multiple storage blocks are pre-allocated to multiple channels according to the channel parameters of the audio and video storage channels and the allocation index, and the storage blocks allocated to the channels are adjusted according to the changes in the storage channels and / or storage disks.
[0019] The channel parameters include any one or more of the following: channel bitrate, channel capacity, number of channels, and channel retention period; the changes in the storage channels and / or storage disks include any one or more of the following: channel deletion, channel addition, channel offline, channel re-bringing online, storage disk deletion, and storage disk addition.
[0020] In an exemplary embodiment of this application, when the allocated storage block is a new storage block partitioned from an existing storage disk, the step of pre-allocating the plurality of storage blocks to the plurality of channels according to the channel parameters of the audio / video storage channels and the allocation index includes:
[0021] Detect whether the channel bitrates of the multiple channels are the same; based on the detection results, allocate the multiple storage blocks according to the following allocation strategy:
[0022] When the channel code rates of the multiple channels are the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a manner that one storage block is allocated to each channel at a time, until all storage blocks are allocated.
[0023] When the channel bitrates of the multiple channels are not the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a manner that matches the number of storage blocks allocated to each channel each time with the ratio of the channel bitrates of the multiple channels, until all storage blocks are allocated.
[0024] In an exemplary embodiment of this application, the step of pre-allocating the plurality of storage blocks to the plurality of channels according to the channel parameters of the audio / video storage channels and the allocation index may further include:
[0025] After all new storage blocks allocated from the existing storage disks have been allocated, the system begins to reclaim storage blocks in deleted channels, channels with offline durations exceeding a preset duration threshold, and / or channels that have reached their retention period as old blocks, and allocates these old blocks to channels that require pre-allocation of storage blocks; or, it reclaims the earliest allocated storage block in the channel that requires pre-allocation of storage blocks as a copy block, and then reassigns the copy block to the channel.
[0026] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may include:
[0027] When a new storage disk is added and / or the capacity of the existing storage disk increases, new storage blocks are allocated based on the new storage disk and / or the increased capacity of the existing storage disk, and the new storage blocks are allocated to multiple channels according to the allocation strategy until all the new storage blocks are allocated.
[0028] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may further include:
[0029] When at least one of the multiple channels is deleted, according to the allocation strategy, the storage blocks in the deleted channel that have exceeded the channel retention period will be reclaimed and allocated to online channels until the channel retention period of each online channel is the same; and / or,
[0030] When at least one of the multiple channels goes offline, according to the allocation strategy, the storage blocks in the offline channel that have exceeded the channel retention period are sequentially allocated to the online channels until the channel retention period of each online channel is the same.
[0031] When both offline channels and deleted channels exist simultaneously, the storage blocks in the offline and deleted channels that have exceeded the channel retention period over time are sequentially reclaimed and stored in the Red-Black Tree (RBTree), and then allocated to online channels according to the allocation strategy.
[0032] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may further include:
[0033] After all new storage blocks have been allocated from the existing storage disks, when a new channel is added, old blocks or rewritten blocks reclaimed from the original channel will be allocated to the new channel until the channel retention period of each online channel is the same.
[0034] In an exemplary embodiment of this application, the recycling strategy for the old block and the rewrite block may include one or more of the following:
[0035] When there are new storage blocks that have not been fully allocated, the old blocks and the rewrite blocks are not reclaimed;
[0036] Once new storage blocks have been allocated, the old blocks or the rewrite blocks are reclaimed; however, if there are old blocks that can be reclaimed, the rewrite blocks are not reclaimed.
[0037] When any channel's offline time exceeds a preset time threshold and / or any channel is deleted, the storage blocks within that channel are reclaimed based on its retention period; and,
[0038] When a new storage disk is added, the old blocks and rewritten blocks in the channel are stopped from being recycled, and the new storage blocks allocated from the new storage disk are formatted and added to the Red-Black Tree (RBTree).
[0039] And / or,
[0040] The method may further include storing the recycled old blocks and the overwrite blocks in the nodes of the red-black tree (RBTree).
[0041] In an exemplary embodiment of this application, the method may further include: calculating the channel retention period for each channel based on the channel bitrate, the number of channels, the storage disk capacity, the size of each storage block, and a channel retention period calculation trigger event; the channel retention period refers to the duration for which audio and video are retained within the channel.
[0042] In an exemplary embodiment of this application, the step of calculating the channel retention period of each channel based on the channel bitrate, the number of channels, the storage disk capacity, the size of each storage block, and the channel retention period calculation trigger event may include: calculating the channel retention period according to a preset channel retention period calculation formula;
[0043] The formula for calculating the channel retention period may include:
[0044] Wherein, Time is the channel retention period, x is the channel bitrate, d is the storage disk capacity, c is the number of channels, b is the size of each storage block, and e is the calculation trigger event;
[0045] The calculation trigger event may include:
[0046] Changes to any one or more of the following values: channel bitrate, number of channels, storage disk capacity, and size of each storage block; and / or changes to the storage channels and / or storage disks.
[0047] This application also provides a block storage-based slicing device, which may include a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, characterized in that, when the instructions are executed by the processor, they implement the block storage-based slicing method described in any one of the above claims.
[0048] Compared with related technologies, the embodiments of this application may include: acquiring multiple storage blocks to be allocated; numbering the multiple storage blocks according to a preset order, and establishing an allocation index for the multiple storage blocks according to the numbering; pre-allocating the multiple storage blocks to multiple channels according to the channel parameters of the audio and video storage channels and the allocation index, and adjusting the storage blocks allocated to the channels according to changes in the storage channels and / or storage disks; wherein, the channel parameters include any one or more of the following: channel bitrate, channel capacity, number of channels, and channel retention period; the changes in the storage channels and / or storage disks include any one or more of the following: channel deletion, channel addition, channel offline, channel re-online, storage disk deletion, and storage disk addition. This embodiment eliminates the time consumed by block selection, avoids the loss of recorded audio and video, improves the utilization rate of storage blocks, enhances the integrity and stability of the monitoring storage system, and improves read and write efficiency.
[0049] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the solutions described in the description and drawings. Attached Figure Description
[0050] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0051] Figure 1 This is a flowchart of a block-based storage-based segmentation method according to an embodiment of this application;
[0052] Figure 2 This is a schematic diagram illustrating the coordinated operation of the various modules in an embodiment of this application;
[0053] Figure 3 This is a block diagram of a block storage-based slicing device according to an embodiment of this application. Detailed Implementation
[0054] This application describes several embodiments, but these descriptions are exemplary and not restrictive, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with or in lieu of any other feature or element in any other embodiment.
[0055] This application includes and contemplates combinations of features and elements known to those skilled in the art. The embodiments, features, and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive scheme as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive schemes to form another unique inventive scheme as defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in this application may be implemented individually or in any suitable combination. Therefore, the embodiments are not limited except by the limitations imposed by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
[0056] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to the specific order of steps described herein, to the extent that it does not depend on such a specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims concerning the method and / or process should not be limited to the steps performed in the written order, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.
[0057] A classic backend monitoring solution typically consists of the following modules: an IPC (Internet Protocol Camera) access management module, a stream data receiving module (hereinafter referred to as the receiving module), and a storage management module. The stream data primarily consists of audio and video data, but can be expanded to include various types of intelligent data.
[0058] This monitoring system typically allocates a certain amount of memory space as a buffer for each connected front-end camera to assemble the received bitstream data in a specific format for easy storage. The storage management module is mainly responsible for managing storage resources, such as integrating all connected hard drives in the system, organizing them in a certain way, providing interfaces for the receiving module to request free storage space, and storing the received bitstream data on the hard drive. The specific organization method can usually be a specific file system or a block-based storage system (the basic principles are similar, and will be referred to as file system below). Within the file system, there are additional management elements, such as filenames, sizes, and storage locations on the hard drive, which can be called the first-level index (metadata information describing each file in the file system). Within each file, data used to record the attributes of the bitstream data and its specific location within the file can be called the second-level index (metadata information describing audio, video, and intelligent data in the file).
[0059] In video surveillance file systems, considering overall management efficiency and space utilization, file sizes are typically fixed, such as 256MB or 1GB. A file can usually store data for an IPC for a period of time, but when the stored data reaches the fixed size, the current file can no longer be stored. The current file must be closed, and a new file must be requested from the storage module. The specific process is as follows: First, the corresponding secondary index information of the current file is explicitly written to the storage resource; then the file is closed, and the corresponding primary index information is updated. Next, a new file is requested from the storage module. After the new file is obtained, to ensure it is not occupied by other front-end cameras, it needs to be marked as used in the primary index. Simultaneously, the secondary index information must be initialized; therefore, an additional update of the primary and secondary indexes is required.
[0060] When the front-end camera continuously generates stream data, the receiving module switches to a different file every so often, with each switch accompanied by multiple updates to the primary and secondary indexes. During this switching process, if the receiving module's buffer is not large enough or the processing is not timely, a buffer overflow problem can occur, resulting in the loss of data acquired by the front-end camera.
[0061] In summary, the current storage solution incurs significant overhead during block partitioning and carries a risk of substantial video loss. Therefore, pre-allocating storage blocks can enable seamless data writing to block storage, improve system performance, and proactively mitigate the risk of data loss due to block selection methods.
[0062] This application provides a block-based storage-based segmentation method, such as... Figure 1 As shown, the method may include steps S101-S103:
[0063] S101. Obtain multiple storage blocks to be allocated;
[0064] S102. Number the plurality of storage blocks according to a preset order, and establish an allocation index for the plurality of storage blocks according to the numbering;
[0065] S103. The plurality of storage blocks are pre-allocated to the plurality of channels according to the channel parameters and the allocation index, and the storage blocks allocated to the channels are adjusted according to the changes in the storage channels and / or storage disks.
[0066] The channel parameters include any one or more of the following: channel bitrate, channel capacity, number of channels, and channel retention period; the changes in the storage channels and / or storage disks include any one or more of the following: channel deletion, channel addition, channel offline, channel re-bringing online, storage disk deletion, and storage disk addition.
[0067] In the exemplary embodiments of this application, the main purpose is to solve the problem that the file switching process in the current storage scheme is too long, causing system cache overflow and resulting in the loss of front-end camera data. The embodiment of this application proposes a storage block pre-allocation scheme to avoid the consumption caused by temporary block selection and switching when a storage block is full and there is no subsequent storage block to hand over, thereby improving the integrity and stability of the monitoring storage system.
[0068] In the exemplary embodiments of this application, the solution of the embodiments of this application is adopted such that each subsequent storage block is ready before the current storage block is completely stored, so that the data can be switched to the next storage block for storage in a timely manner, eliminating the time consumed by block selection and avoiding the risk of lost recorded data.
[0069] In an exemplary embodiment of this application, obtaining the plurality of storage blocks to be allocated may include:
[0070] The number of storage blocks to be allocated is calculated based on the channel parameters of the audio and video storage channel and the storage block parameters.
[0071] Based on the number of storage blocks to be allocated, a corresponding number of storage blocks are obtained from all storage blocks divided according to the current storage disk capacity; wherein, when the total number of all divided storage blocks is less than the calculated number of storage blocks to be allocated, the earliest allocated storage block that has been written to is reclaimed from the channel with insufficient storage blocks as a write block and redistributed to the channel to supplement the number of storage blocks.
[0072] In an exemplary embodiment of this application, calculating the number of multiple storage blocks to be allocated based on the channel parameters and storage block parameters of the audio and video storage channels may include: calculating how long it takes to consume one storage block based on parameters such as the current channel bitrate of each channel and the capacity of a storage block, and calculating the number of storage blocks required for each channel if the channel retention period of each channel is the same.
[0073] In an exemplary embodiment of this application, after acquiring multiple storage blocks to be allocated, before pre-allocating storage blocks to each channel, allocation indexes can be pre-established for the storage blocks. Based on the allocation index of each storage block, storage can be performed in an index-ordered manner. This can improve the utilization rate of storage blocks and reasonably allocate channel retention periods. Moreover, since the indexes of each storage block are ordered under stable conditions, and the allocation indexes of each storage block are pre-allocated and saved, data recovery and subsequent maintenance are facilitated in certain situations. Furthermore, the ordered storage block indexes of each channel facilitate the improvement of disk head read / write efficiency and disk input / output I / O efficiency.
[0074] In an exemplary embodiment of this application, since storage blocks are pre-allocated, the indexes of each channel and the pre-allocated indexes are saved. In case of an abnormal situation, it is also convenient to recover user data based on the index values and the pre-allocated index values.
[0075] In an exemplary embodiment of this application, the plurality of storage blocks are numbered according to a preset order, and an index is established for the plurality of storage blocks according to the numbering. This may include: marking the corresponding number of storage blocks to be allocated, for example, assigning a unique number to each storage block, and having a preset order for all storage block numbers so that the allocation index established according to the numbering is continuous (e.g., 1-100 allocation indexes, 2 channels, the first channel occupies 1, 3, 5, 7...99, and the second channel occupies 2, 4, 6, 8, 10...100), connecting these storage blocks end to end according to the numbering order, and marking which channel is used on each storage block, thereby establishing an allocation index for each storage block.
[0076] In an exemplary embodiment of this application, during the normal storage of audio and video data in the current storage block of a channel recording, the next storage block to be used can be pre-allocated according to the established allocation index, thereby realizing the pre-allocation of storage blocks.
[0077] In an exemplary embodiment of this application, when the allocated storage block is a new storage block partitioned from an existing storage disk (which can be simply referred to as a new block, meaning a block that has not been added to the management node), the pre-allocation of the plurality of storage blocks to the plurality of channels according to the channel parameters of the audio / video storage channels and the allocation index may include:
[0078] Detect whether the channel bitrates of the multiple channels are the same; based on the detection results, allocate the multiple storage blocks according to the following allocation strategy:
[0079] When the channel code rates of the multiple channels are the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a manner that one storage block is allocated to each channel at a time, until all storage blocks are allocated.
[0080] When the channel bitrates of the multiple channels are not the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a manner that matches the number of storage blocks allocated to each channel each time with the ratio of the channel bitrates of the multiple channels, until all storage blocks are allocated.
[0081] In an exemplary embodiment of this application, the newly partitioned storage blocks can be saved in a red-black tree (RBTree), and storage blocks can be allocated from the RBTree when allocating storage blocks.
[0082] In an exemplary embodiment of this application, the nodes (storage blocks) stored in the Red-Black Tree (RBTree) are not all allocated; instead, a few are allocated as needed. This is because when an event occurs, the storage blocks are adjusted. If all storage blocks are allocated to various channels, they need to be reclaimed. Therefore, the solution in this embodiment allocates storage blocks only when needed, rather than allocating them to various channels at once. For example, when the current storage block is 1 / 4 to 1 / 3 written (e.g., 1 / 4 can be selected), the next subsequent storage block should be selected, instead of allocating all nodes (storage blocks) in the RBTree to various channels. When an event occurs, only the number of storage blocks allocated next needs to be adjusted; if all are allocated to various channels, they need to be reclaimed and redistributed.
[0083] In an exemplary embodiment of this application, when allocating newly partitioned storage blocks to each channel, the allocation strategy described above can be followed. The allocation strategy will be described below with reference to a specific embodiment.
[0084] In an exemplary embodiment of this application, for example, the channel bitrate of each channel is first calculated. If there are two channels, D1 and D2, and both channels have a channel bitrate of 4M, then when allocating storage blocks, channels D1 (0, 2, 4, 8, 10, 12...) and channels D2 (1, 3, 5, 7, 9, 11, 13, 15...) can be allocated sequentially according to the storage block index. When there are 3 channels, the allocation method can be as shown in Table 1 below:
[0085] Table 1
[0086] Channel D1 1 4 7 10 13 Channel D2 2 5 8 11 14 Channel D3 3 6 9 12 15
[0087] In an exemplary embodiment of this application, if the channel code rates of channels D1 and D2 are 2M and 4M respectively, then when allocating storage blocks, channels D1 (0, 3, 6, 9, 12, 15, 18...) and channels D2 (1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17...) can be allocated sequentially. That is, channel D1 is allocated to one storage block each time, and channel D2 is allocated to two adjacent storage blocks each time. When there are three channels, if the channel code rate of channel D1 is 1M, the channel code rate of channel D2 is 2M, and the channel code rate of channel D3 is 4M, then assuming the channel retention period of the three channels is the same, one storage block is allocated for channel D1, two storage blocks for channel D2, and four storage blocks for channel D3 each time. The allocation method can be shown in Table 2 below:
[0088] Table 2
[0089] Channel 1 1 8 Channel 2 2 3 9 10 Channel 3 4 5 6 7 11 12 13 14
[0090] In an exemplary embodiment of this application, the step of pre-allocating the plurality of storage blocks to the plurality of channels according to the channel parameters of the audio / video storage channels and the allocation index may further include:
[0091] After all new storage blocks allocated from the existing storage disks have been allocated, the system begins to reclaim storage blocks in deleted channels, channels with offline durations exceeding a preset duration threshold, and / or channels that have reached their retention period as old blocks, and allocates these old blocks to channels that require pre-allocation of storage blocks; or, it reclaims the earliest allocated storage block in the channel that requires pre-allocation of storage blocks as a copy block, and then reassigns the copy block to the channel.
[0092] In an exemplary embodiment of this application, after all new storage blocks allocated from the existing storage disk have been allocated, old blocks or rewritten blocks can be reclaimed to pre-allocate storage blocks in the channel before any channel is about to be filled.
[0093] In an exemplary embodiment of this application, after the storage block allocation is completed, if there are old blocks available for reclamation, the old blocks are reclaimed first and then pre-allocated; if there are no old blocks available for reclamation, cyclic overwriting is performed within the storage blocks of the channel itself. For example:
[0094] In channel D1 (0, 3, 6, 9, 12, 15, 18, 21), when no new storage blocks are available, the oldest storage block is 21, which can be reclaimed for use as a write block in channel D1. The allocation result after reclamation is D1 (21, 0, 3, 6, 9, 12, 15, 18). When this channel needs to allocate storage blocks again, the allocation rule is the same, and 18 can be reclaimed as a write block.
[0095] In channel D2 (1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20), when there are no new storage blocks, the oldest storage block is 20, which can be reclaimed for use by channel D2. The allocation result of the reclaimed storage blocks is D2 (20, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19). When this channel needs to allocate storage blocks again, the allocation rule is the same, and 19 can be reclaimed as a write block.
[0096] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may include:
[0097] When a new storage disk is added and / or the capacity of the existing storage disk increases, new storage blocks are allocated based on the new storage disk and / or the increased capacity of the existing storage disk, and the new storage blocks are allocated to multiple channels according to the allocation strategy until all the new storage blocks are allocated.
[0098] In an exemplary embodiment of this application, if the storage capacity of certain channels is newly set, such as increasing or decreasing the storage capacity of a certain channel, the number of storage blocks corresponding to that channel will increase or decrease accordingly. The pre-allocation scheme can readjust the pre-allocated storage blocks. For example, if the storage capacity of a channel is increased, the storage blocks of other channels need to be adjusted and pre-allocated to that channel. If the storage capacity of a channel is decreased, some storage blocks in that channel are allocated to other channels, and the number of storage blocks in the corresponding other channels will increase, eventually reaching a stable state.
[0099] In an exemplary embodiment of this application, if a new storage disk is added, the new storage disk needs to be reformatted and divided into blocks. The newly divided storage blocks are then allocated to various channels as subsequent blocks (the other storage blocks in a channel besides the first storage block) according to a preset allocation strategy. Similarly, if the storage disk is offline, some storage blocks need to be selected from other channels for storage of recordings on certain channels.
[0100] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may further include:
[0101] When at least one of the multiple channels is deleted, according to the allocation strategy, the storage blocks in the deleted channel that have exceeded their channel retention period will be reclaimed sequentially and allocated to the online channels until the channel retention period of each online channel is the same; and / or,
[0102] When at least one of the multiple channels goes offline, according to the allocation strategy, the storage blocks in the offline channel that have exceeded the channel retention period are sequentially allocated to the online channels until the channel retention period of each online channel is the same.
[0103] When both offline channels and deleted channels exist simultaneously, the storage blocks in the offline and deleted channels that have exceeded the channel retention period over time are sequentially reclaimed and stored in the Red-Black Tree (RBTree), and then allocated to online channels according to the allocation strategy.
[0104] In an exemplary embodiment of this application, if a channel is deleted / offline, storage blocks that have exceeded the channel retention period can be allocated to each channel.
[0105] In an exemplary embodiment of this application, if a channel has been offline for a certain period of time and has not come back online, all storage blocks in that channel, including the oldest storage blocks to the second newest storage blocks that have been in use over time, can be pre-allocated to other channels to maximize the utilization of storage blocks and preserve the recording time of other channels for as long as possible.
[0106] In the exemplary embodiments of this application, each channel has been pre-allocated storage blocks. After stabilization, considering the possibility of adding new channels, it is necessary to allocate storage blocks to the new channels. Therefore, the storage blocks previously allocated to the channels must also be available for use by other channels. According to the allocation strategy, the oldest (i.e., earliest) storage block of each channel can be released to the newly added channel. The selection of which channel's oldest storage block to use can be based on the allocation strategy. For example, if channel D1 has a 1M bitrate and channel D2 has a 4M bitrate, within the same retention period, D1 has one storage block and D4 has four storage blocks. The oldest block of channel D2 can be selected for use by the newly added channel.
[0107] In the exemplary embodiments of this application, the oldest storage block is generally released; otherwise, directly taking it from the second-to-last storage block would destroy the integrity of the original channel recording. Therefore, even when releasing, only the oldest storage block of each channel is released.
[0108] In an exemplary embodiment of this application, when the disk space is full, subsequent audio and video data needs to overwrite the storage block containing the oldest audio and video data. The oldest (earliest) storage block (rewrite block) will also be added to the pre-allocated block. Ultimately, under stable conditions, the rewrite blocks of each channel will be used cyclically within the storage block occupied by their own recordings. This stable state means that the recording retention time of each channel is roughly the same, for example, each channel can retain 15 days of recordings. The ordered state means that the indexes of some channel blocks are ordered, for example, the storage block index values follow an increasing or decreasing trend. For example, if a channel block index is: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 (1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21), where 21 is the current storage block. In the case of full coverage, the inner circular block 1 is used as the first storage block and marked as not to be occupied by other channels or not to be pre-allocated. 3-21 represent the subsequent pre-allocated storage blocks, which can be allocated by other channels as subsequent blocks (i.e., storage blocks after the first storage block).
[0109] In an exemplary embodiment of this application, adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk may further include:
[0110] After all new storage blocks have been allocated from the existing storage disks, when a new channel is added, old blocks or rewritten blocks reclaimed from the original channel will be allocated to the new channel until the channel retention period of each online channel is the same.
[0111] In an exemplary embodiment of this application, if new storage blocks have been allocated and a new channel is added, blocks reclaimed from other channels can be allocated to that channel until the channel retention period of each channel is the same.
[0112] In an exemplary embodiment of this application, if parameters such as the channel bitstream or encoding format of certain channels are adjusted, the pre-allocated storage blocks of each channel can be readjusted to eventually reach a stable state.
[0113] In exemplary embodiments of this application, as Figure 2 As shown, the solution of this application embodiment may include multiple working modules, such as a block allocation module, a block reclamation module, a channel retention period calculation module, and a channel linked list management module. These modules can work together to complete the solution of this application embodiment.
[0114] In an exemplary embodiment of this application, the above storage block allocation scheme can be completed by a preset block allocation module, and the allocation strategy can be implemented by a preset allocation function, for example, Y = f3(t, x), where Y represents the allocation function, t represents a new storage block, an old block, a rewrite block, etc., and x is a parameter such as the channel bit rate.
[0115] In an exemplary embodiment of this application, the storage block reclamation strategy is described in detail below. This reclamation strategy can be completed by a preset block reclamation module.
[0116] In an exemplary embodiment of this application, the recycling strategy for the old block and the rewrite block includes one or more of the following:
[0117] When there are new storage blocks that have not been fully allocated, the old blocks and the rewrite blocks are not reclaimed;
[0118] Once new storage blocks have been allocated, the old blocks or the rewrite blocks are reclaimed; however, if there are old blocks that can be reclaimed, the rewrite blocks are not reclaimed.
[0119] When any channel's offline time exceeds a preset time threshold and / or any channel is deleted, the storage blocks within that channel are reclaimed based on its retention period; and,
[0120] When a new storage disk is added, the old blocks and rewrite blocks in the channel are stopped from being recycled. The new storage blocks allocated from the new storage disk are formatted and added to the Red-Black Tree (RBTree).
[0121] In an exemplary embodiment of this application, the method may further include storing the recycled old blocks and the rewritten blocks in the nodes of the red-black tree (RBTree).
[0122] In an exemplary embodiment of this application, the storage blocks that need to be reclaimed for each channel can be calculated based on the channel retention period under various circumstances (e.g., channel deletion, channel addition, channel offline, channel re-online, etc.), and then the blocks can be delivered to the block allocation module.
[0123] In an exemplary embodiment of this application, when the block recycling module performs block recycling, it can first determine the conditions for block recycling. In some cases, block recycling is not performed immediately. For example, if the IPC offline time has not exceeded the preset time, block recycling is not performed immediately. The purpose is to avoid frequent offline and online cycles causing the block recycling module to process too much. At this time, the channel retention period of each channel can be calculated, and the storage blocks that have reached the channel retention period can be recycled.
[0124] In an exemplary embodiment of this application, the storage blocks occupied by each channel can be processed using a channel linked list. Released and reclaimed storage blocks can be stored using a binary tree, such as a red-black tree (RBTree). During storage, the storage block with the smallest block number in the binary tree can be sequentially retrieved and allocated to each channel.
[0125] In an exemplary embodiment of this application, before the block reclamation module begins reclamation, new storage blocks can be allocated to each channel until all allocations are complete. Subsequent reclamation involves submitting the oldest (earliest) storage block from each channel to the block reclamation module, where it is reclaimed as a write block. The reclaimed storage blocks (write blocks) are then reassigned to the previous channels. Old blocks are reclaimed from other channels (such as deleted channels, channels exceeding their retention period, or channels with long offline times). Specifically, if old blocks exist, the oldest storage block in the current channel is not reclaimed initially; instead, it is reclaimed only after all old blocks have been allocated.
[0126] In an exemplary embodiment of this application, the recycling strategy for old blocks and rewritten blocks can be implemented through a preset recycling function, such as the function free = f2(c,t). This function is used for recycling old blocks and rewritten blocks, and the storage blocks recycled by the free function are allocated to each channel. The free function can determine whether the storage blocks in a channel can be recycled based on the calculation result of the channel retention period t of each channel, and recycle the storage blocks of each channel c and add them to the RBTree tree.
[0127] In an exemplary embodiment of this application, if new storage blocks are not fully allocated in the RBTree tree, the oldest storage block (rewrite block) of each channel is not reclaimed. The RBTree tree stores only new storage blocks. If new storage block allocation is complete, it checks if any old blocks can be reclaimed. If so, the reclaimed old blocks are stored as new blocks (new storage blocks) in the RBTree tree. If no old blocks are found, the oldest storage block (rewrite block) from each channel is added to the RBTree tree. Therefore, when a new storage disk is added or an old storage disk is formatted, the RBTree tree stores only new storage blocks. After new storage block allocation is complete, the number of storage blocks stored in the RBTree tree is at most the number of channels added. If new storage block allocation is complete and no other events occur, such as adding or deleting channels or storage disks, the reclaimed rewrite blocks are still allocated to the channels before reclaiming, meaning the blocks are cyclically rewritten within the channels.
[0128] In an exemplary embodiment of this application, the calculation method for the channel retention period of each channel is described in detail below. The calculation of the channel retention period can be completed by the channel retention period calculation module.
[0129] In an exemplary embodiment of this application, the method may further include: calculating the channel retention period for each channel based on the channel bitrate, the number of channels, the storage disk capacity, the size of each storage block, and a channel retention period calculation trigger event; the channel retention period refers to the duration for which audio and video are retained within the channel.
[0130] In an exemplary embodiment of this application, the step of calculating the channel retention period of each channel based on the channel bitrate, the number of channels, the storage disk capacity, the size of each storage block, and the channel retention period calculation trigger event may include: calculating the channel retention period according to a preset channel retention period calculation formula;
[0131] The formula for calculating the channel retention period may include:
[0132] Wherein, Time is the channel retention period, x is the channel bitrate, d is the storage disk capacity, c is the number of channels, b is the size of each storage block, and e is the calculation trigger event;
[0133] The calculation trigger event may include:
[0134] Changes to any one or more of the following values: channel bitrate, number of channels, storage disk capacity, and size of each storage block; and / or changes to the storage channels and / or storage disks.
[0135] In an exemplary embodiment of this application, when a channel is online, the channel retention period for each channel can be calculated. When a channel is offline, if the offline time exceeds a preset time threshold, such as 1 hour, and the channel has not yet come back online, the channel retention period calculation module can be activated to calculate how long the recording can be retained for that channel, and based on the calculation result, the recycling module can be notified when to start recycling the oldest storage block of that channel.
[0136] In an exemplary embodiment of this application, when adding / deleting channels, the quota status of each channel can be calculated, and the recording retention time can be increased / decreased.
[0137] In an exemplary embodiment of this application, when adding or deleting storage disks, the channel retention period to be increased / decreased for each channel can also be calculated.
[0138] In an exemplary embodiment of this application, the channel retention period calculation module can first calculate the channel retention period, then calculate the storage blocks in each channel linked list. If it is found that a storage block in a channel can be reclaimed, the module is notified to reclaim it, and the channel linked list should release the earliest block node storing the data.
[0139] In an exemplary embodiment of this application, the channel retention period can be calculated using the following function (channel retention period calculation formula): Time = f(n,t) = n*t = f1(d,c,b,x,e);
[0140] Where Time is the channel retention period; x represents the current channel parameters, such as channel bitrate; e represents the triggering event (such as channel launch, video parameter changes, adding or deleting channels, etc.); n is the number of storage blocks in each channel, n = d / c / b; d refers to the storage disk capacity, c refers to the number of channels, and b is the size of each storage block, such as 1G or 0.5G; t is the retention time of a single storage block (in seconds); t = b / (x / 8 / 1000) seconds, where x is the IPC channel bitrate and b is the size of a single storage block.
[0141] In an exemplary embodiment of this application, for example: if the IPC channel code rate is 4M and b is 0.5G, then a storage block can store 1000 seconds, or 16.666667 minutes; then the retention period for each channel is: time = d / b*b / (x / 8 / 1000).
[0142] In the exemplary embodiment of this application, if a channel is added, c increases by 1 accordingly; if a storage disk (hard disk) is added, d increases. e is the calculation trigger event; when the event is triggered, it will trigger the calculation of the channel retention period for each channel. The channel retention period calculation formula can then be summarized as follows:
[0143]
[0144] This function can be used to calculate the current channel retention period.
[0145] In an exemplary embodiment of this application, an example is given: For instance, if a storage block is set to 0.5G in size, the IPC channel bitrate is 4M, and H.264 encoding is used, then a storage block can be filled in 16.67 minutes. If there is only one 1TB hard drive and only one D1 channel, the channel retention period can be 23.15 days (2000 storage blocks). If a D2 channel is added, the channel retention period for each channel is 11.57 days (1000 blocks). When another hard drive is added, condition e is triggered. If there are still two channels, the channel retention period for each channel is 23.15 days (2000 blocks). If one of the channel IPCs goes offline or is deleted, the oldest recording of that channel can be saved for 23.15 days, after which the corresponding oldest storage block is released. Over time, the storage blocks of that channel will be reclaimed sequentially. These released blocks can be added to the idle management module.
[0146] In an exemplary embodiment of this application, the aforementioned channel linked list can be managed by a channel linked list management module. This module can manage the storage blocks of each channel, including but not limited to: the number of storage blocks, and the information of the storage blocks in the channel linked list. The channel linked list management module is also used to synchronize information and ensure seamless data writing for the storage block that is about to be written and the next storage block to be written. After block partitioning, data cleanup work for the previous storage block is performed, including updating the first-level and second-level indexes of the storage block.
[0147] In an exemplary embodiment of this application, the management strategy of the channel linked list management module can be implemented through a management function, such as the function List = f4(x), where x records information such as the channel's block segmentation information, channel retention period information, and the number of storage blocks. The function's function may include: when a new storage block is allocated, it is continuously added to the head of the list, and the channel's information is updated. If no new storage block is allocated, the channel linked list management module accepts a storage block and then releases the oldest storage block to the recycling module.
[0148] In the exemplary embodiments of this application, the solution of the embodiments of this application will be further illustrated below by means of block segmentation.
[0149] In an exemplary embodiment of this application, if a device has two channels, such as channel 1 and channel 2, and the channel bitrate and other encoding parameters of the two channels are the same, and a hard disk is divided into 20 storage blocks (for ease of description, the number of blocks is small).
[0150] In an exemplary embodiment of this application, the ideal block occupancy is shown in Table 3 below:
[0151] Table 3
[0152] Channel 1 1 3 5 7 9 11 13 15 17 19 When copying: 1 3 5 7 9 11 13 15 17 19 Channel 2 2 4 6 8 10 12 14 16 18 20 2 4 6 8 10 12 14 16 18 20
[0153] In the exemplary embodiments of this application, if the bitrate or capacity settings of a certain channel are different, or due to historical recording reasons, coupled with the influence of the original block selection allocation strategy, the situation shown in Table 4 is very likely to occur after the upgrade:
[0154] Table 4
[0155]
[0156] If storage blocks are pre-allocated, the following situation may occur: When channel 1 and channel 2 are first stored, the first block indices are 9 and 3 respectively. Then, according to the pre-allocation strategy, the blocks will be divided as shown in Table 5 below:
[0157] Table 5
[0158] Channel 1 9 1 4 6 8 11 13 15 17 19 Channel 2 3 2 5 7 10 12 14 16 18 20
[0159] In an exemplary embodiment of this application, before adding channel 3, the block index usage of channels 1 and 2 can be shown in Table 6 below:
[0160] Table 6
[0161] Channel 1 9 1 4 6 8 11 13 15 17 19 Channel 2 3 2 5 7 10 12 14 16 18 20
[0162] After adding channel 3, the channel pre-allocated block indexes are shown in Table 7 below: the oldest storage blocks are allocated to channels 1, 2, and 3 in sequence. The gray background represents the block allocation before adding channel 3.
[0163] Table 7
[0164]
[0165] In an exemplary embodiment of this application, if channel 3 is offline, the current storage block allocation is as shown in Table 8 below (before channel 3 goes offline):
[0166] Table 8
[0167] Channel 1 1 5 8 12 15 18 Channel 2 3 4 7 11 14 17 20 Channel 3 9 2 6 10 13 16 19
[0168] After D3 is offline for an extended period and does not come back online, the storage blocks in channel 3 will be reclaimed and allocated to channels 1 and 2 in sequence after the channel retention period expires. The storage block pre-allocation will be as shown in Table 9 below. Since channel 3 is offline, one block index 19 can be reserved for channel 3.
[0169] Table 9
[0170]
[0171] In an exemplary embodiment of this application, if channel 3 is deleted, index 19 is not retained after the channel reservation period expires, as shown in Table 10:
[0172] Table 10
[0173]
[0174] In an exemplary embodiment of this application, if a hard disk is added, 10 storage blocks are added, with indices 21-30. The three channel indices can then be pre-allocated as shown in Table 11 below:
[0175] Table 11
[0176] Channel 1 1 5 8 12 15 18 Channel 2 3 4 7 11 14 17 20 Channel 3 9 2 6 10 13 16 19
[0177] The allocation is complete, as shown in Table 12 below:
[0178] Table 12
[0179] Channel 1 1 5 8 12 15 18 21 24 27 30 Channel 2 3 4 7 11 14 17 20 23 26 29 Channel 3 9 2 6 10 13 16 19 22 25 28
[0180] In the exemplary embodiments of this application, the storage blocks are pre-allocated in advance through the scheme of the embodiments of this application, which realizes seamless writing of data stored in the storage blocks, improves system performance, and avoids the risk of data loss caused by the block selection method in advance.
[0181] This application also provides a block storage-based slicing device 1, such as... Figure 3 As shown, it may include a processor 11 and a computer-readable storage medium 12, wherein the computer-readable storage medium 12 stores instructions that, when executed by the processor 11, implement the block-based storage-based slicing method described above.
[0182] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
Claims
1. A block-based storage-based segmentation method, characterized in that, The method includes: Retrieve multiple storage blocks to be allocated; The multiple storage blocks are numbered according to a preset order, and an allocation index is established for the multiple storage blocks according to the numbering. The multiple storage blocks are pre-allocated to multiple channels according to the channel parameters of the audio and video storage channels and the allocation index, and the storage blocks allocated to the channels are adjusted according to the changes in the storage channels and / or storage disks. The channel parameters include any one or more of the following: channel bitrate, channel capacity, number of channels, and channel retention period; the changes in the storage channels and / or storage disks include any one or more of the following: channel deletion, channel addition, channel offline, channel re-bringing online, storage disk deletion, and storage disk addition; When the allocated storage block is a new storage block partitioned from an existing storage disk, the step of pre-allocating the multiple storage blocks to multiple channels according to the channel parameters of the audio / video storage channels and the allocation index includes: Detect whether the channel bitrates of the multiple channels are the same; based on the detection results, allocate the multiple storage blocks according to the following allocation strategy: When the channel code rates of the multiple channels are the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a manner that one storage block is allocated to each channel at a time, until all storage blocks are allocated. When the channel bitrates of the multiple channels are not the same, according to the encoding order of the multiple storage blocks, the storage blocks are allocated to the multiple channels sequentially from the red-black tree RBTree in a way that matches the number of storage blocks allocated to each channel each time with the ratio of the channel bitrates of the multiple channels, until all storage blocks are allocated. The adjustment of the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk includes: When at least one of the multiple channels is deleted, according to the allocation strategy, the storage blocks in the deleted channel that have exceeded the channel retention period will be reclaimed and allocated to online channels until the channel retention period of each online channel is the same; and / or, When at least one of the multiple channels goes offline, according to the allocation strategy, the storage blocks in the offline channel that have exceeded the channel retention period are sequentially allocated to the online channels until the channel retention period of each online channel is the same. When both offline channels and deleted channels exist simultaneously, the storage blocks in the offline and deleted channels that have exceeded the channel retention period over time are sequentially reclaimed and stored in the Red-Black Tree (RBTree), and then allocated to online channels according to the allocation strategy.
2. The block-based storage-based slicing method according to claim 1, characterized in that, The step of pre-allocating the plurality of storage blocks to the plurality of channels according to the channel parameters of the audio and video storage channels and the allocation index also includes: After all new storage blocks allocated from the existing storage disks have been allocated, the system begins to reclaim storage blocks in deleted channels, channels with offline durations exceeding a preset duration threshold, and / or channels that have reached their retention period as old blocks, and allocates these old blocks to channels that require pre-allocation of storage blocks; or, it reclaims the earliest allocated storage block in the channel that requires pre-allocation of storage blocks as a copy block, and then reassigns the copy block to the channel.
3. The block-based storage-based slicing method according to claim 1, characterized in that, The step of adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk further includes: When a new storage disk is added and / or the capacity of the existing storage disk increases, new storage blocks are allocated based on the new storage disk and / or the increased capacity of the existing storage disk, and the new storage blocks are allocated to multiple channels according to the allocation strategy until all the new storage blocks are allocated.
4. The block-based storage-based slicing method according to claim 1, characterized in that, The step of adjusting the storage blocks allocated to the channel based on changes in the storage channel and / or storage disk further includes: After all new storage blocks have been allocated from the existing storage disks, when a new channel is added, old blocks or rewritten blocks reclaimed from the original channel will be allocated to the new channel until the channel retention period of each online channel is the same.
5. The block-based storage-based slicing method according to claim 2 or 4, characterized in that, The recycling strategies for the old blocks and the rewritten blocks include one or more of the following: When there are new storage blocks that have not been fully allocated, the old blocks and the rewrite blocks are not reclaimed; Once new storage blocks have been allocated, the old blocks or the rewrite blocks are reclaimed; however, if there are old blocks that can be reclaimed, the rewrite blocks are not reclaimed. When any channel's offline time exceeds a preset time threshold and / or any channel is deleted, the storage blocks within that channel are reclaimed based on its retention period; and, When a new storage disk is added, the old blocks and rewritten blocks in the channel are stopped from being recycled, and the new storage blocks allocated from the new storage disk are formatted and added to the Red-Black Tree (RBTree). And / or, The method also includes storing the recycled old blocks and the overwrite blocks in the nodes of the red-black tree (RBTree).
6. The block-based storage-based slicing method according to claim 1, characterized in that, The method further includes: calculating the channel retention period for each channel based on the channel bitrate, the number of channels, the storage disk capacity, the size of each storage block, and the channel retention period calculation trigger event; the channel retention period refers to the duration for which audio and video are retained within the channel.
7. The block-based storage-based slicing method according to claim 6, characterized in that, The calculation of the channel retention period for each channel based on the channel bitrate, number of channels, storage disk capacity, size of each storage block, and channel retention period calculation trigger event includes: calculating the channel retention period according to a preset channel retention period calculation formula; The formula for calculating the channel retention period includes: Time= ; Wherein, Time is the channel retention period, x is the channel bitrate, d is the storage disk capacity, c is the number of channels, b is the size of each storage block, and e is the calculation trigger event; The calculation trigger events include: Changes to any one or more of the following values: channel bitrate, number of channels, disk capacity, and size of each storage block; and / or, Changes in the storage channel and / or storage disk.
8. A block-based sharding device, comprising a processor and a computer-readable storage medium storing instructions, characterized in that, When the instruction is executed by the processor, the block-based storage-based slicing method as described in any one of claims 1-7 is implemented.