Audio file retrieval method and system
By constructing device nodes of storage media and using device identification codes and directory structure verification values, directly traversing the modified catalogs for audio file retrieval, solving the problems of low accuracy of audio file type detection and low retrieval efficiency in the prior art. Efficient and accurate audio file retrieval is achieved.
Patent Information
- Application Number
- CN202410099060.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-23
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-01-23
AI Technical Summary
In the prior art, audio file type detection depends on file extensions that are easily affected by file renaming or extension modification, resulting in low accuracy; and when determining file type by reading the magic signature of the file, it will lead to every unplug. Storage media consumes a lot of time and calculations, reducing the efficiency of audio file retrieval.
By building the device node of the storage medium, directly open the storage medium to parse file data, avoid the file system abstraction layer of the operating system and improve file reading speed. Use the device identification code and directory structure verification value to perform device identification and file directory modification and inspection, directly traverse the modified directory for audio file retrieval, and improve file traversal efficiency.
Improves the efficiency and accuracy of audio file retrieval, reduces the frequency of file opening and closing, reduces the time of repeated reading, and supports the rapid identification and processing of audio files.
Smart Images

Figure CN117932107B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to an audio file retrieval method and system. Background Art
[0002] In the context of big data, a large amount of data or files will be uniformly stored in databases or other mobile storage devices. Identifying whether a file is an audio file from a large number of files usually involves file type detection and content analysis. There are usually two methods for file type detection. One is to determine whether the file is an audio type based on the file extension, and the other is to read the magic signature of the file to determine the file type. Content analysis of files usually involves checking file header information or using audio feature extraction algorithms.
[0003] In the prior art, with the development of technology, audio player devices are applied to more and more fields, and also support various types of mobile storage media, and the capacity of mobile storage media is getting larger and larger.
[0004] In the prior art, a player device detects the type of each file stored in a mobile storage medium according to the extension name to determine whether the file is of an audio type. However, the method that relies on the file extension name is easily affected by file renaming or extension name change, and misjudgment is prone to occur during the detection process, resulting in low accuracy of file type detection.
[0005] When the player device determines the type of file by reading the magic signature of the file, each time the mobile storage medium is plugged in or out, the player device will open each file to read the magic signature, file header information, and content analysis to determine whether it is an audio file. This will consume a lot of time and calculation, and reduce the efficiency of audio file retrieval. Summary of the invention
[0006] In order to solve the above technical problems, the present invention discloses an audio file retrieval method and system to improve the efficiency and accuracy of audio file retrieval.
[0007] In order to achieve the above object, in a first aspect, the present invention discloses an audio file retrieval method, comprising:
[0008] Constructing a device node corresponding to the storage medium to be retrieved, and obtaining and saving the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location;
[0009] According to the first directory structure, the directory complexity of the storage medium to be retrieved is analyzed by a preset complexity analysis method to generate a first directory structure check value corresponding to the storage medium to be retrieved;
[0010] According to the device identification code, historical device identification code information stored in a preset database is searched to determine whether the storage medium to be retrieved is a historical device;
[0011] When the storage medium to be searched is not a historical device, according to the first file position, traversing the file information of each file in the storage medium to be searched through the device node, screening each first audio file in the storage medium to be searched according to the file information, and recording the first audio file position corresponding to each first audio file;
[0012] Generate and save first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system format and the first directory structure check value;
[0013] When the storage medium to be retrieved is a historical device, obtaining historical audio file information corresponding to the storage medium to be retrieved from the database according to the device identification code, and matching the first directory structure and the first file modification time with the second directory structure and the second file modification time in the historical audio file information, and determining whether the storage medium to be retrieved has been modified according to the matching result;
[0014] When it is determined that a file modification occurs in the storage medium to be retrieved, the second directory where the file modification occurs is determined and traversed by comparing the first directory structure check value with a second directory structure check value corresponding to the second directory structure, obtaining each second audio file in the second directory, and recording a second audio file position corresponding to each second audio file;
[0015] The second audio file information corresponding to the storage medium to be retrieved is generated according to the second audio file position and in combination with the historical audio file information.
[0016] The audio file retrieval method disclosed by the present invention first constructs a device node corresponding to the storage medium to be retrieved when retrieving an audio file, so that the storage medium is directly opened by using the device node to parse file data when performing file retrieval, thereby avoiding the technical means of adding a file system abstraction layer to read file data in the operating system of the prior art, and improving the speed of file reading. After constructing the device node, the device identification code and the file system format in the storage medium to be retrieved are read from the device node, and the directory structure in the file system format is used to construct the directory structure check value corresponding to the storage medium to be retrieved, so that the modification of the file directory is checked according to the directory structure check value. When it is determined that the storage medium to be retrieved is a historical device, the modified file directory can be directly locked by the check, so as to directly traverse the modified file directory. The modified directory is used to retrieve audio files, avoiding the complete traversal of the entire storage medium and improving the efficiency of file traversal. At the same time, after constructing the directory structure check value, the device identification code is used to identify the device. When the medium is identified as a new device, the file information of each file in the entire medium is traversed according to the first file position, and whether it is an audio file is identified according to the file information, thereby improving the accuracy of audio file identification. Then, when a file is identified as an audio file, the file position of the current file is recorded, and the first audio file information corresponding to the storage medium to be retrieved is generated and saved in combination with the file system format and device identification code corresponding to the storage medium read above, so that the audio file can be directly read according to the saved first audio file information when the storage medium is used next time, thereby reducing the repeated reading time and improving the efficiency of audio file retrieval.
[0017] As a preferred example, the step of constructing a device node corresponding to the storage medium to be searched, and obtaining and saving the device identification code and the file system structure of the storage medium to be searched through the device node includes:
[0018] Automatically detecting the plugging and unplugging operation of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, creating a device node corresponding to the storage medium to be retrieved;
[0019] The file system format corresponding to the storage medium to be retrieved is obtained through a preset file system type query instruction, and the device node is accessed according to the file system format to parse and obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
[0020] The present invention constructs the device node so that the storage medium can be directly opened through the device node for data reading, thereby reducing the frequency of opening and closing files and improving the efficiency of file reading. The device node is then used to read the device identification code and file system structure of the storage medium to facilitate subsequent device identification and file identification, thereby improving the efficiency and accuracy of file reading.
[0021] As a preferred example, in the step of analyzing the directory complexity of the storage medium to be retrieved by a preset complexity analysis method according to the first directory structure, and generating a first directory structure check value corresponding to the storage medium to be retrieved, the step includes:
[0022] Acquire several initial directories in the storage medium to be searched according to the first directory structure, and delete empty directories in the several initial directories to obtain several directories;
[0023] Obtaining a directory letter corresponding to each directory in the plurality of directories, and sorting the plurality of directories in descending order of the directory letters;
[0024] According to the first file position and the preset number of files of unit complexity, the files in the plurality of directories are divided to generate a plurality of file sets; wherein each file set includes the number of files of the unit complexity;
[0025] Verifying the file path of each file in each file set among the plurality of file sets, and generating and recording a unique value corresponding to each file set;
[0026] A first directory structure check value corresponding to the storage medium to be searched is generated according to the sorting and the unique value corresponding to each file set.
[0027] The present invention calculates the corresponding file complexity of each directory according to the first file position, uses the complexity to verify the file path, and generates a verification value corresponding to the complexity, which is used to verify whether there are any deleted or added files when the storage medium is used for audio file retrieval next time, thereby improving the reading efficiency of audio files.
[0028] As a preferred example, according to the first file position, traversing the file information of each file in the storage medium to be retrieved through the device node, and screening each first audio file in the storage medium to be retrieved according to the file information, includes:
[0029] According to the first file position, offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node;
[0030] The file information of each file is read according to the file position, and whether each file is the first audio file is determined according to the file information; wherein the file information includes a magic signature, file header information and file content.
[0031] The present invention determines whether the current file is an audio file by reading the magnetic signature, file header information and content analysis of the file, thereby ensuring from multiple aspects that the file finally screened out is an audio file and improving the accuracy of audio file extraction.
[0032] As a preferred example, the step of generating the second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information includes:
[0033] The second audio file information corresponding to the storage medium to be retrieved is generated by replacing the historical audio file position corresponding to the second directory with the second audio file position.
[0034] The present invention can generate a complete audio file list by only identifying the audio files in the modified directory when the same storage medium is modified, thereby improving the efficiency of audio file reading.
[0035] In a second aspect, the present invention discloses an audio file retrieval system, the system comprising a node building module, a directory analysis module, a device identification module, a file retrieval module, an information generation module, a file detection module, a directory modification module and an information update module;
[0036] The node building module is used to construct a device node corresponding to the storage medium to be retrieved, and obtain and save the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location;
[0037] The directory analysis module is used to analyze the directory complexity of the storage medium to be retrieved according to the first directory structure by a preset complexity analysis method, and generate a first directory structure check value corresponding to the storage medium to be retrieved;
[0038] The device identification module is used to query the historical device identification code information stored in the preset database according to the device identification code, and determine whether the storage medium to be retrieved is a historical device;
[0039] The file retrieval module is used for, when the storage medium to be retrieved is not a historical device, traversing the file information of each file in the storage medium to be retrieved through the device node according to the first file position, screening each first audio file in the storage medium to be retrieved according to the file information, and recording the first audio file position corresponding to each first audio file;
[0040] The information generation module is used to generate and save the first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system format and the first directory structure check value;
[0041] The file detection module is used for, when the storage medium to be retrieved is a historical device, obtaining the historical audio file information corresponding to the storage medium to be retrieved from the database according to the device identification code, and matching the first directory structure and the first file modification time with the second directory structure and the second file modification time in the historical audio file information, and determining whether the storage medium to be retrieved has been modified according to the matching result;
[0042] The directory modification module is used for, when determining that a file modification has occurred in the storage medium to be retrieved, determining and traversing the second directory where the file modification has occurred by comparing the first directory structure check value with the second directory structure check value corresponding to the second directory structure, obtaining each second audio file in the second directory, and recording the second audio file position corresponding to each second audio file;
[0043] The information updating module is used to generate the second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information.
[0044] The audio file retrieval system disclosed in the present invention first constructs a device node corresponding to the storage medium to be retrieved when retrieving an audio file, so that the storage medium is directly opened by using the device node to parse file data when performing file retrieval, thereby avoiding the technical means of adding a file system abstraction layer to read file data in the operating system of the prior art, and improving the speed of file reading. After constructing the device node, the device identification code and the file system format in the storage medium to be retrieved are read from the device node, and the directory structure in the file system format is used to construct the directory structure check value corresponding to the storage medium to be retrieved, so that the modification of the file directory is checked according to the directory structure check value. When it is determined that the storage medium to be retrieved is a historical device, the modified file directory can be directly locked through the check, so as to directly traverse the modified file directory. The modified directory is used to retrieve audio files, avoiding the complete traversal of the entire storage medium and improving the efficiency of file traversal. At the same time, after constructing the directory structure check value, the device identification code is used to identify the device. When the medium is identified as a new device, the file information of each file in the entire medium is traversed according to the first file position, and whether it is an audio file is identified according to the file information, thereby improving the accuracy of audio file identification. Then, when a file is identified as an audio file, the file position of the current file is recorded, and the first audio file information corresponding to the storage medium to be retrieved is generated and saved in combination with the file system format and device identification code corresponding to the storage medium read above, so that the audio file can be directly read according to the saved first audio file information when the storage medium is used next time, thereby reducing the repeated reading time and improving the efficiency of audio file retrieval.
[0045] As a preferred example, the node building module includes a node creation unit and a node access unit;
[0046] The node creation unit is used to automatically detect the plugging and unplugging operation of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, create a device node corresponding to the storage medium to be retrieved;
[0047] The node access unit is used to obtain the file system format corresponding to the storage medium to be retrieved through a preset file system type query instruction, and access the device node according to the file system format to parse and obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
[0048] The present invention constructs the device node so that the storage medium can be directly opened through the device node for data reading, thereby reducing the frequency of opening and closing files and improving the efficiency of file reading. The device node is then used to read the device identification code and file system structure of the storage medium to facilitate subsequent device identification and file identification, thereby improving the efficiency and accuracy of file reading.
[0049] As a preferred example, the directory analysis module includes a directory acquisition unit, a complexity analysis unit and a check value generation unit;
[0050] The directory acquisition unit is used to acquire several initial directories in the storage medium to be searched according to the first directory structure, and delete empty directories in the several initial directories to obtain several directories; acquire directory letters corresponding to each directory in the several directories, and sort the several directories in descending order according to the directory letters;
[0051] The complexity analysis unit is used to divide the files in the plurality of directories according to the first file position and the preset number of unit complexity files to generate a plurality of file sets; wherein each file set includes the number of files of the unit complexity;
[0052] The verification value generation unit is used to verify the file path of each file in each file set among the several file sets, generate and record a unique value corresponding to each file set; and generate a first directory structure verification value corresponding to the storage medium to be retrieved based on the sorting and the unique value corresponding to each file set.
[0053] According to the first file position, the present invention uses the calculated file complexity corresponding to each directory as the directory complexity verification value to verify whether there are deleted or added files when the storage medium is used for audio file retrieval next time, thereby improving the reading efficiency of audio files.
[0054] As a preferred example, the file retrieval module includes a file locating unit and an information reading unit;
[0055] The file positioning unit is used to offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node according to the first file position;
[0056] The information reading unit is used to read the file information of each file according to the file position, and determine whether each file is the first audio file according to the file information; wherein the file information includes a magic signature, file header information and file content.
[0057] The present invention determines whether the current file is an audio file by reading the magic signature, file header information, and content analysis of the file, thereby ensuring from multiple aspects that the file finally screened out is an audio file and improving the accuracy of audio file extraction.
[0058] In a third aspect, the present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the audio file retrieval method as described in the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 : is a flow chart of an audio file retrieval method disclosed in an embodiment of the present invention;
[0060] Figure 2 : is a structural diagram of an audio file retrieval system disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0062] Embodiment 1
[0063] This embodiment discloses an audio file retrieval method. The specific implementation process of the retrieval method can be referred to Figure 1 , mainly including steps 101 to 106, the steps include:
[0064] Step 101: construct a device node corresponding to the storage medium to be retrieved, and obtain and save the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location.
[0065] In this embodiment, the steps are as follows: automatically detecting the plugging and unplugging operations of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, creating a device node corresponding to the storage medium to be retrieved; obtaining the file system format corresponding to the storage medium to be retrieved through a preset file system type query instruction, accessing the device node according to the file system format, and parsing to obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
[0066] Specifically, in a certain implementable mode provided in this embodiment, when the storage medium to be retrieved is a mobile storage medium, including a mobile hard disk or a USB, etc., when the mobile storage medium is inserted into an audio playback device or other device for audio file retrieval, the insertion operation of the mobile storage medium is first detected by a preset operation detection method, and then a device node corresponding to the mobile storage medium is created without mounting. Optionally, when creating the device node, the mobile storage medium may also be subjected to operations such as device registration, device identification or device allocation, so as to select the above-mentioned optional operations according to the device requirements of the device connected to the mobile storage medium.
[0067] Preferably, referring to the audio playback device connected to the mobile storage medium, after creating the device node, a message of plugging and unplugging the device of the mobile storage medium is thrown, and the file system type query instruction can be used to monitor the message and parse the plug / unplug action and its device node from the message. Furthermore, the file system type query instruction can use the netlink instruction. When the netlink instruction is selected for query, the file system format of the mobile storage medium is obtained by using blkid, and the device node is directly opened to read data (the same as reading a file). According to the corresponding file system specification, the device identification code and file system structure corresponding to the mobile storage medium are parsed, and the file system structure includes a directory structure, file modification time and file location.
[0068] In this embodiment, this step constructs the device node so that the storage medium can be directly opened through the device node for data reading, reducing the frequency of file opening and closing, and improving the efficiency of file reading. The device node is then used to read the device identification code and file system structure of the storage medium to facilitate subsequent device identification and file identification, thereby improving the efficiency and accuracy of file reading.
[0069] Step 102: According to the first directory structure, the directory complexity of the storage medium to be retrieved is analyzed by a preset complexity analysis method, and a first directory structure check value corresponding to the storage medium to be retrieved is generated.
[0070] In this embodiment, this step mainly includes: obtaining several initial directories in the storage medium to be retrieved according to the first directory structure, and deleting empty directories in the several initial directories to obtain several directories; obtaining directory letters corresponding to each directory in the several directories, and sorting the several directories in descending order according to the directory letters; dividing the files in the several directories according to the first file position and the preset number of unit complexity files to generate several file sets; wherein each file set includes the number of files of the unit complexity; verifying the file path of each file in each file set in the several file sets, generating and recording a unique value corresponding to each file set; generating a first directory structure verification value corresponding to the storage medium to be retrieved according to the sorting and the unique value corresponding to each file set.
[0071] Specifically, in a certain specific implementation method provided in this embodiment, according to the parsed directory structure, the empty directories of the mobile storage medium are filtered out, and the file path of each file is temporarily stored according to the file location, and the directories are sorted in descending order to obtain file information, that is, the location and size of the file in the storage medium. According to the temporarily stored file path, the directory is used as a unit to calculate the complexity of 1 for every m files or more. If the number of files under all directories of the same level does not reach m, they are added to the calculation of the files under the upper directory and recorded as 1 complexity, and so on. Then, the file path under each directory with a complexity of 1 is calculated and verified to calculate a unique value and record it for the next time the storage medium is used to verify whether files have been deleted or added.
[0072] When the directory complexity is obtained, a verification value is generated for the directory structure in the mobile storage medium according to the directory complexity. Specifically, after the file path is obtained and sorted by directory, 500 files are regarded as a complexity of 1, and the first 500 file paths are sequentially used and verified to calculate the verification value, and the directory where the 500 files are located is parsed and recorded. If there are other files in the directory where the 500th file of the current complexity is located, all files in this directory will be incorporated into the calculation. If the final directory calculation is less than 500 files, it will also be calculated at a complexity of 1.
[0073] Optionally, in the process of generating the check value, the check value can be analyzed according to the directory depth. For example, if the directory depth is 6 levels, all files under the 3rd level directory and all files under its subdirectories are checked using sum to calculate the check value, among which all files under the 2nd level directory and its subdirectories (only directory path, not including files) are checked using sum to calculate the check value, and all files under the 1st level directory and its subdirectories (only directory path, not including files) are checked using sum to calculate the check value, and all files under the root directory and its subdirectories (only directory path, not including files) are checked using sum to calculate the check value.
[0074] In this embodiment, this step is based on the first file location, calculates the corresponding file complexity in each directory, uses the complexity to verify the file path, and generates a verification value corresponding to the complexity, which is used to verify whether there are any deleted or added files the next time this storage medium is used for audio file retrieval, thereby improving the reading efficiency of audio files.
[0075] Step 103: query historical device identification code information stored in a preset database according to the device identification code to determine whether the storage medium to be retrieved is a historical device.
[0076] In this embodiment, the step is: after parsing and obtaining the device identification code of the current device to be retrieved, retrieve the historical device identification code information stored in a preset database according to the device identification code; when the device identification code exists in the historical device identification code information, determine that the device to be retrieved is a historical device; when the device identification code does not exist in the historical device identification code information, determine that the device to be retrieved is a new device.
[0077] Specifically, referring to the mobile storage medium being inserted into the audio playback device, the unique UU ID, i.e., the unique universal identification code, of the mobile storage medium is obtained by using the device node to parse, and the historical playback records saved by the audio playback device are queried according to the unique universal identification code to determine whether the unique universal identification code exists in the historical playback records. When the unique universal identification code exists in the historical playback records, it indicates that the mobile storage medium has been inserted into the audio playback device before. If the unique universal identification code does not exist in the historical playback records, it indicates that the mobile storage medium is inserted into the audio playback device for the first time.
[0078] Step 104: When the storage medium to be retrieved is not a historical device, according to the first file position, traverse the file information of each file in the storage medium to be retrieved through the device node, filter each first audio file in the storage medium to be retrieved according to the file information, and record the first audio file position corresponding to each first audio file.
[0079] In this embodiment, the step is: according to the first file position, offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node; read the file information of each file according to the file position, and determine whether each file is the first audio file according to the file information; wherein the file information includes a magic signature, file header information and file content.
[0080] Specifically, in a certain implementation method provided in this embodiment, the file position is offset to the corresponding file position, and the file information corresponding to each file is traversed and read according to the file position, and whether the file is an audio file is determined according to the file information. Specifically, the file information of each file includes the file's magic signature, file header information, and content, wherein the "magic" signature of the file is a specific identifier of the file, usually a byte sequence in the file header, used to identify the type of the file. This identifier is usually composed of some fixed byte values or characters, which can help the computer system determine the format of the file so as to correctly interpret and process them. Different types of audio files correspond to different file offsets and magic values. Among them, this embodiment provides magic values of 38 audio formats, which can be referred to in the following table:
[0081]
[0082]
[0083]
[0084] After determining that the file is an audio file based on the magic signature, file header information, and content analysis of the file, the file position corresponding to the current file is recorded, and the total audio duration corresponding to the current audio file is recorded while recording the file position of the audio file.
[0085] In this embodiment, this step determines whether the current file is an audio file by reading the magnetic signature, file header information, and content analysis of the file, thereby ensuring from multiple aspects that the file finally screened out is an audio file and improving the accuracy of audio file extraction.
[0086] Step 105: Generate and save first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system structure and the first directory structure check value.
[0087] Step 106: When the storage medium to be retrieved is a historical device, historical audio file information corresponding to the storage medium to be retrieved is obtained from the database according to the device identification code, and the first directory structure and the first file modification time are matched with the second directory structure and the second file modification time in the historical audio file information, and it is determined whether file modification has occurred in the storage medium to be retrieved according to the matching result.
[0088] In this embodiment, the step is: first obtain the directory structure and file modification time corresponding to the current device to be retrieved, match the directory structure and the file modification time with the historical directory structure and the historical file modification time saved in the identified historical playback record, and when the directory structures are different or the file modification times are inconsistent, it is determined that the files in the same storage medium have been modified.
[0089] Step 107: When it is determined that a file modification has occurred in the storage medium to be retrieved, the second directory where the file modification has occurred is determined and traversed by comparing the first directory structure check value with the second directory structure check value corresponding to the second directory structure, obtaining each second audio file in the second directory, and recording the second audio file position corresponding to each second audio file.
[0090] In this embodiment, the step is: when it is determined that a file modification has occurred in the storage medium to be retrieved, the same directory complexity analysis method and check value generation method are used to generate a check value corresponding to the directory structure in the current storage medium, and then the check value is compared one by one with the check value saved in the historical playback record to determine which directory has been modified, re-identify the files in this directory, obtain the audio files in the directory, and record the file position corresponding to each audio file in the directory.
[0091] Preferably, when no file modification occurs in the storage medium to be searched, the path of the audio file stored historically is directly extracted from the database, and the audio file is searched for on the storage medium to be searched according to the audio file path.
[0092] Step 108: Generate second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information.
[0093] In this embodiment, this step is: by replacing the historical audio file position corresponding to the second directory with the second audio file position, the second audio file information corresponding to the storage medium to be retrieved is generated.
[0094] On the other hand, this embodiment also discloses an audio file retrieval system. The specific structure of the system can be referred to Figure 2 The system includes a node building module 201, a directory analysis module 202, a device identification module 203, a file retrieval module 204, an information generation module 205, a file detection module 206, a directory modification module 207 and an information update module 208.
[0095] The node building module 201 is used to construct a device node corresponding to the storage medium to be retrieved, and obtain and save the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location.
[0096] The directory analysis module 202 is used to analyze the directory complexity of the storage medium to be retrieved according to the first directory structure by a preset complexity analysis method, and generate a first directory structure check value corresponding to the storage medium to be retrieved.
[0097] The device identification module 203 is used to query the historical device identification code information stored in a preset database according to the device identification code, and determine whether the storage medium to be retrieved is a historical device.
[0098] The file retrieval module 204 is used for traversing the file information of each file in the storage medium to be retrieved through the device node according to the first file position when the storage medium to be retrieved is not a historical device, screening each first audio file in the storage medium to be retrieved according to the file information, and recording the first audio file position corresponding to each first audio file.
[0099] The information generation module 205 is used to generate and save the first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system format and the first directory structure check value.
[0100] The file detection module 206 is used to obtain the historical audio file information corresponding to the storage medium to be retrieved from the database according to the device identification code when the storage medium to be retrieved is a historical device, and match the first directory structure and the first file modification time with the second directory structure and the second file modification time in the historical audio file information, and determine whether the storage medium to be retrieved has any file modification based on the matching result.
[0101] The directory modification module 207 is used to determine and traverse the second directory where the file modification has occurred by comparing the first directory structure check value with the second directory structure check value corresponding to the second directory structure when it is determined that the file modification has occurred in the storage medium to be retrieved, obtain each second audio file in the second directory, and record the second audio file position corresponding to each second audio file.
[0102] The information updating module 208 is used to generate the second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information.
[0103] In this embodiment, the node building module 201 includes a node creation unit and a node access unit.
[0104] The node creation unit is used to automatically detect the plugging and unplugging operation of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, create a device node corresponding to the storage medium to be retrieved.
[0105] The node access unit is used to obtain the file system format corresponding to the storage medium to be retrieved through a preset file system type query instruction, and access the device node according to the file system format to parse and obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
[0106] In this embodiment, the directory analysis module 202 includes a directory acquisition unit, a complexity analysis unit, and a check value generation unit.
[0107] The directory acquisition unit is used to acquire several initial directories in the storage medium to be retrieved according to the first directory structure, and delete empty directories in the several initial directories to obtain several directories; obtain directory letters corresponding to each directory in the several directories, and sort the several directories in descending order according to the directory letters.
[0108] The complexity analysis unit is used to divide the files in the several directories according to the first file position and the preset unit complexity file number to generate several file sets; wherein each file set includes the unit complexity file number of files.
[0109] The verification value generation unit is used to verify the file path of each file in each file set among the several file sets, generate and record a unique value corresponding to each file set; and generate a first directory structure verification value corresponding to the storage medium to be retrieved based on the sorting and the unique value corresponding to each file set.
[0110] In this embodiment, the file retrieval module 204 includes a file locating unit and an information reading unit.
[0111] The file positioning unit is used to offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node according to the first file position.
[0112] The information reading unit is used to read the file information of each file according to the file position, and determine whether each file is the first audio file according to the file information; wherein the file information includes a magic signature, file header information and file content.
[0113] In addition to the above method and system, this embodiment further discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, an audio file retrieval method described in this embodiment is implemented.
[0114] The present embodiment discloses an audio file retrieval method, system and storage medium. In order to improve the file reading speed, reduce the frequency of opening and closing files, and avoid introducing other abstract layers to reduce the file reading speed, the file data can be directly read, that is, the file system structure is parsed from the device node, the position of each file is traversed and read, and the magic signature, file header information and content analysis of the file are offset to the corresponding position to determine whether it is an audio file. If it is an audio file, the information will be recorded. At the same time, in order to efficiently and accurately complete the operation of identifying the audio file, the mobile storage medium will be frequently plugged in and out when used on the player device, and the user will frequently delete, add and modify the file. Under the premise of improving the user experience, it is necessary to improve the secondary reading efficiency. Therefore, after traversing each file, the present invention needs to recursively obtain all file information under each first-level subdirectory, and use the checksum function to calculate the unique value and record it, so as to verify whether the file in this directory has changed when the storage medium is used next time. If it has changed, it is necessary to verify whether the audio file in this directory still exists. If it exists, the recognition of this audio file is skipped, and then the other audio files in this directory need to be re-identified. In this way, the recognition operation can be completed in a short time. If there is no change, the file list can be generated immediately. At the same time, the present invention retrieves audio files by identifying file signatures, file contents and file header information, which can ensure the accuracy of audio file retrieval from multiple aspects, has wide support, and can accurately identify a variety of audio files.
[0115] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. An audio file retrieval method, characterized in that: include: Constructing a device node corresponding to the storage medium to be retrieved, and obtaining and saving the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location; According to the first directory structure, the directory complexity of the storage medium to be retrieved is analyzed by a preset complexity analysis method, and a first directory structure verification value corresponding to the storage medium to be retrieved is generated; wherein, according to the first directory structure, several initial directories in the storage medium to be retrieved are obtained, and empty directories in the several initial directories are deleted to obtain several directories; the directory letters corresponding to each directory in the several directories are obtained, and the several directories are sorted in descending order according to the directory letters; according to the first file position and the preset number of files per unit complexity, the files in the several directories are divided to generate several file sets; wherein each file set includes the number of files per unit complexity; the file path of each file in each file set in the several file sets is verified, and a unique value corresponding to each file set is generated and recorded; according to the sorting and the unique value corresponding to each file set, a first directory structure verification value corresponding to the storage medium to be retrieved is generated; According to the device identification code, historical device identification code information stored in a preset database is searched to determine whether the storage medium to be retrieved is a historical device; When the storage medium to be searched is not a historical device, according to the first file position, traversing the file information of each file in the storage medium to be searched through the device node, screening each first audio file in the storage medium to be searched according to the file information, and recording the first audio file position corresponding to each first audio file; Generate and save first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system structure and the first directory structure check value; When the storage medium to be retrieved is a historical device, obtaining historical audio file information corresponding to the storage medium to be retrieved from the database according to the device identification code, and matching the first directory structure and the first file modification time with the second directory structure and the second file modification time in the historical audio file information, and determining whether the storage medium to be retrieved has been modified according to the matching result; When it is determined that a file modification occurs in the storage medium to be retrieved, the second directory where the file modification occurs is determined and traversed by comparing the first directory structure check value with a second directory structure check value corresponding to the second directory structure, obtaining each second audio file in the second directory, and recording a second audio file position corresponding to each second audio file; The second audio file information corresponding to the storage medium to be retrieved is generated according to the second audio file position and in combination with the historical audio file information.
2. An audio file retrieval method as claimed in claim 1, characterized in that: The step of constructing a device node corresponding to the storage medium to be retrieved, and obtaining and saving the device identification code and the file system structure of the storage medium to be retrieved through the device node, includes: Automatically detecting the plugging and unplugging operation of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, creating a device node corresponding to the storage medium to be retrieved; The file system format corresponding to the storage medium to be retrieved is obtained through a preset file system type query instruction, and the device node is accessed according to the file system format to parse and obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
3. The audio file retrieval method according to claim 1, characterized in that: The step of traversing the file information of each file in the storage medium to be retrieved through the device node according to the first file position, and screening each first audio file in the storage medium to be retrieved according to the file information includes: According to the first file position, offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node; The file information of each file is read according to the file position, and whether each file is the first audio file is determined according to the file information; wherein the file information includes a magic signature, file header information and file content.
4. The audio file retrieval method according to claim 1, characterized in that: The step of generating the second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information includes: The second audio file information corresponding to the storage medium to be retrieved is generated by replacing the historical audio file position corresponding to the second directory with the second audio file position.
5. An audio file retrieval system, characterized in that: The system includes a node building module, a directory analysis module, a device identification module, a file retrieval module, an information generation module, a file detection module, a directory modification module and an information update module; The node building module is used to construct a device node corresponding to the storage medium to be retrieved, and obtain and save the device identification code and file system structure of the storage medium to be retrieved through the device node; wherein the file system structure includes a first directory structure, a first file modification time and a first file location; The directory analysis module is used to analyze the directory complexity of the storage medium to be retrieved according to the first directory structure by a preset complexity analysis method, and generate a first directory structure verification value corresponding to the storage medium to be retrieved; wherein, the directory analysis module includes a directory acquisition unit, a complexity analysis unit and a verification value generation unit; the directory acquisition unit is used to acquire several initial directories in the storage medium to be retrieved according to the first directory structure, and delete empty directories in the several initial directories to obtain several directories; obtain the directory letters corresponding to each directory in the several directories, and sort the several directories in descending order according to the directory letters; the complexity analysis unit is used to divide the files in the several directories according to the first file position and the preset number of unit complexity files, and generate several file sets; wherein each file set includes the number of files of the unit complexity; the verification value generation unit is used to verify the file path of each file in each file set in the several file sets, and generate and record the unique value corresponding to each file set; according to the sorting and the unique value corresponding to each file set, generate the first directory structure verification value corresponding to the storage medium to be retrieved; The device identification module is used to query the historical device identification code information stored in the preset database according to the device identification code, and determine whether the storage medium to be retrieved is a historical device; The file retrieval module is used for, when the storage medium to be retrieved is not a historical device, traversing the file information of each file in the storage medium to be retrieved through the device node according to the first file position, screening each first audio file in the storage medium to be retrieved according to the file information, and recording the first audio file position corresponding to each first audio file; The information generation module is used to generate and save the first audio file information corresponding to the storage medium to be retrieved according to the device identification code, the first audio file location, the file system format and the first directory structure check value; The file detection module is used for, when the storage medium to be retrieved is a historical device, obtaining the historical audio file information corresponding to the storage medium to be retrieved from the database according to the device identification code, and matching the first directory structure and the first file modification time with the second directory structure and the second file modification time in the historical audio file information, and determining whether the storage medium to be retrieved has been modified according to the matching result; The directory modification module is used for, when determining that a file modification has occurred in the storage medium to be retrieved, determining and traversing the second directory where the file modification has occurred by comparing the first directory structure check value with the second directory structure check value corresponding to the second directory structure, obtaining each second audio file in the second directory, and recording the second audio file position corresponding to each second audio file; The information updating module is used to generate the second audio file information corresponding to the storage medium to be retrieved according to the second audio file position and in combination with the historical audio file information.
6. An audio file retrieval system as claimed in claim 5, characterized in that: The node building module includes a node creation unit and a node access unit; The node creation unit is used to automatically detect the plugging and unplugging operation of the storage medium to be retrieved according to a preset operation detection method, and when the insertion operation of the storage medium to be retrieved is detected, create a device node corresponding to the storage medium to be retrieved; The node access unit is used to obtain the file system format corresponding to the storage medium to be retrieved through a preset file system type query instruction, and access the device node according to the file system format to parse and obtain the device identification code and file system structure corresponding to the storage medium to be retrieved.
7. An audio file retrieval system as claimed in claim 5, characterized in that: The file retrieval module includes a file locating unit and an information reading unit; The file positioning unit is used to offset to the file position corresponding to each file in the storage medium to be retrieved by accessing the device node according to the first file position; The information reading unit is used to read the file information of each file according to the file position, and determine whether each file is the first audio file according to the file information; wherein the file information includes a magic signature, file header information and file content.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the audio file retrieval method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Audio data processing method and device, equipment and storage medium
CN114913864A
Audio device
JP2013051004A