Method for copying monitoring video in avi format

By analyzing the cluster byte length and index matching blocks of AVI format, and using the map storage method to recover AVI video files, the problem of recovering AVI video data from damaged disks was solved, achieving higher recovery accuracy and data integrity.

CN115145765BActive Publication Date: 2026-02-24XLY SALVATIONDATA TECHNOLOGY INC
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210782336.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-27
Publication Date
2026-02-24
Estimated Expiration
2042-06-27

AI Technical Summary

Technical Problem

Existing technologies cannot effectively recover complete video data from damaged AVI format surveillance video disks, resulting in data corruption or inability to play the video.

Method used

By analyzing the data composition of AVI format, the byte length of each cluster is obtained. Clusters are classified and matched with AVI index blocks. The AVI video file is then restored using a map storage method.

Benefits of technology

It improves the accuracy of AVI video file recovery, reduces data overlap, and ensures the integrity of the recovered video data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115145765B_ABST
    Figure CN115145765B_ABST
Patent Text Reader

Abstract

The application discloses a carving method of avi format monitoring video, and is characterized by comprising the following steps: S100, acquiring the byte length of a cluster, comprising the following steps: S101, traversing N clusters starting from an avi header and recording the starting addresses of the clusters; S102, calculating and recording the difference between the starting addresses of two adjacent clusters in each cluster; S103, acquiring the minimum value of the N-1 starting address differences in step S102 as the byte length of the cluster; S200, acquiring the address of the first cluster, comprising the following steps: S201, acquiring the address of the first cluster starting from the avi header; S202, taking the address of the first cluster starting from the avi header as a starting address and taking the byte length of the cluster as an offset, addressing the clusters forward until the address of the first cluster is reached; S300, acquiring an avi index, acquiring an avi header through the avi index, matching corresponding blocks according to the avi index and carving the avi format monitoring video.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data recovery and relates to a method for recovering surveillance videos in AVI format. Background Technology

[0002] AVI is a commonly used video format. More specifically, it is a Resource Interchange File Format (RIFF) standard, which stores data according to marked blocks and is widely used in video transmission, especially in surveillance equipment.

[0003] If a surveillance disk storing AVI files is damaged, current technologies can directly extract the file by examining the header and its length (what we commonly call file signature extraction) or by extracting fragmented data segments from the AVI file's blocks. The data extracted using either of these methods will be garbled, a jumble of multiple video clips, or unplayable AVI video data. Summary of the Invention

[0004] To address the technical problems of existing technologies, this invention provides a method for replicating AVI format surveillance videos: by analyzing the AVI format and data composition, the byte length of each cluster is first obtained, then each cluster is classified, and the AVI video file is replicated based on the AVI data format.

[0005] This invention includes the following steps:

[0006] S100: Obtain the byte length of the cluster, including the following steps:

[0007] S101: Traverse N clusters starting with the AVI header and record the starting address of each cluster, where N is a natural number not less than 1;

[0008] S102: Calculate and record the difference in starting addresses between two adjacent clusters in each cluster;

[0009] S103: Obtain the minimum value of the difference between the N-1 starting addresses in step S102, and use it as the byte length of the cluster;

[0010] S200: Obtain the address of the first cluster, including the following steps:

[0011] S201: Get the address of the first cluster that starts with an AVI header;

[0012] S202: Starting from the address of the first cluster that begins with an AVI header, and using the byte length of the cluster as the offset, address each cluster backward until the address of the first cluster is reached;

[0013] S300: Obtain the AVI index, retrieve the AVI header using the AVI index, match the corresponding blocks according to the AVI index, and copy the surveillance video in AVI format, including the following steps:

[0014] S3000: Address of the first cluster;

[0015] S3001: Determine whether the sculpting of all clusters has been completed. If yes, proceed to step S3011; otherwise, proceed to step S3002.

[0016] S3002: Read the contents of the current cluster based on the cluster's byte length;

[0017] S3003: Determine whether the current cluster has an AVI header. If yes, proceed to step S3006; otherwise, proceed to step S3004.

[0018] S3004: Determine whether the current cluster has an AVI index. If yes, proceed to step S3008; otherwise, proceed to step S3005.

[0019] S3005: Determine whether the current cluster has an AVI block. If yes, proceed to step S3007; otherwise, proceed to step S3002.

[0020] S3006: Uses map storage method to store the AVI header as a header map;

[0021] Using the offset address of the current cluster on the disk as the keyword and the AVI header information as the key value, the current keyword and the current key value are added to the header map storage, and step S3012 is executed. The AVI header information includes the byte length of the corresponding AVI file and the address of the corresponding movi block in the AVI file.

[0022] S3007: Uses map storage method to store AVI chunks as chunk map storage;

[0023] Using the offset address of the current cluster on the disk as the key and the AVI block information as the critical value, the current key and the current critical value are added to the block map storage, and step S3012 is executed. The AVI block information includes the starting address of the first block and the length of the missing bytes of the last block in the current cluster.

[0024] S3008: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, proceed to step S3009; otherwise, proceed to step S3010.

[0025] S3009: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S3012.

[0026] S3010: Uses map storage method to store AVI indexes as index map storage;

[0027] Using the offset address of the cluster where the AVI index is located as the key and the relevant information as the key value, the current key and the current key value are stored in the index map storage, and step S3012 is executed. The relevant information includes the starting address of the first block data.

[0028] S3011: Check if there are any un-carved surveillance videos in the AVI header map storage, AVI data map storage, and AVI index map storage. If so, proceed to step S3013; otherwise, end the process.

[0029] S3012: Address the next cluster, execute step S3001;

[0030] S3013: Remaining surveillance videos stored in the AVI index map, AVI header map, and AVI data map.

[0031] Preferably, the disk storage format for AVI format surveillance videos is FAT32 or exFAT.

[0032] Preferably, determining whether the current cluster has an AVI header in step S3003 includes the following steps:

[0033] If the content of the current cluster conforms to the RIFF file structure and also meets the following data structure, then the current cluster is determined to have an AVI header:

[0034] A: The content of the 4 bytes starting at address 0x0000 is the string "RIFF";

[0035] B: A byte with a length of 4 bytes, starting at address 0x0004, contains a value of 0x0008 or higher;

[0036] C: A string "AVI" or "AVIX" of type avi, starting at address 0x0008 and with a length of 4 bytes.

[0037] Preferably, in step S3004, determining whether the current cluster has an AVI index includes the following steps:

[0038] If the content of the current cluster conforms to the following data structure, then the current cluster is determined to have an AVI index:

[0039] A: Is the chunk name one of the following values:

[0040] 02tx, 00db, 00dc, 01wb, 02wb, 01wc, 02wc, JUNK;

[0041] B: Is the block identifier 0x10 or 0x00?

[0042] C: Whether the byte length of the block is less than 0x1000000.

[0043] Preferably, in step S3008, determining whether the header map storage contains a header includes the following steps:

[0044] In the data contained in the cluster starting with the AVI header, it is determined whether the name, identifier, offset address and byte length in the block correspond one-to-one with the data in the index. If they do, it means that the AVI header matches the AVI index, and the header map storage contains the header corresponding to the AVI index.

[0045] Preferably, step 3009 includes the following steps:

[0046] S30091: Use the current AVI header as the header of the AVI format surveillance video after engraving and write it into the AVI format surveillance video after engraving. Obtain the byte length of the surveillance video to be engraved from the current AVI header and subtract the byte length of the cluster containing the AVI header and the AVI index, and record the difference.

[0047] S30092: Determine if the difference is zero. If it is, it means that the clusters of the surveillance videos to be restored have been restored. Proceed to step S30094. Otherwise, proceed to step S30093.

[0048] S30093: Determine whether the cluster of AVI blocks that corresponds one-to-one with the cluster of the surveillance video to be engraved is found in the data map storage. If so, obtain the updated byte length of the surveillance video to be engraved and execute step S30092. Otherwise, execute step S30094.

[0049] S30094: Write the AVI index to the end of the copied AVI format surveillance video to complete the copying of the current surveillance video cluster. Then execute step S3012.

[0050] Preferably, step 30093 includes the following steps:

[0051] S300930: Determine whether the data map has been completely traversed. If yes, execute S30094; otherwise, execute S300931.

[0052] S300931: Is the length of the missing bytes of the last block data in the current cluster equal to the offset of the first block of the currently traversed cluster in the data map storage? If yes, proceed to step S300932; otherwise, proceed to step S300930.

[0053] S300932: Does the data of each block of the currently traversed cluster in the data map storage correspond one-to-one with the data in the avi index map storage? If yes, proceed to step S300933; otherwise, proceed to step S300930.

[0054] S300933: The currently traversed cluster in the data map storage is written into the AVI format surveillance video after engraving. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. The difference between the byte length of the surveillance video to be engraved and the byte length of the current cluster is calculated, and step S30092 is executed.

[0055] Preferably, step 3013 includes the following steps:

[0056] S30131: Restore the remaining surveillance videos in the AVI index map storage, including the following steps:

[0057] S301311: Determine whether the loop traversal of the index map storage has ended. If yes, execute step S301315; otherwise, execute step S301312.

[0058] S301312: Retrieve the current cluster from the index map;

[0059] S301313: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, execute step S301314; otherwise, execute step S301311.

[0060] S301314: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S301311.

[0061] S301315: Delete the remaining clusters from the index map storage and proceed to step S30132;

[0062] S30132: The remaining surveillance video in the AVI header map storage includes the following steps:

[0063] S301321: Determine whether the loop traversal of the head map storage has ended. If yes, execute step S30133; otherwise, execute step S301322.

[0064] S301322: Retrieve the current cluster from the header map;

[0065] S301323: Retrieve the remaining surveillance videos from the data map storage, including the following steps:

[0066] S3013231: Use the current AVI header as the header of the copied AVI format surveillance video and write it into the copied AVI format surveillance video;

[0067] S3013232: Determine whether the data map storage for loop traversal has ended. If yes, execute step S301324; otherwise, execute step S3013233.

[0068] S3013233: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, proceed to step SS3013234; otherwise, proceed to step S3013232.

[0069] S3013234: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013232 is executed.

[0070] S301324: Generate the surveillance video to be reproduced, and execute step S301321;

[0071] S30133: Remaining surveillance videos in the AVI data map storage, including the following steps:

[0072] 301331: Determine if the loop traversal of the data map storage has ended. If yes, end the process; otherwise, execute step S301332.

[0073] S301332: Retrieve the current cluster from the data map;

[0074] S301333: Retrieve the remaining surveillance videos from the data map storage, including the following steps:

[0075] S3013331: Write the current cluster to the monitoring video to be etched;

[0076] S3013332: Determine whether the data map storage for the loop traversal has ended. If yes, execute step S3013335; otherwise, execute step S3013333.

[0077] S3013333: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, proceed to step SS3013334; otherwise, proceed to step S3013332.

[0078] S3013334: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013332 is executed.

[0079] S3013335: Generate the surveillance video to be reproduced, and execute step 301331.

[0080] The present invention has the following beneficial effects:

[0081] 1. Data recovery using AVI video storage format is more accurate than recovery using signatures;

[0082] 2. By leveraging the characteristics of AVI files stored in surveillance footage, the byte length of each cluster is recalculated instead of using the default value, resulting in more accurate reproduction of the video data.

[0083] 3. After traversing the disk and classifying the clusters, the data is then copied to reduce data overlap and improve the copying accuracy of AVI video files. Attached Figure Description

[0084] Figure 1 A flowchart of the method provided by this invention;

[0085] Figure 2 This is a flowchart illustrating the specific process of matching the corresponding chunks based on the AVI index and copying the AVI format surveillance video in the method provided by the present invention.

[0086] Figure 3 This is an example diagram of the data structure of the AVI header in one embodiment of the present invention. Detailed Implementation

[0087] This method is applicable when the disk storage format for AVI format surveillance videos is FAT32 or exFAT.

[0088] As is well known, AVI video files consist of three parts:

[0089] 1. File header: Stores parameters related to the playback of AVI video files, hereinafter referred to as the AVI header;

[0090] 2. Index: Contains the index of AVI video files, also known as the idx1 data block, hereinafter referred to as the AVI index;

[0091] 3. Chunk: Audio and video data is composed of small chunks (chucks), hereinafter referred to as AVI chunks.

[0092] Figure 1 A flowchart of the method provided by this invention is shown. Figure 1 As shown, the method of the present invention includes the following steps:

[0093] S100: Get the byte length of the cluster.

[0094] When disk data is corrupted, the parameter storing the cluster's byte length may also be corrupted. Therefore, it is necessary to recalculate the cluster's byte length.

[0095] Due to the inherent storage pattern of AVI video files, which always start with cluster alignment, and the fact that the monitoring machine has multiple channels, if the corresponding AVI video files are created simultaneously, they are written to each cluster sequentially.

[0096] Based on the above pattern, we iterate through and find a certain number (e.g., 20) of AVI header clusters and record their starting addresses. Then, we take the minimum interval value among these cluster positions (for example, each cluster has a starting address, so with 20 clusters, there are 19 starting addresses. In other words, there are 19 interval sizes between adjacent clusters, and we take the minimum of these 9 interval values) as the byte length of the cluster.

[0097] Step S100 includes the following steps:

[0098] S101: Traverse 20 clusters that start with an AVI header and record the starting address of each cluster;

[0099] S102: Calculate and record the difference in starting addresses between two adjacent clusters in each cluster;

[0100] S103: Obtain the minimum value of the difference between the 19 starting addresses in step S102, and use it as the byte length of the cluster;

[0101] S200: Obtain the address of the first cluster, including the following steps:

[0102] S201: Get the address of the first cluster that starts with an AVI header;

[0103] S202: Starting from the address of the first cluster that begins with an AVI header, and using the byte length of the cluster as the offset, address each cluster backward until the address of the first cluster is reached;

[0104] The main idea behind ripping AVI video files is to find the AVI index data, deduce the AVI header data through its parameters, and then match the chunk data one by one according to the AVI index, thus ripping out the AVI video file.

[0105] For a disk containing data from multiple AVI files, how can one extract the file from this data while reducing the error rate? The key lies in the following steps using the S300 technical solution: classifying the data, identifying the most likely matching method, achieving extraction, and improving accuracy.

[0106] S300: Obtain the AVI index, retrieve the AVI header through the AVI index, match the corresponding blocks according to the AVI index, and copy the surveillance video in AVI format.

[0107] Figure 2 The diagram illustrates a detailed flowchart of the method provided by this invention, which involves matching corresponding blocks based on the AVI index and replicating the AVI format surveillance video. For example... Figure 2 As shown, it includes the following steps:

[0108] S3000: Address of the first cluster;

[0109] S3001: Determine whether the sculpting of all clusters has been completed. If yes, proceed to step S3011; otherwise, proceed to step S3002.

[0110] S3002: Read the contents of the current cluster based on the cluster's byte length;

[0111] S3003: Determine whether the current cluster has an AVI header. If yes, proceed to step S3006; otherwise, proceed to step S3004.

[0112] Specifically, determining whether the current cluster has an AVI header in step S3003 includes the following steps:

[0113] If the content of the current cluster conforms to the RIFF file structure and also meets the following data structure, then the current cluster is determined to have an AVI header:

[0114] A: The content of the 4 bytes starting at address 0x0000 is the string "RIFF";

[0115] Figure 3 An example diagram of the AVI header data structure is shown in one embodiment of the present invention. For example... Figure 3 As shown, in this embodiment, the content of the first 4 bytes of the current file starting address is the hexadecimal representation of the ASCII code of the character "RIFF", that is, 0x52494646.

[0116] B: A byte with a length of 4 bytes, starting at address 0x0004, contains a value of 0x0008 or higher;

[0117] C: A string "AVI" or "AVIX" of type avi, starting at address 0x0008 and with a length of 4 bytes.

[0118] S3004: Determine whether the current cluster has an AVI index. If yes, proceed to step S3008; otherwise, proceed to step S3005.

[0119] Specifically, determining whether the current cluster has an AVI index includes the following steps:

[0120] If the content of the current cluster conforms to the following data structure, then the current cluster is determined to have an AVI index:

[0121] A: Is the chunk name one of the following values:

[0122] 02tx, 00db, 00dc, 01wb, 02wb, 01wc, 02wc, JUNK;

[0123] B: Is the block identifier 0x10 or 0x00?

[0124] C: Whether the byte length of the block is less than 0x1000000.

[0125] S3005: Determine whether the current cluster has an AVI block. If yes, proceed to step S3007; otherwise, proceed to step S3002.

[0126] S3006: Uses map storage method to store the AVI header as a header map;

[0127] Using the offset address of the current cluster on the disk as the keyword and the AVI header information as the key value, the current keyword and the current key value are added to the header map storage, and step S3012 is executed. The AVI header information includes the byte length of the corresponding AVI file and the address of the corresponding movi block in the AVI file.

[0128] S3007: Uses map storage method to store AVI chunks as chunk map storage;

[0129] Using the offset address of the current cluster on the disk as the key and the AVI block information as the critical value, the current key and the current critical value are added to the block map storage, and step S3012 is executed. The AVI block information includes the starting address of the first block and the length of the missing bytes of the last block in the current cluster.

[0130] S3008: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, proceed to step S3009; otherwise, proceed to step S3010.

[0131] Specifically, determining whether the header map storage contains a header includes the following steps:

[0132] In the data contained in the cluster starting with the AVI header, it is determined whether the name, identifier, offset address and byte length in the block correspond one-to-one with the data in the index. If they do, it means that the AVI header matches the AVI index, and the header map storage contains the header corresponding to the AVI index.

[0133] S3009: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S3012.

[0134] Specifically, step 3009 includes the following steps:

[0135] S30091: Use the current AVI header as the header of the AVI format surveillance video after engraving and write it into the AVI format surveillance video after engraving. Obtain the byte length of the surveillance video to be engraved from the current AVI header and subtract the byte length of the cluster containing the AVI header and the AVI index, and record the difference.

[0136] S30092: Determine if the difference is zero. If it is, it means that the clusters of the surveillance videos to be restored have been restored. Proceed to step S30094. Otherwise, proceed to step S30093.

[0137] S30093: Determine whether the cluster of AVI blocks that corresponds one-to-one with the cluster of the surveillance video to be engraved is found in the data map storage. If so, obtain the updated byte length of the surveillance video to be engraved and execute step S30092. Otherwise, execute step S30094.

[0138] Specifically, step 30093 includes the following steps:

[0139] S300930: Determine whether the data map has been completely traversed. If yes, execute S30094; otherwise, execute S300931.

[0140] S300931: Is the length of the missing bytes of the last block data in the current cluster equal to the offset of the first block of the currently traversed cluster in the data map storage? If yes, proceed to step S300932; otherwise, proceed to step S300930.

[0141] S300932: Does the data of each block of the currently traversed cluster in the data map storage correspond one-to-one with the data in the avi index map storage? If yes, proceed to step S300933; otherwise, proceed to step S300930.

[0142] S300933: The currently traversed cluster in the data map storage is written into the AVI format surveillance video after engraving. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. The difference between the byte length of the surveillance video to be engraved and the byte length of the current cluster is calculated, and step S30092 is executed.

[0143] S30094: Write the AVI index to the end of the copied AVI format surveillance video to complete the copying of the current surveillance video cluster. Then execute step S3012.

[0144] S3010: Uses map storage method to store AVI indexes as index map storage;

[0145] Using the offset address of the cluster where the AVI index is located as the key and the relevant information as the key value, the current key and the current key value are stored in the index map storage, and step S3012 is executed. The relevant information includes the starting address of the first block data.

[0146] S3011: Check if there are any un-carved surveillance videos in the AVI header map storage, AVI data map storage, and AVI index map storage. If so, proceed to step S3008; otherwise, end the process.

[0147] S3012: Address the next cluster, execute step S3001;

[0148] S3013: Restore the remaining surveillance video in the AVI index map storage, AVI header map storage, and AVI data map storage. Step 3013 includes the following steps:

[0149] S30131: Restore the remaining surveillance videos in the AVI index map storage, including the following steps:

[0150] S301311: Determine whether the loop traversal of the index map storage has ended. If yes, execute step S301315; otherwise, execute step S301312.

[0151] S301312: Retrieve the current cluster from the index map;

[0152] S301313: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, execute step S301314; otherwise, execute step S301311.

[0153] S301314: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S301311.

[0154] S301315: Delete the remaining clusters from the index map storage and proceed to step S30132;

[0155] S30132: The remaining surveillance video in the AVI header map storage includes the following steps:

[0156] S301321: Determine whether the loop traversal of the head map storage has ended. If yes, execute step S30133; otherwise, execute step S301322.

[0157] S301322: Retrieve the current cluster from the header map;

[0158] S301323: Retrieve the remaining surveillance videos from the data map storage, including the following steps:

[0159] S3013231: Use the current AVI header as the header of the copied AVI format surveillance video and write it into the copied AVI format surveillance video;

[0160] S3013232: Determine whether the data map storage for loop traversal has ended. If yes, execute step S301324; otherwise, execute step S3013233.

[0161] S3013233: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, proceed to step SS3013234; otherwise, proceed to step S3013232.

[0162] S3013234: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013232 is executed.

[0163] S301324: Generate the surveillance video to be reproduced, and execute step S301321;

[0164] S30133: Remaining surveillance videos in the AVI data map storage, including the following steps:

[0165] 301331: Determine if the loop traversal of the data map storage has ended. If yes, end the process; otherwise, execute step S301332.

[0166] S301332: Retrieve the current cluster from the data map;

[0167] S301333: Retrieve the remaining surveillance videos from the data map storage, including the following steps:

[0168] S3013331: Write the current cluster to the monitoring video to be etched;

[0169] S3013332: Determine whether the data map storage for the loop traversal has ended. If yes, execute step S3013335; otherwise, execute step S3013333.

[0170] S3013333: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, proceed to step SS3013334; otherwise, proceed to step S3013332.

[0171] S3013334: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013332 is executed.

[0172] S3013335: Generate the surveillance video to be reproduced, and execute step 301331.

[0173] The method provided by this invention solves the technical problem that there is no existing FAT32 or exFAT disk storage format for copying surveillance videos in AVI format.

[0174] It should be understood that the present invention is not limited to the examples described above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A method for replicating AVI format surveillance video, characterized in that... Includes the following steps: S100: Obtain the byte length of the cluster, including the following steps: S101: Traverse N clusters starting with the AVI header and record the starting address of each cluster, where N is a natural number not less than 1; S102: Calculate and record the difference in starting addresses between two adjacent clusters in each cluster; S103: Obtain the minimum value of the difference between the N-1 starting addresses in step S102, and use it as the byte length of the cluster; S200: Obtain the address of the first cluster, including the following steps: S201: Get the address of the first cluster that starts with an AVI header; S202: Starting from the address of the first cluster that begins with an AVI header, and using the byte length of the cluster as the offset, address each cluster backward until the address of the first cluster is reached; S300: Obtain the AVI index, retrieve the AVI header using the AVI index, match the corresponding blocks according to the AVI index, and copy the surveillance video in AVI format, including the following steps: S3000: Address of the first cluster; S3001: Determine whether the sculpting of all clusters has been completed. If yes, proceed to step S3011; otherwise, proceed to step S3002. S3002: Read the contents of the current cluster based on the cluster's byte length; S3003: Determine whether the current cluster has an AVI header. If yes, proceed to step S3006; otherwise, proceed to step S3004. S3004: Determine whether the current cluster has an AVI index. If yes, proceed to step S3008; otherwise, proceed to step S3005. S3005: Determine whether the current cluster has an AVI block. If yes, proceed to step S3007; otherwise, proceed to step S3002. S3006: Uses map storage method to store the AVI header as a header map; Using the offset address of the current cluster on the disk as the keyword and the AVI header information as the key value, the current keyword and the current key value are added to the header map storage, and step S3012 is executed. The AVI header information includes the byte length of the corresponding AVI file and the address of the corresponding movi block in the AVI file. S3007: Uses map storage method to store AVI chunks as chunk map storage; Using the offset address of the current cluster on the disk as the key and the AVI block information as the critical value, the current key and the current critical value are added to the block map storage, and step S3012 is executed. The AVI block information includes the starting address of the first block and the length of the missing bytes of the last block in the current cluster. S3008: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, proceed to step S3009; otherwise, proceed to step S3010. S3009: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S3012. S3010: Uses map storage method to store AVI indexes as index map storage; Using the offset address of the cluster where the AVI index is located as the key and the relevant information as the key value, the current key and the current key value are stored in the index map storage, and step S3012 is executed. The relevant information includes the starting address of the first block data. S3011: Check if there are any un-carved surveillance videos in the AVI header map storage, AVI data map storage, and AVI index map storage. If yes, proceed to step S3013; otherwise, end the process. S3012: Address the next cluster, execute step S3001; S3013: Remaining surveillance videos stored in the AVI index map, AVI header map, and AVI data map.

2. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, The disk storage format for AVI format surveillance videos is FAT32 or exFAT.

3. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, Step S3003, determining whether the current cluster has an AVI header, includes the following steps: If the content of the current cluster conforms to the RIFF file structure and also meets the following data structure, then the current cluster is determined to have an AVI header: A: The content of the 4 bytes starting at address 0x0000 is the string "RIFF"; B: A byte with a length of 4 bytes, starting at address 0x0004, contains a value of 0x0008 or higher; C: A string "AVI" or "AVIX" of type AVI, starting at address 0x0008 and with a length of 4 bytes.

4. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, In step S3004, determining whether the current cluster has an AVI index includes the following steps: If the content of the current cluster conforms to the following data structure, then the current cluster is determined to have an AVI index: A: Is the chunk name one of the following values: 02tx, 00db, 00dc, 01wb, 02wb, 01wc, 02wc, JUNK; B: Is the block identifier 0x10 or 0x00? C: Whether the byte length of the block is less than 0x1000000.

5. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, In step S3008, determining whether the header map storage contains a header includes the following steps: In the data contained in the cluster starting with the AVI header, it is determined whether the name, identifier, offset address and byte length in the block correspond one-to-one with the data in the index. If they do, it means that the AVI header matches the AVI index, and the header map storage contains the header corresponding to the AVI index.

6. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, Step 3009 includes the following steps: S30091: Use the current AVI header as the header of the AVI format surveillance video after engraving and write it into the AVI format surveillance video after engraving. Obtain the byte length of the surveillance video to be engraved from the current AVI header and subtract the byte length of the cluster containing the AVI header and the AVI index, and record the difference. S30092: Determine if the difference is zero. If it is, it means that the clusters of the surveillance videos to be restored have been restored. Proceed to step S30094. Otherwise, proceed to step S30093. S30093: Determine whether the cluster of AVI blocks that corresponds one-to-one with the cluster of the surveillance video to be engraved is found in the data map storage. If so, obtain the updated byte length of the surveillance video to be engraved and execute step S30092. Otherwise, execute step S30094. S30094: Write the AVI index to the end of the copied AVI format surveillance video to complete the copying of the current surveillance video cluster. Then execute step S3012.

7. The method for reproducing AVI format surveillance video according to claim 6, characterized in that, Step 30093 includes the following steps: S300930: Determine whether the data map has been completely traversed. If yes, execute S30094; otherwise, execute S300931. S300931: Is the length of the missing bytes of the last block data in the current cluster equal to the offset of the first block of the currently traversed cluster in the data map storage? If yes, proceed to step S300932; otherwise, proceed to step S300930. S300932: Does the data of each block of the currently traversed cluster in the data map storage correspond one-to-one with the data in the avi index map storage? If yes, proceed to step S300933; otherwise, proceed to step S300930. S300933: The currently traversed cluster in the data map storage is written into the AVI format surveillance video after engraving. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. The difference between the byte length of the surveillance video to be engraved and the byte length of the current cluster is calculated, and step S30092 is executed.

8. The method for reproducing AVI format surveillance video according to claim 1, characterized in that, Step 3013 includes the following steps: S30131: Restore the remaining surveillance videos in the AVI index map storage, including the following steps: S301311: Determine whether the loop traversal of the index map storage has ended. If yes, proceed to step S301315; otherwise, proceed to step S301312. S301312: Retrieve the current cluster from the index map storage; S301313: Determine whether the header map storage contains a header corresponding to the avi index in step S3004. If yes, execute step S301314; otherwise, execute step S301311. S301314: Use the current AVI header as the header of the copied AVI format surveillance video. Based on the AVI header and AVI index, copy the surveillance video from the AVI data map storage and execute step S301311. S301315: Delete the remaining clusters from the index map storage and proceed to step S30132; S30132: The remaining surveillance video in the AVI header map storage includes the following steps: S301321: Determine whether the loop traversal of the head map storage has ended. If yes, execute step S30133; otherwise, execute step S301322. S301322: Retrieve the current cluster from the header map storage; S301323: Retrieve the remaining surveillance videos from the data map storage, including the following steps: S3013231: Use the current AVI header as the header of the copied AVI format surveillance video and write it into the copied AVI format surveillance video; S3013232: Determine whether the data map storage for loop traversal has ended. If yes, execute step S301324; otherwise, execute step S3013233. S3013233: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, execute step S3013234; otherwise, execute step S3013232. S3013234: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013232 is executed. S301324: Generate the surveillance video to be reproduced, and execute step S301321; S30133: Remaining surveillance videos in the AVI data map storage, including the following steps: 301331: Determine if the loop traversal of the data map storage has ended. If yes, end the process; otherwise, execute step S301332. S301332: Retrieve the current cluster from the data map storage; S301333: Retrieve the remaining surveillance videos from the data map storage, including the following steps: S3013331: Write the current cluster to the monitoring video to be etched; S3013332: Determine whether the data map storage for the loop traversal has ended. If yes, execute step S3013335; otherwise, execute step S3013333. S3013333: Determine whether the length of the missing bytes in the last block of the current cluster is equal to the offset of the first block of the currently traversed cluster in the data map storage. If yes, execute step S3013334; otherwise, execute step S3013332. S3013334: The currently traversed cluster in the data map storage is written into the restored AVI format monitoring video. At the same time, the currently traversed cluster in the data map storage is deleted from the data map storage. The currently traversed cluster in the data map storage is used as the current cluster. Step S3013332 is executed. S3013335: Generate the surveillance video to be reproduced, and execute step 301331.

Citation Information

Patent Citations

  • Method for extracting amr audio file from damaged storage device

    CN115114090A