Multimedia file extraction method
Technical Field
The invention relates to a data extraction technology, in particular to a multimedia file extraction method.
Background
In the field of security monitoring, various storage devices are numerous, and each monitoring device manufacturer designs its own data storage format, so that video data on each hard disk cannot be read by adopting a uniform method or tool. Because the hard disk data storage formats of the monitoring devices such as the hard disk video recorder/network video recorder manufactured by various monitoring device manufacturers are different, the hard disk data stored in the hard disks need to be extracted by adopting the product tools owned by the manufacturers, and a universal file extraction method is not available for extracting the hard disk data of the monitoring devices of different manufacturers, which is very inconvenient.
Disclosure of Invention
The invention provides a multimedia file extraction method, which aims to solve the problem that no universal file extraction method is available in the prior art to extract data in memories of monitoring equipment of different manufacturers. The invention is realized by the following technical scheme:
a multimedia file extraction method, comprising:
step 1: analyzing the file system format of each partition in the memory, if the file system format of each partition in the memory is analyzed, entering a step 3, and otherwise, entering a step 2;
step 2: analyzing the file format of each data block in the memory, and entering step 4 if the file format of each data block in the memory is analyzed;
and step 3: extracting each data block from the memory to reconstruct a media file according to the file system format of each partition in the memory, and then entering step 5;
and 4, step 4: extracting each data block from the memory to reconstruct a media file according to the file format of each data block in the memory, and then entering step 5;
and 5: and outputting the reconstructed media file.
Further, in step 1, the method for analyzing the file system format of each partition in the memory includes:
the method comprises the following steps: determining a file system format of each partition in the memory by reading a file system format flag of a 0 th sector of each partition in the memory;
the method 2 comprises the following steps: selecting one SDK plug-in from a plurality of SDK plug-ins based on SDK development kits of different manufacturers for carrying out format matching on each partition in the memory each time, wherein the file system format of each partition is the file system format corresponding to the SDK plug-in capable of successfully matching the partition; each SDK plug-in comprises the private file system format information of each corresponding manufacturer;
the method 3 comprises the following steps: selecting one API plug-in from a plurality of API plug-ins based on different official APIs each time to carry out format matching on each partition in the memory, wherein the file system format of each partition is the file system format corresponding to the API plug-in capable of successfully matching the partition; each API plug-in contains the corresponding official file system format information.
Further, in the step 2, the method for analyzing the file format of each data block in the memory includes:
and selecting one file format from a plurality of preset file format plug-ins each time to match the file formats of the data blocks in the memory, wherein the file format of each data block is the file format corresponding to the file format plug-in capable of successfully matching the data block.
Further, the method for extracting each data block from the memory to reconstruct the media file comprises the following steps:
extracting each data block from the memory;
and recombining the data blocks belonging to the same media file in the extracted data blocks to obtain each media file.
Further, the method 1, the method 2 and the method 3 are performed in the following order:
the file system format of each partition in the memory is analyzed by the method 1, and then the file system format of each partition in the memory, for which the file system format has not been analyzed, is analyzed by the method 2 or the method 3.
Further, after the step 4 and before the step 5, the method further comprises the following steps:
and correcting the attribute information of each reconstructed media file.
Further, in the step 3, extracting each data block through a file system format plug-in corresponding to the file system format of the partition where each data block is located;
in the step 4, each data block is extracted through the file format plug-in corresponding to the file format of each data block.
Further, the file system format plug-in includes a FAT32 format plug-in, an EXT3 format plug-in, or a WFS format plug-in, and the file format plug-in includes an AVI format plug-in, an MP4 format plug-in, a JPEG format plug-in, or a PNG format plug-in.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the multimedia file extraction method provided by the invention can be used for extracting files according to the file system format and the file format, is not limited by the formats of manufacturers of various monitoring equipment in the security field, and can be applied to the media file extraction of various monitoring equipment in the security field. Meanwhile, the method adopts a data recombination mode to extract the file, is not easily influenced by storage conditions and has high reliability. Moreover, the method adopts a plug-in mode, can easily increase supportable file formats or file system formats in a targeted manner, and cannot influence the original system structure.
Drawings
FIG. 1 is a schematic flow chart of a multimedia file extraction method;
fig. 2 is a detailed flowchart of a multimedia file extraction method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the following embodiments and the accompanying drawings.
As shown in fig. 1, a multimedia file extraction method includes:
step 1: analyzing the file system format of each partition in the memory, if the file system format of each partition in the memory is analyzed, entering a step 3, and if not, entering a step 2;
step 2: analyzing the file format of each data block in the memory, and entering step 4 if the file format of each data block in the memory is analyzed;
and step 3: extracting each data block from the memory to reconstruct the media file according to the file system format of each partition in the memory, and then entering the step 5;
and 4, step 4: extracting each data block from the memory to reconstruct a media file according to the file format of each data block in the memory, and then entering step 5;
and 5: and outputting the reconstructed media file.
In step 1, the method for analyzing the file system format of each partition in the memory comprises the following steps:
the method comprises the following steps: the file system format of each partition in the memory is determined by reading the file system format flag of the 0 th sector of each partition in the memory. The file system format mark is written in the 0 th sector of each partition in most memories to identify the file system format of the corresponding partition, and the file system format of each partition in the memory can be acquired by reading the file system format mark of the 0 th sector of each partition in the memory.
The method 2 comprises the following steps: selecting one SDK plug-in from a plurality of SDK plug-ins based on SDK development kits of different manufacturers for carrying out format matching on each partition in a memory each time, wherein the file system format of each partition is the file system format corresponding to the SDK plug-in capable of successfully matching the partition; each SDK plug-in includes the private file system format information of the corresponding manufacturer. Some memories in the monitoring devices adopt a proprietary file system format of a monitoring device manufacturer, and the memories do not have file system format marks, so that the file system format of each partition in the memories cannot be determined by reading the file system format marks. However, file system format identification and file extraction may be performed on the memory in the factory-provided monitoring device by an SDK plug-in based on the factory-provided SDK development kit. If the storage is not determined to be provided by which manufacturer, a plurality of SDK plug-ins based on SDK development kits of different manufacturers can be obtained in advance, then one SDK plug-in is selected from the SDK plug-ins each time to carry out file system format matching on each partition in the storage, and if a certain partition can be successfully matched by a certain SDK plug-in, the file system format of the partition is indicated to be the file system format corresponding to the SDK plug-in.
The method 3 comprises the following steps: selecting one API plug-in from a plurality of API plug-ins based on different official APIs each time to perform format matching on each partition in the memory, wherein the file system format of each partition is the file system format corresponding to the API plug-in capable of successfully matching the partition; each API plug-in contains the corresponding official file system format information. Method 3 is essentially the same as method 2, except that the SDK plug-in is replaced with an API plug-in.
The execution sequence of method 1, method 2 and method 3 is: the file system format of each partition in the memory is analyzed by the method 1, and then the file system format of each partition in the memory, for which the file system format has not been analyzed, is analyzed by the method 2 or the method 3. In analyzing the file system format of each partition in the memory, once the file system format of a partition is analyzed, the partition is not repeatedly analyzed.
In step 2, the method for analyzing the file format of each data block in the memory comprises the following steps:
and selecting one file format from a plurality of preset file format plug-ins each time to match the file formats of the data blocks in the memory, wherein the file format of each data block is the file format corresponding to the file format plug-in capable of successfully matching the data block. In the process of analyzing the file format of each data block in the storage, once the file format of a certain data block is analyzed, the data block is not repeatedly analyzed.
The method for extracting each data block from the memory to reconstruct the media file comprises the following steps:
and extracting each data block from the memory, and recombining each data block belonging to the same media file in each extracted data block to obtain each media file.
After the step 4 and before the step 5, the following steps are also included: and correcting the attribute information of each reconstructed media file.
In step 3, each data block is extracted through a file system format plug-in corresponding to the file system format of the partition in which each data block is located. In step 4, each data block is extracted through a file format plug-in corresponding to the file format of each data block. The file system format plug-ins include FAT32 format plug-ins, EXT3 format plug-ins, WFS format plug-ins, and the like, and the file format plug-ins include AVI format plug-ins, MP4 format plug-ins, JPEG format plug-ins, PNG format plug-ins, and the like.
Fig. 2 shows a specific flow of the multimedia file extraction method according to the embodiment of the present invention. Firstly, a memory and information thereof in the current monitoring equipment are identified through a drive of a system bottom layer. The memory is then parsed using a fast parsing scheme (i.e., file system format parsing). In the rapid analysis mode, each file system format plug-in is firstly obtained, then the file system format plug-ins are loaded, then the current file system format plug-ins are traversed, and each partition in the memory is identified through three modes so as to determine the file system format of each partition. If the identification is successful, the file system format of each partition can be determined, then the data blocks are extracted from each partition of the memory and recombined to obtain the media file, and if the identification is not successful, a deep analysis mode (namely file format analysis) is adopted. In the deep analysis mode, each file format plug-in is obtained and loaded, the file format of each data block of the memory is identified by traversing each file format plug-in, and after the file format of each data block is identified, each data block belonging to the media file can be extracted according to the media file information to be recombined to obtain the media file. And formatting the obtained media file and finally outputting the media file.
The above-described embodiments are merely preferred embodiments, which are not intended to limit the scope of the present invention, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present invention should be included in the scope of the present invention.