Video data recovery method and device, terminal equipment and storage medium
By acquiring the block structure information in the storage medium, determining and parsing the video information in the data blocks, the problem of low robustness caused by global index area dependency is solved, and efficient video data recovery is achieved when the global index area is damaged.
Patent Information
- Application Number
- CN202511165457.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-11-04
AI Technical Summary
Existing technologies rely on the global index area during video data recovery, resulting in low robustness and an inability to perform data recovery properly when the global index area is damaged or parsing errors occur.
By obtaining the block structure information in the storage medium, multiple data blocks are identified, and each data block is parsed to obtain the video information of the video segment, thus realizing video data recovery and avoiding dependence on the global index area.
It improves the robustness of data recovery, enabling normal data recovery even without obtaining the structure of the global index area, and significantly improves the success rate of video data recovery in the event of partial damage to the storage medium.
Smart Images

Figure CN120897098A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a video data recovery method and device, a terminal device and a storage medium. BACKGROUND
[0002] At present, video data recovery has become an important technical link in scenarios such as digital forensics, and the video data recovery situation is directly related to the reliability of scenarios such as event backtracking and judicial evidence.
[0003] In related technologies, when video data recovery is performed, the global index area needs to be completely parsed, wherein the global index area refers to a centralized metadata structure in a storage medium, which contains the complete index information of all files and directories in the entire volume. If the structure of the global index area cannot be obtained or the global index area parsing is incorrect, the data recovery cannot be normally performed, thereby causing the problem of low robustness. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a video data recovery method, device, terminal device and storage medium to avoid the dependence on the global index area when performing video data recovery and improve the robustness of data recovery.
[0005] To achieve the above purpose, the technical solutions adopted by the embodiments of the present application are as follows: In a first aspect, the present application provides a video data recovery method, which comprises: obtaining block structure information of data blocks in a storage medium, and determining a plurality of data blocks in the storage medium according to the block structure information; respectively for each data block, parsing the data block to obtain video information of a video segment contained in the data block, and obtaining the video segment from the data block based on the video information and the block structure information; performing video data recovery according to the video segments corresponding to each data block to obtain a target video.
[0006] In an optional implementation, the obtaining of the block structure information of the data blocks in the storage medium and the determination of the plurality of data blocks in the storage medium according to the block structure information comprises: obtaining the block structure information from an initial sector in the storage medium; the block structure information comprises a data block size and a data area start address of a data block storage area; determining a plurality of data blocks according to the data block size and the data area start address; The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: A plurality of parallel block processing threads are generated, and a one-to-one correspondence between the block processing threads and the data blocks is determined according to the block structure information; The data blocks are parsed respectively by the block processing threads corresponding to the data blocks, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information.
[0007] In an optional implementation, the video information includes frame index information corresponding to the video segments; the data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: For each video segment, frame addresses of the video frames corresponding to the video segment are calculated according to the frame index information of the video segment and the block structure information, and the video frames corresponding to the video segment are obtained according to the frame addresses, and the video segment is generated based on the video frames.
[0008] In an optional implementation, the offset address includes a file offset address and a frame index offset address; The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including: The data blocks are parsed respectively, video information of the video segments contained in the data blocks is obtained, and the video segments are obtained from the data blocks based on the video information and the block structure information, including:
[0009] In an optional implementation, the attribute information comprises a segment timestamp of the video segment, and the frame index information comprises a frame timestamp of the video frame. The determining of the frame index information of each video segment according to the attribute information of each video segment and the frame index information of each video frame comprises: For each video segment, a target video frame corresponding to the video segment is determined according to the segment timestamp of the video segment and the frame timestamp of each video frame, and the frame index information of the target video frame is determined as the frame index information of the video segment.
[0010] In an optional implementation, the frame index information comprises a video frame data size and a starting cluster number of the video frame, and the block structure information further comprises a cluster size. The calculating of the frame address of each video frame corresponding to the video segment according to the frame index information of the video segment and the block structure information, and the obtaining of each video frame corresponding to the video segment according to the frame address, and the generating of the video segment based on the video frame, for each video segment, comprises: For each video segment, a frame starting address corresponding to a first frame video frame of the video segment is calculated according to the starting cluster number of the first frame video frame, the cluster size and a block starting address of a data block to which the video segment belongs. A physical address of each video frame is determined according to the frame starting address of the first frame video frame, the video frame data size of each video frame corresponding to the video segment and the cluster size. Each video frame is obtained according to the physical address of each video frame, and the video segment is generated based on the video frame.
[0011] In an optional implementation, before the parsing of each data block to obtain the video information of the video segment contained in the data block, the method further comprises: For each data block, a verification parameter is obtained according to a preset verification offset address, and the data block is verified according to the verification parameter to determine whether the data block is a valid data block. The parsing of the data block to obtain the video information of the video segment contained in the data block comprises: In the case that the data block is a valid data block, the data block is parsed to obtain the video information of the video segment contained in the data block.
[0012] In a second aspect, the present application provides a video data recovery device, the device comprising: obtain the block structure information of the data blocks in the storage medium, and determine a plurality of data blocks in the storage medium according to the block structure information; The parsing module is configured to parse each data block respectively, to obtain video information of a video segment contained in the data block, and to obtain the video segment from the data block based on the video information and the block structure information. The data recovery module is configured to perform video data recovery according to the video segment corresponding to each data block, to obtain a target video.
[0013] In a third aspect, the present application provides a terminal device, comprising a processor and a memory, the memory stores a computer program capable of being executed by the processor, and the processor can execute the computer program to implement the method in any of the preceding embodiments.
[0014] In a fourth aspect, the present application provides a storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method in any of the preceding embodiments.
[0015] The video data recovery method, device, terminal device and storage medium provided by the embodiments of the present application first obtain the block structure information in the storage medium, determine a plurality of data blocks according to the block structure information, parse each data block, and obtain the video information inside the data block, obtain the video segment in the data block based on the video information and the block structure information, and finally perform video data recovery according to the video segment corresponding to each data block, thereby obtaining a target video. In this way, the metadata information embedded in each independent data block can be accessed and parsed directly without relying on the understanding of the global index area, thereby obtaining the video segment in the data block for data recovery. In this case, even if the structure of the global index area cannot be obtained, data recovery can be performed normally, thereby improving the robustness of data recovery.
[0016] In order to make the above objectives, characteristics and advantages of the present application more apparent and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are referred to, and the detailed description is as follows. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0018] Figure 1 A flowchart of video file recovery in the related art is shown. Figure 2 A block diagram of a terminal device provided by an embodiment of the present application is shown; Figure 3 A flow diagram of a video data recovery method provided by an embodiment of the present application is shown; Figure 4 A data block size example diagram is shown; Figure 5 A meta information field diagram is shown; Figure 6 An attribute information example diagram is shown; Figure 7 A frame index information example diagram is shown; Figure 8 A video file example diagram is shown; Figure 9 A functional module diagram of a video data recovery apparatus provided by an embodiment of the present application is shown.
[0019] Icon: 100 - memory; 110 - processor; 120 - communication module; 200 - acquisition module; 210 - parsing module; 220 - data recovery module. DETAILED DESCRIPTION
[0020] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations.
[0021] Therefore, the detailed description of the embodiments of the present application provided in the accompanying drawings below is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of the present application.
[0022] It should be noted that the relational terms herein, such as first and second and the like, are used solely to distinguish one from another entity or action, without necessarily requiring or implying any actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0023] In application scenarios such as digital forensics, data recovery, security monitoring, etc., video data recovery has extremely important practical significance. For example, when investigating related events, law enforcement agencies often need to extract relevant video materials from monitoring devices as key evidence.
[0024] In related technologies, when video data recovery is performed, a similar serial parsing model based on a central index needs to be followed.
[0025] Figure 1 For a flowchart of video file recovery in related technologies, please refer to Figure 1 During the execution of this step, the core metadata of the file system needs to be obtained from the storage medium first, and this operation depends on the accurate positioning and parsing of the global index area.
[0026] In related technologies, the parsing of the global index area is usually completed by the data recovery software through accessing the specific physical location of the storage medium. For example, in the NTFS file system, the Master File Table (MFT) as the global index area records the metadata information of all files and directories in the entire volume, including file name, size, timestamp, and data storage physical location, etc.; while in the FAT32 file system, the File Allocation Table (FAT) is used to record the allocation and linkage relationship of file data blocks. By parsing these structured metadata areas, the software constructs a file index list or tree structure that can be used for subsequent operations.
[0027] Based on the above index information, the software further performs a positioning operation of file data, that is, according to a recovery target specified by a user, a corresponding file entry is searched in the constructed index structure, and an address list of data blocks or clusters occupied by the file is extracted therefrom, and then a serial reading and recombination stage is entered, each data block or cluster is accessed in sequence, and the read data is spliced in a logical order to reconstruct the complete file content.
[0028] As can be seen, in the video data recovery process, complete parsing of the global index area is the basis of the entire process, which strongly depends on prior knowledge of the structure and location of the global index area. If the structure of the global index area cannot be obtained, the subsequent data recovery cannot be carried out. In addition, even if the structure of the global index area is known, since the parsing of the global index area is the "meridian" of the entire file system, once the area is damaged due to physical bad tracks, firmware errors or accidental power failure, etc., the entire recovery process will fail, and there is a serious single point failure risk.
[0029] In summary, there is an urgent need for a new data recovery method that can efficiently and stably extract video data from a storage medium without relying on the global index.
[0030] Based on this, the embodiments of the present application provide a video data recovery method, device, terminal equipment and storage medium to solve the above problems.
[0031] Figure 2 For the block diagram of the terminal equipment provided by the embodiments of the present application, please refer to Figure 2 The terminal equipment includes a memory 100, a processor 110 and a communication module 120. The memory 100, the processor 110 and the communication module 120 are directly or indirectly electrically connected to each other to realize the transmission or interaction of data. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines.
[0032] Among them, the memory 100 is used to store computer programs or data that can be executed by the processor. The memory 100 can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) and the like.
[0033] The processor 110 is configured to read / write data or computer programs stored in the memory, and execute the computer programs to implement the video data recovery method provided by the embodiments of the present application.
[0034] The communication module 120 is configured to establish a communication connection between the terminal device and other communication terminals through a network, and configured to receive / transmit data through the network.
[0035] It should be understood that, Figure 2 The structure shown is only a structural schematic diagram of the terminal device, and the terminal device can further include more or less components than those shown in Figure 2 or have a different configuration from that shown in Figure 1 . Figure 2 The components shown in may be implemented in hardware, software, or a combination thereof.
[0036] Next, the terminal device in Figure 2 is taken as the execution subject, and the video data recovery method provided by the embodiments of the present application is exemplarily introduced in combination with the flowchart. Specifically, Figure 3 for the video data recovery method provided by the embodiments of the present application, please refer to Figure 3 , which comprises the following steps. Step S20, obtaining block structure information of data blocks in the storage medium, and determining a plurality of data blocks in the storage medium according to the block structure information.
[0037] Optionally, the block structure information refers to key parameters for describing the arrangement mode of data blocks in the entire storage structure, so that the terminal device can determine a plurality of data blocks according to the block structure information, and process each data block respectively.
[0038] Step S21, respectively for each data block, parsing the data block to obtain video information of a video segment contained in the data block, and obtaining the video segment from the data block based on the video information and the block structure information.
[0039] Optionally, the terminal device can directly access and parse the metadata information embedded in each independent data block to obtain the video information of the video segment.
[0040] Optionally, the video information refers to a set of metadata for describing the video segment and the constituent video frames thereof, which is extracted in the process of parsing each data block in the storage medium. These metadata are not only used to represent the attributes of the video content, but also serve as a key basis for subsequent video data recombination and recovery operations.
[0041] In this embodiment, multiple video clips can be included in each data block, and the terminal device can obtain video information of the multiple video clips, and further parse the data block based on the video information to obtain specific video clips.
[0042] In step S22, video data is recovered according to the video clips corresponding to the data blocks to obtain a target video.
[0043] In this embodiment, the terminal device can sequentially splice or organize the video clips distributed in the multiple data blocks according to a time sequence or other logical relationship, thereby generating a target video for playing or further processing.
[0044] The video data recovery method provided in the embodiments of this application first obtains block structure information in a storage medium, determines multiple data blocks according to the block structure information, parses each data block to obtain video information inside the data block, obtains a video clip in the data block based on the video information and the block structure information, and finally recovers video data according to the video clips corresponding to the data blocks to obtain a target video. In this way, the metadata information embedded in each independent data block can be directly accessed and parsed without relying on the understanding of the global index area, thereby obtaining the video clip in the data block for data recovery. In this case, even if the structure of the global index area cannot be obtained, data recovery can still be normally performed, thereby improving the robustness of data recovery.
[0045] In addition, even if a certain area in the storage medium, for example, any data block, is physically damaged or logically incorrect, other independent and healthy data blocks can still be successfully parsed and recovered. This "divide and conquer" strategy significantly improves the success rate of video data rescue in the case of partial damage of the storage medium, thereby further improving the robustness of data recovery.
[0046] In a possible implementation manner, the block structure information can be obtained by parsing an initial sector of the storage medium.
[0047] Specifically, the terminal device can obtain the block structure information including the data block size and the data area start address of the data block storage area from the initial sector in the storage medium, and then determine the multiple data blocks according to the data block size and the data area start address.
[0048] Optionally, the initial sector refers to a physical start sector in the storage medium (such as a hard disk or an image file) for storing core boot information and file system basic parameters, which is usually referred to as an LBA0 sector in a logical block address (LBA) system.
[0049] In the embodiment, the terminal device can extract the block structure information for describing the data block distribution and organization mode by accessing the initial physical sector (LBA0) of the storage medium and reading the binary data at a specific offset position. These parameters constitute the basic structure information for subsequent data block division and parallel analysis operation, including but not limited to the size of a single data block (S_DataBlock) and the logical start address of the data block storage area (LBA_DataAreaStart).
[0050] In addition, the block structure information can also include the size of the cluster in the file system (S_Cluster).
[0051] Specifically, during the execution of the above steps, the terminal device can read a binary value of a specific length (for example, 8 bytes) by positioning to the preset offset address (for example, OFS_DataBlockSize, 0x78) in the initial sector, so as to obtain the fixed data block size of a single data block. In an example, Figure 4 For an example diagram of the data block size, please refer to Figure 4 The data block size can be represented as 0x10000000 bytes, that is, 256 MB, which is used to define the physical boundary of each data block in the storage medium.
[0052] At the same time, the terminal device can determine the data area start address (LBA_DataAreaStart) as 0 to indicate the starting point of the distribution of the data block in the storage medium. In addition, the terminal device can also identify and record the fixed size of the cluster (S_Cluster, such as 4096 bytes).
[0053] It should be noted that the video data recovery method provided in the embodiments of the present application can be applied to storage media with the same storage structure, that is, storage media with fixed data block size, file system without partition structure, and cluster size as a fixed value.
[0054] It can be understood that on this basis, the terminal device can determine a plurality of data blocks based on the data block size and the data area start address. Alternatively, in order to further improve the robustness of data recovery and prevent the block structure information from being obtained after the initial sector is damaged, the user can also configure default block structure information in the terminal device in advance based on the structural characteristics of the file system in the storage medium. When the initial sector is damaged, the terminal device can directly obtain the default block structure information for processing.
[0055] In addition, considering that in the data recovery process of the prior art, whether it is to completely analyze the global index area with a large amount of data or to serially read and reorganize the data, it is a very time-consuming operation. In the face of TB-level monitoring data and other large-scale storage scenarios, this serial processing mode will result in extremely high time consumption and resource occupation.
[0056] Obviously, the serialization feature inherent in the traditional method makes it difficult to effectively utilize the parallel computing capability provided by modern multi-core processors and high-speed storage devices when facing massive data, private formats or partially damaged storage media, resulting in low overall processing efficiency and great pressure on system resources.
[0057] To solve this problem, the video data recovery method provided by the embodiments of the present application can be processed through a parallel processing mechanism.
[0058] Specifically, the terminal device can generate a plurality of parallel block processing threads, determine a one-to-one correspondence between the block processing threads and the data blocks according to the block structure information, parse the data blocks through the block processing threads corresponding to the data blocks respectively, obtain the video information of the video segments contained in the data blocks, and obtain the video segments from the data blocks based on the video information and the block structure information.
[0059] Optionally, the terminal device can generate a plurality of block processing threads and allocate corresponding data blocks to each block processing thread.
[0060] During the execution of the above steps, the terminal device can first determine the number of concurrent threads N according to the hardware resources (such as the number of CPU cores) of the current processing environment or a preset parallel strategy, and then generate N parsing threads numbered Thread_0 to Thread_(N-1) in sequence.
[0061] Subsequently, the terminal device can calculate the starting physical offset Offset_DataBlock_k of the data block corresponding to the kth thread based on the data block size (S_DataBlock) and the starting address (LBA_DataAreaStart) of the data area of the data block storage area according to the following formula: Offset_DataBlock_k=LBA_DataAreaStart+k*S_DataBlock Wherein, k represents the thread index, and the value range is 0 to N-1.
[0062] In this embodiment, the starting physical offset represents the starting position of the data block responsible for processing by the block processing thread in the storage medium, thereby ensuring that the data blocks processed by each thread are physically non-overlapping, avoiding concurrent access conflicts.
[0063] Further, based on the mapping relationship between the above block processing threads and the data blocks, the terminal device can independently execute data block parsing operations through the block processing threads corresponding to each data block respectively, thereby realizing parallel processing of a plurality of data blocks in the entire storage medium.
[0064] Specifically, each thread Thread_k starts to access the storage medium at the assigned start offset Offset_DataBlock_k with a fixed data block size, and performs a series of parsing operations on the data block at the position, and finally extracts the video information corresponding to the video clip from the data block. In this process, the threads are independent of each other and independently complete the assigned data block parsing task without sharing or synchronizing global state information, thereby effectively reducing the overhead of thread communication and coordination and improving the overall processing efficiency.
[0065] Optionally, considering that there may be a case where the number of generated block processing threads is less than the number of data blocks, at this time some data blocks may not be assigned corresponding block processing threads, the terminal device can further assign some block processing threads to the next data block to be processed for processing after the block processing threads parse the corresponding data blocks, until all data blocks are parsed.
[0066] It can be understood that the video data recovery method provided by the embodiment of the application can construct a static mapping relationship between the block processing threads and the data blocks based on the block structure information, and use a non-overlapping physical offset allocation strategy to achieve efficient concurrent parsing of the data blocks in the storage medium. This mechanism fully utilizes the parallel computing capability of modern multi-core processors and the multi-task access characteristics of storage devices, significantly improving the speed of video data recovery and system resource utilization.
[0067] In actual application, for example, when recovering data from a private file system with unknown global index area, this parallel processing mechanism can achieve fast extraction and recovery of large-scale monitoring data without relying on the global index, thereby effectively overcoming the efficiency bottleneck caused by the traditional serial processing method.
[0068] Optionally, considering that in the traditional recovery process, if the global index area is damaged or contains error information, the terminal device will still attempt to access the data area pointed to by the index, even if the area may be blank, damaged or not contain valid content. However, the terminal device performs parsing, reading, reorganization and other operations on the invalid data area, which not only cannot obtain valid information, but also occupies valuable CPU, memory and disk I / O resources, thereby causing the overall processing efficiency to decrease.
[0069] Further, when facing a large amount of storage medium, due to physical wear, power failure, firmware error and other reasons, the storage medium may be damaged or logically incorrect in some areas. If the system cannot judge the validity of the data block before processing, it will inevitably perform meaningless parsing on a large number of invalid data blocks, further exacerbating resource waste and processing delay.
[0070] Therefore, the terminal device needs to perform validity check on the data block before parsing the data block.
[0071] In this embodiment, the terminal device can obtain the check parameter according to the preset check offset address for each data block, and check the data block according to the check parameter to determine whether the data block is a valid data block.
[0072] It can be understood that the block processing thread can parse the data block to obtain the video information of the video segment contained in the data block when the data block is a valid data block.
[0073] In this embodiment, before performing deep parsing on the data block, the terminal device can quickly determine the validity of the data block by reading the fixed flag information at a specific offset position in the header of the data block. This step is a pre-judgment mechanism of the data block processing flow, and its purpose is to avoid invalid parsing of empty, damaged or non-target format data blocks by the system, thereby saving system resources and improving overall processing efficiency.
[0074] Specifically, during the execution of the above step, each block processing thread (Thread_k) first reads the header data of a predetermined size from the starting physical offset (Offset_DataBlock_k) of the data block allocated to it, and extracts the key check parameter at the preset offset position (such as 0x00) in the data block header to identify whether the data block is a valid data block, i.e. some private file system specific data block start flag (FLAG_DataBlock).
[0075] Optionally, the flag can be a fixed byte sequence.
[0076] In this embodiment, after the block processing thread obtains the flag, it can compare it with the preset flag. If the comparison is successful, it means that the current data block belongs to a valid data block, its structure is complete and contains video data content, and the thread will continue to perform subsequent file entry parsing and video frame index extraction operations. If the comparison fails, it means that the data block is empty, damaged, or at the end of the valid data storage area, and the thread will immediately terminate further processing of the data block and report the invalid state to the main control flow, thereby avoiding investing additional computing resources on invalid data.
[0077] In one possible implementation, the preset flag can be a fixed byte sequence with a length of 8 bytes (uint64 type) and a specific value of 0x40000005050.
[0078] Optionally, if the data block is valid, the block processing thread can further extract and analyze the key meta information inside the data block. Specifically, under the premise that the header flag verification is passed, the block processing thread will further extract the meta information field with specific format and semantic meaning from the multiple preset offset addresses of the data block header as an auxiliary basis for further confirming the validity of the data block.
[0079] In one possible implementation manner, Figure 5 For a schematic diagram of the meta information field, please refer to Figure 5 After confirming that the data block header flag is matched successfully, the block processing thread can continue to read multiple key meta information fields from the header region of the data block, including but not limited to: the signature at offset 0x00-0x07, which is used to identify the format version or file system type of the data block; the channel number (ChannelID) at offset 0x1C-0x1F, which represents the monitoring channel identifier corresponding to the video data recorded by the data block; and the camera watermark information at offset 0x40-0x5F, which is usually used to record auxiliary information such as device model, installation location or timestamp. These meta information fields not only have fixed offset positions and data formats, but also carry key information for judging the content integrity and validity of the data block.
[0080] In addition, in order to further determine whether the next data block needs to be obtained for processing in the case of invalid data block, the block processing thread can further extract and analyze the key meta information inside the data block, thereby obtaining the above-mentioned meta information field, and determining whether the data block is at the end of the valid data storage area according to the above-mentioned meta information field. For example, it is determined whether there is a corresponding signature in the data block. If not, it means that the data block is at the end of the valid data storage area, and there is no need to obtain the next data block for processing; otherwise, if there is, it can be determined that the data block is empty or damaged, and the next data block can be obtained for processing.
[0081] As can be seen, the video data recovery method provided by the embodiments of the present application realizes rapid judgment of the validity of the data block by introducing a header flag verification mechanism based on fixed offset addresses. The judgment basis comes from the inherent format characteristics in the header structure of the data block itself, rather than relying on external index or metadata information, thereby ensuring that valid data blocks can still be efficiently identified in the private file system environment without knowing the global index area. In actual application process, this mechanism effectively avoids the waste of CPU, memory and I / O resources caused by redundant analysis of invalid data blocks, and significantly improves the overall processing efficiency and system stability of video data recovery.
[0082] Next, a possible implementation is provided for how to parse the data block, obtain the video information of the video segment contained in the data block, and obtain the video segment from the data block based on the video information and the block structure information, respectively for each data block.
[0083] Specifically, the video information can include frame index information corresponding to the video segment. The terminal device can parse the data block for video segments and parse the data block for video frames according to the preset offset address, respectively for each data block, to obtain the frame index information of the multiple video frames corresponding to the video segment in the data block. Then, for each video segment, the frame address of each video frame corresponding to the video segment is calculated according to the frame index information of the video segment and the block structure information, and each video frame corresponding to the video segment is obtained according to the frame address, and the video segment is generated based on the video frames.
[0084] Optionally, the frame index information refers to a structured data set for describing the storage location, size and timestamp information of the video frame inside the data block, which can provide key positioning basis for video segment recombination and data extraction.
[0085] In this embodiment, each block processing thread can parse the data block for video segments and parse the data block for video frames according to the starting physical offset Offset_DataBlock_k of the data block and the preset offset address.
[0086] It can be understood that a video segment is composed of multiple video frames, and each video frame corresponds to a frame index information. Therefore, one video segment can correspond to multiple frame index information, pointing to multiple video frames. The block processing thread can calculate the frame address of each video frame according to the frame index information and the block structure information, so as to obtain each specific video frame in the data block, and generate a complete video segment by splicing the video frames.
[0087] In a possible implementation, since the block processing thread needs to parse the data block for video segments and parse the data block for video frames, the offset address can include a file offset address and a frame index offset address.
[0088] In this embodiment, the terminal device can first parse the data block for video segments according to the file offset address to obtain the file entries in the data block, wherein each file entry corresponds to a video segment. Then, the parameters of each file entry can be parsed to obtain the attribute information of the video segment corresponding to each file entry, the data block is parsed for video frames according to the frame index offset address to obtain the frame index information of the multiple video frames, and the frame index information of each video segment is determined according to the attribute information of each video segment and the frame index information of each video frame.
[0089] In the embodiment, the block processing thread can extract the structured file entries from the data block based on the preset file offset address, and obtain the metadata information related to the video segment by parsing the entries, so as to provide key parameters for subsequent association of video frame index information and video data reorganization.
[0090] In a possible implementation, the file offset address OFS_FileEntries can be 0x800.
[0091] Specifically, during the execution of the above steps, the thread Thread_k can first locate to the fixed offset OFS_FileEntries (0x800) of the starting address Offset_DataBlock_k of the current data block, and the offset position points to the video data entry area in the data block. The area is composed of a plurality of file entries (FileEntry_j) with a fixed length of 24 bytes, and each file entry corresponds to an independent video segment. The block processing thread can read and parse the key fields in each file entry in turn, so as to obtain the attribute information of the video segment corresponding to the file entry.
[0092] In a possible implementation, the attribute information can include the segment timestamp (start timestamp and end timestamp) of the video segment and the number of data clusters contained in the video segment. For example, Figure 6 For an example diagram of the attribute information, please refer to Figure 6 The attribute information can include the video segment start timestamp (Timestamp_Start_j) at offset 0x00-0x03, the video segment end timestamp (Timestamp_End_j) at offset 0x04-0x07, and the number of data clusters (Num_Clusters_j) contained in the segment recorded at offset 0x10-0x13.
[0093] Optionally, after obtaining the file entry, the block processing thread can determine whether the file entry is valid according to the parsed segment timestamp and the preset time range, if the file entry is valid, the block processing thread can parse the file entry, and continue to obtain the next file entry according to the length of the file entry after parsing the file entry, until an invalid file entry is obtained. It can be understood that if the file entry is invalid, the file entry can be determined as the last file entry of the valid file entry, that is, the file entries after the file entry are all invalid file entries, and there is no need to obtain and parse the next file entry.
[0094] In the embodiment, after the block processing thread completes the file entry parsing of the data block, the block processing thread can further read the structured video frame index record from the data block based on the preset offset address, associate the video frame with the corresponding video segment, and construct the complete video data logical structure.
[0095] Specifically, during the execution of the above steps, after completing the parsing of the file entry area, the block processing thread Thread_k can continue to access the video frame data index table area in the data block according to the frame index offset address.
[0096] In a possible implementation manner, the frame index offset address OFS_FrameIndexTable can be 0x2000.
[0097] In the embodiment, the block processing thread can obtain the video frame data index table at the fixed offset OFS_FrameIndexTable (0x2000) relative to the starting address Offset_DataBlock_k of the data block. The index table is composed of a plurality of frame index information (FrameIndexEntry_m) with a fixed length of 32 bytes.
[0098] Optionally, each frame index information corresponds to a video frame, and includes the frame timestamp corresponding to the video frame, the video frame data size, and the starting cluster number.
[0099] For example, Figure 7 For an example diagram of the frame index information, refer to Figure 7 Each video frame can include the following key information: the frame timestamp (Timestamp_Frame_m located at offset 0x00-0x03) of the video frame, the video frame data size (Size_Frame_m_InClusters represented in clusters located at offset 0x10-0x11), and the starting cluster number (ClusterID_FrameStart_m located at offset 0x12-0x13) of the video frame in the data block.
[0100] In the embodiment, the block processing thread can establish the corresponding relationship between the video segments and the video frames based on the attribute information corresponding to each video segment and the frame index information of each video frame, so as to determine the frame index information corresponding to the video segment.
[0101] It can be understood that the video data recovery method provided in the embodiment can make the terminal device complete the efficient identification and parsing of the video segment without relying on the global index of the traditional file system, by structurally parsing the file entry area and the frame index information in the data block, thereby significantly improving the efficiency and applicability of data recovery.
[0102] Next, a possible implementation is provided for how to determine the frame index information of each video segment according to the attribute information of each video segment and the frame index information of each video frame. In this embodiment, since the attribute information of the video segment includes the segment timestamp of the video segment, and the frame index information includes the frame timestamp of the video frame, the block processing thread can establish the correspondence between the video segment and the video frame based on the timestamp information. Specifically, the terminal device can determine, for each video segment, the target video frame corresponding to the video segment according to the segment timestamp of the video segment and the frame timestamp of each video frame, and determine the frame index information of the target video frame as the frame index information of the video segment.
[0103] In this embodiment, after the structured analysis of the attribute information corresponding to the video segment and the frame index information corresponding to the video frame is completed, the block processing thread can establish the logical mapping relationship between the video segment and the specific video frame through the timestamp matching mechanism, thereby providing a key basis for the accurate reorganization of subsequent video data.
[0104] Specifically, during the execution of the above steps, the block processing thread can first construct a video file index node (VideoFileIndex_j) based on the video segment start timestamp (Timestamp_Start_j) and the end timestamp (Timestamp_End_j) extracted in the file entry (FileEntry_j). In addition to the above timestamp information, the node can also record the channel number (ChannelID) corresponding to the data block, the number of data clusters (Num_Clusters_j), and the relative position of the file entry in the data block, and other auxiliary information.
[0105] Subsequently, when the block processing thread parses the frame index information of the video frame, the segment timestamp of the video segment and the frame timestamp of the video frame can be given for the timestamp matching operation.
[0106] In the embodiment, for each file index node VideoFileIndex_j, the block processing thread can traverse all frame index information FrameIndexEntry_m, and filter out video frames whose frame timestamps (Timestamp_Frame_m) fall within the time range (Timestamp_Start_j≤Timestamp_Frame_m≤Timestamp_End_j) of the video segment. These filtered video frames can be determined as target video frames corresponding to the video segment, and the block processing thread can determine the frame index information of the target video frames as the frame index information corresponding to the video segment, and logically bind the frame index information (including the frame timestamp Timestamp_Frame_m, the video frame data size Size_Frame_m_InClusters, and the starting cluster number ClusterID_FrameStart_m) of the target video frames with the current file index node VideoFileIndex_j as the basic index data required for subsequent data recombination of the video segment.
[0107] In a possible implementation manner, in order to facilitate subsequent generation of a video file by using video frames, each frame index information in the index node VideoFileIndex_j can be arranged in the order of frame timestamps.
[0108] Optionally, the block processing thread can further perform secondary matching confirmation based on the data cluster number in the attribute information of the video segment and the video frame data size of the corresponding video frame, to determine whether the matching is correct, so as to determine whether some video frames are missed or whether there is a video frame matching error.
[0109] It can be understood that the above steps achieve efficient and accurate mapping between the video segment and the video frame by using the timestamp as a key matching parameter, and ensure the consistency of the frame order and the time logic in the video data recombination process.
[0110] Next, a possible implementation manner is provided for how to calculate the frame addresses of each video frame corresponding to a video segment according to the frame index information and the block structure information of the video segment for each video segment, and how to obtain each video frame corresponding to the video segment according to the frame addresses, to generate the video segment based on the video frames.
[0111] In the embodiment, the frame index information further comprises a video frame data size and a start cluster number of the video frame, and the block structure information further comprises a cluster size. The terminal device can calculate a frame start address corresponding to a first video frame of a video segment according to the start cluster number of the first video frame, the cluster size and a block start address of a data block to which the video segment belongs, determine a physical address of each video frame according to the frame start address of the first video frame, the video frame data size of each video frame corresponding to the video segment and the cluster size, acquire each video frame according to the physical address of each video frame, and generate the video segment based on the video frames.
[0112] In the embodiment, the video frame data size (Size_Frame_m_InClusters) and the start cluster number (ClusterID_FrameStart_m) in the frame index information and the cluster size (S_Cluster) in the block structure information jointly constitute an address description system of the video frame on the storage medium, which provides a basic support for the system to accurately locate and recombine the private format video data in the absence of global index area analysis.
[0113] Specifically, the block processing thread can enter a video frame address calculation stage after completing the logical mapping between the video segment and the video frame (i.e., determining all target video frames belonging to the video segment through timestamp matching).
[0114] In this stage, the block processing thread can calculate a physical address of each video frame based on the video frame data size Size_Frame_m_InClusters and the start cluster number ClusterID_FrameStart_m of each video frame corresponding to the video segment, the block start address Offset_DataBlock_k of the data block and the cluster size S_Cluster of the file system.
[0115] During the execution of the above steps, the block processing thread can first calculate a physical start address Addr_FrameStart_m of the first video frame (i.e., the first frame) of the video segment in the data block according to the start cluster number ClusterID_FrameStart_m of the first video frame, the cluster size S_Cluster and the block start address of the data block.
[0116] Alternatively, the calculation formula of the physical start address can be: Addr_FrameStart_m=Offset_DataBlock_k+ClusterID_FrameStart_m×S_Cluster For example, in a data block, if the start cluster number of the first video frame of a video segment is ClusterID_FrameStart_0 = 10, the cluster size is S_Cluster = 4096 bytes, and the start address of the data block is Offset_DataBlock_k = 0x10000000, then the physical address of the first video frame is: Addr_FrameStart_0 = 0x10000000 + 10 x 4096 = 0x1000A000.
[0117] The formula shows that the physical address of a video frame is determined by the start position of a data block and the offset of the video frame in the data block, and the offset is derived from the start cluster number and the cluster size. Based on this, the block processing thread can sequentially calculate the physical addresses of subsequent video frames. The physical storage size of each video frame is Size_Frame_m_InClusters x S_Cluster, so the addresses of subsequent video frames can be sequentially derived from the start address of the previous frame plus its data size.
[0118] Further, based on the above calculation results, the block processing thread can sequentially read the physical data of each video frame in time order, and splice it into a complete video file stream (Stream_j) according to the frame timestamp of each video frame. It can be understood that the video file stream is the video segment.
[0119] In actual application process, this sequential reading mechanism based on cluster address not only avoids the random access delay caused by fragmentation storage in traditional file system, but also effectively supports efficient parsing of private file system without global index structure.
[0120] After splicing the video frame data, the block processing thread can save the generated video file stream Stream_j as an independent and playable video file, generate a file name based on the channel number (ChannelID) of the data block and the start timestamp (Timestamp_Start_j) of the video segment, and record the complete metadata information of the video file for subsequent archiving or analysis.
[0121] In an example, Figure 8 For a video file example, see Figure 8For example, taking chn003_2024-12-05 15_57_55.h264 as an example, "chn003" represents the channel number ChannelID of the data block, and "2024-12-05 15_57_55" represents the start timestamp Timestamp_Start_j of the video segment, wherein "2024-12-05" represents the recording date, and "15_57_55" represents the start recording time, specifically 15:57:55.
[0122] It can be understood that the terminal device can finally perform video splicing based on the file name of the video file corresponding to each data block, thereby obtaining the target video.
[0123] In order to perform the corresponding steps in the above-mentioned embodiments and various possible manners, the following provides an implementation manner of a video data recovery apparatus. Optionally, the video data recovery apparatus can adopt the device structure of the terminal device shown in Figure 2 Further, please refer to Figure 9 , Figure 9 A functional module diagram of a video data recovery apparatus provided by the embodiments of the present application. It should be noted that the basic principle and technical effects of the video data recovery apparatus provided by the embodiments are the same as those of the above-mentioned embodiments. For brief description, the part not mentioned in the embodiments can be referred to the corresponding content in the above-mentioned embodiments. The video data recovery apparatus includes an acquisition module 200, an analysis module 210, and a data recovery module 220.
[0124] The acquisition module 200 is configured to acquire the block structure information of the data blocks in the storage medium, and determine the plurality of data blocks in the storage medium according to the block structure information.
[0125] It can be understood that the acquisition module 200 can also be configured to perform the above-mentioned step S20.
[0126] The analysis module 210 is configured to analyze each data block respectively, obtain the video information of the video segment contained in the data block, and obtain the video segment from the data block based on the video information and the block structure information.
[0127] It can be understood that the analysis module 210 can also be configured to perform the above-mentioned step S21.
[0128] The data recovery module 220 is configured to perform video data recovery according to the video segment corresponding to each data block, and obtain the target video.
[0129] It can be understood that the data recovery module 220 can also be configured to perform the above-mentioned step S22.
[0130] Optionally, the acquisition module 200 is further configured to acquire block structure information from the initial sector in the storage medium; the block structure information comprises a data block size and a data area start address of a data block storage area; and a plurality of data blocks are determined according to the data block size and the data area start address.
[0131] Optionally, the parsing module 210 is further configured to generate a plurality of parallel block processing threads, and determine a one-to-one correspondence between the block processing threads and the data blocks according to the block structure information; and for each data block, the data block is parsed by the block processing thread corresponding to the data block to obtain video information of a video segment contained in the data block, and the video segment is obtained from the data block based on the video information and the block structure information.
[0132] Optionally, the parsing module 210 is further configured to, for each data block, perform video segment parsing and video frame parsing on the data block according to a preset offset address to obtain frame index information of a plurality of video frames corresponding to a video segment in the data block; for each video segment, calculate frame addresses of the video frames corresponding to the video segment according to the frame index information of the video segment and the block structure information, and obtain the video frames corresponding to the video segment according to the frame addresses, and generate the video segment based on the video frames.
[0133] Optionally, the parsing module 210 is further configured to perform video segment parsing on the data block according to a file offset address to obtain file entries in the data block; each file entry corresponds to a video segment; perform parameter parsing on each file entry to obtain attribute information of the video segment corresponding to each file entry; perform video frame parsing on the data block according to a frame index offset address to obtain frame index information of a plurality of video frames, and determine the frame index information of each video segment according to the attribute information of each video segment and the frame index information of each video frame.
[0134] Optionally, the parsing module 210 is further configured to, for each video segment, determine a target video frame corresponding to the video segment according to a segment timestamp of the video segment and frame timestamps of the video frames, and determine frame index information of the target video frame as the frame index information of the video segment.
[0135] Optionally, the parsing module 210 is further configured to, for each video segment, calculate a frame start address of a first video frame corresponding to the video segment according to a start cluster number of the first video frame, a cluster size, and a block start address of a data block to which the video segment belongs; determine physical addresses of the video frames according to the frame start address of the first video frame, a video frame data size of the video frames corresponding to the video segment, and the cluster size; obtain the video frames according to the physical addresses of the video frames, and generate the video segment based on the video frames.
[0136] Optionally, the parsing module 210 is further configured to acquire the check parameter according to the preset check offset address for each data block respectively, and check the data block according to the check parameter to determine whether the data block is a valid data block; and in the case that the data block is a valid data block, parse the data block to obtain the video information of the video segment contained in the data block. Optionally, the above modules can be stored in the memory in the form of software or firmware (Firmware) or solidified in the operating system (Operating System, OS) of the terminal device, and can be executed by the processor in the terminal device. Figure 2 The processor in the terminal device. Figure 2 The processor in the terminal device.
[0137] The application further provides a storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the video data recovery method provided in the application.
[0138] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are only schematic, for example, the flow chart and block diagram in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flow chart or block diagram can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that, in some alternative implementation manners, the functions noted in the blocks can also occur in different order from that noted in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flow chart, and the combination of blocks in the block diagram and / or flow chart, can be implemented by a dedicated hardware-based system for implementing the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0139] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0140] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts of the prior art that make contributions or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0141] The above is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A video data recovery method, characterized in that, The method includes: Obtain block structure information of data blocks in the storage medium, and determine multiple data blocks in the storage medium based on the block structure information; For each of the data blocks, the data blocks are parsed to obtain video information of the video segments contained in the data blocks, and the video segments are obtained from the data blocks based on the video information and the block structure information; Video data is recovered based on the video segments corresponding to each data block to obtain the target video.
2. The method according to claim 1, characterized in that, The step of obtaining block structure information of data blocks in the storage medium and determining multiple data blocks in the storage medium based on the block structure information includes: The block structure information is obtained from the initial sector in the storage medium; the block structure information includes the data block size and the starting address of the data area of the data block storage region; Multiple data blocks are determined based on the data block size and the starting address of the data area; The step of parsing each data block to obtain video information of the video segments contained in the data block, and obtaining the video segments from the data blocks based on the video information and the block structure information, includes: Multiple parallel block processing threads are generated, and a one-to-one correspondence between the block processing threads and the data blocks is determined based on the block structure information. For each of the data blocks, the block processing thread corresponding to the data block parses the data block to obtain the video information of the video segment contained in the data block, and obtains the video segment from the data block based on the video information and the block structure information.
3. The method according to claim 1, characterized in that, The video information includes frame index information corresponding to the video segment; the step of parsing each data block to obtain video information of the video segments contained in the data block, and obtaining the video segment from the data block based on the video information and the block structure information, includes: For each data block, video segment parsing and video frame parsing are performed on the data block according to a preset offset address to obtain the frame index information of multiple video frames corresponding to the video segment in the data block; For each video segment, the frame address of each video frame corresponding to the video segment is calculated based on the frame index information and the block structure information of the video segment, and the video frame corresponding to the video segment is obtained based on the frame address, and the video segment is generated based on the video frame.
4. The method according to claim 3, characterized in that, The offset address includes the file offset address and the frame index offset address; The step of parsing video segments and video frames in the data block according to a preset offset address to obtain frame index information of multiple video frames corresponding to the video segments in the data block includes: The data block is parsed according to the file offset address to obtain the file entries in the data block; each file entry corresponds to a video segment. Each of the file entries is parsed to obtain the attribute information of the video segment corresponding to each file entry; The data block is parsed according to the frame index offset address to obtain the frame index information of multiple video frames. The frame index information of each video segment is determined according to the attribute information of each video segment and the frame index information of each video frame.
5. The method according to claim 4, characterized in that, The attribute information includes the segment timestamp of the video segment, and the frame index information includes the frame timestamp of the video frame; Determining the frame index information of each video segment based on the attribute information of each video segment and the frame index information of each video frame includes: For each video segment, the target video frame corresponding to the video segment is determined based on the segment timestamp of the video segment and the frame timestamp of each video frame, and the frame index information of the target video frame is determined as the frame index information of the video segment.
6. The method according to claim 3, characterized in that, The frame index information includes the video frame data size and the starting cluster number of the video frame, and the block structure information also includes the cluster size; For each video segment, the step of calculating the frame address of each video frame corresponding to the video segment based on the frame index information and the block structure information of the video segment, obtaining each video frame corresponding to the video segment based on the frame address, and generating the video segment based on the video frame includes: For each video segment, the frame start address corresponding to the first video frame is calculated based on the starting cluster number of the first video frame corresponding to the video segment, the cluster size, and the block start address of the data block to which the video segment belongs. The physical address of each video frame is determined based on the frame start address of the first video frame, the video frame data size of each video frame corresponding to the video segment, and the cluster size. Each video frame is obtained according to its physical address, and the video segment is generated based on the video frame.
7. The method according to claim 1, characterized in that, Before parsing each data block to obtain the video information of the video segments contained in the data block, the method further includes: For each of the data blocks, a verification parameter is obtained according to a preset verification offset address, and the data block is verified according to the verification parameter to determine whether the data block is a valid data block. The step of parsing the data block to obtain video information of the video segments contained in the data block includes: If the data block is a valid data block, the data block is parsed to obtain the video information of the video segments contained in the data block.
8. A video data recovery device, characterized in that, The device includes: An acquisition module is used to acquire block structure information of data blocks in a storage medium, and to determine multiple data blocks in the storage medium based on the block structure information; The parsing module is used to parse each of the data blocks separately to obtain video information of the video segments contained in the data blocks, and to obtain the video segments from the data blocks based on the video information and the block structure information; The data recovery module is used to recover video data based on the video segments corresponding to each data block to obtain the target video.
9. A terminal device, characterized in that, It includes a processor and a memory, the memory storing a computer program executable by the processor, the processor being able to execute the computer program to implement the method of any one of claims 1-7.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-7.