Media scanning task execution method and apparatus, and device and medium
By optimizing the media scanning task using a binary search algorithm and concurrent thread processing in the Android system, the slow speed of the native Android media scanning service is solved, enabling faster media file information loading and database updates.
Patent Information
- Application Number
- PCT/CN2024/127207
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-28
- Filing Date
- 2024-10-25
- Publication Date
- 2025-12-04
AI Technical Summary
When there are many files on the external storage device, the Android native media scanning service is slow, resulting in slow loading of media file information.
A binary search algorithm is used to traverse the target directory of the external storage device. A parsing thread pool and a storage thread in a concurrent execution mode are used to process the file information to be parsed. The target identifier is generated to update the media database by batch processing the copies in the operation array.
It improves the speed of media scanning tasks, increases the speed of media file information loading, and cleans up redundant data through data maintenance services, reducing resource waste and improving the reliability and efficiency of the media database.
Smart Images

Figure CN2024127207_04122025_PF_FP_ABST
Abstract
Description
Media scanning task execution method, apparatus, equipment and media
[0001] Citation of relevant applications
[0002] This disclosure claims the entire benefits of Chinese Patent Application No. 202410678140.8, filed on May 28, 2024 with the State Intellectual Property Office of the People's Republic of China, entitled "Method, Apparatus, Device and Medium for Performing Media Scanning Tasks", the entire contents of which are incorporated herein by reference.
[0003] field
[0004] This disclosure generally relates to the field of multimedia playback technology, and more specifically to methods, apparatus, devices and media for performing media scanning tasks.
[0005] background
[0006] Android, with its open-source nature, high scalability, and rich ecosystem, has become the preferred operating system for current IVI (In-Vehicle Infotainment) systems. Media scanning service is a crucial component of the Android multimedia system. When the Android system boots up or an external storage device is connected, the system scans the media files in the corresponding storage space of the external storage device and stores the relevant information in the vehicle's media database. Upper-layer applications can directly query the media database to retrieve multimedia file information and display it to the user as needed.
[0007] Android's native media scanning service is deployed in the system as an app (MediaProvider.apk). The current main technical solution for this service is as follows: When the vehicle's infotainment system powers on or an external storage device is connected, it receives a media scanning broadcast and initiates a scanning service for the storage space. A unique identifier ID is generated for the first-time connection to the external storage device. The scanning service then traverses the directories in the storage space, parses each file in the directory, and performs media database operations on the file data under that identifier ID. However, when there are many files on the external storage device, the Android native media scanning service in the vehicle's infotainment system is slow, resulting in slow media file loading speeds.
[0008] Overview
[0009] Firstly, this disclosure relates to a method for performing media scanning tasks, which includes:
[0010] The media scanning service is triggered based on the connection operation of the external storage device, and the binary search algorithm is used to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory.
[0011] Obtain the first file information of each media file in the target subdirectory, filter out the file information to be parsed that does not match the file information currently stored in the media database from the first file information, and store the file information to be parsed in the first queue;
[0012] The file information to be parsed is obtained from the first queue and stored in the parsing thread pool so that the parsing thread pool can parse the file information to obtain parsed file information. The parsed file information is then used to generate a database operation object using the storage thread, and the database operation object is stored in the second queue. The parsing thread pool and the storage thread are executed in a concurrent execution mode.
[0013] The database operation objects in the second queue are sequentially saved to the operation array, and the copies in the operation array are processed in batches to generate target identifiers corresponding to the copies. The target identifiers are then saved to the third queue.
[0014] The media file information in the media database is updated based on the target identifier in the third queue to complete the media scanning task.
[0015] In some implementations, the media scanning task execution method further includes:
[0016] Receive device start command from vehicle-mounted equipment; and
[0017] The data maintenance service is activated according to the device startup command, so that the data maintenance service can clean up the target media data in the media database when the vehicle device is in the target state.
[0018] In some implementations, cleaning the target media data in the media database includes:
[0019] Based on a preset time interval, target media data with an unused time greater than a first preset threshold is selected from the media database, and the target media data is then cleaned up.
[0020] In some implementations, the step of using a binary search algorithm to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory includes:
[0021] The current subdirectory is determined in the target directory of the external storage device, and a binary search algorithm is used to determine whether the current subdirectory exists in the preset scanning strategy file;
[0022] If the current subdirectory does not exist in the preset scanning strategy file, then the current subdirectory is determined to be the target subdirectory.
[0023] In some implementations, after determining whether the current subdirectory exists in the preset scanning strategy file using a binary search algorithm, the method further includes:
[0024] If the current subdirectory exists in the preset scanning strategy file, then determine whether the current subdirectory exists in the preset non-scanned directory list;
[0025] If the current subdirectory exists in the preset non-scanned directory list, then the current subdirectory is determined to be the target subdirectory;
[0026] If the current subdirectory does not exist in the preset non-scanned directory list, then determine whether the preset non-scanned directory list is empty;
[0027] If the preset non-scanned directory list is empty, then the current subdirectory is determined to be the target subdirectory;
[0028] If the preset non-scanned directory list is not empty, then it is determined whether the current subdirectory exists in the preset forced scanned directory list. If the current subdirectory exists in the preset forced scanned directory list, the current subdirectory is determined to be the target subdirectory.
[0029] In some implementations, the step of filtering out file information to be parsed that does not match the file information currently stored in the media database from the first file information includes:
[0030] The first file information is divided into first media file information and second media file information; wherein, the first media file information is the corresponding media file information that does not exist in the media database, and the second media file information is the corresponding media file information that exists in the media database;
[0031] Determine the second file information stored in the media database that corresponds to the second media file information, and filter out the third media file information that is inconsistent with the second file information from the second media file information; and
[0032] The first media file information and the third media file information are identified as the file information to be parsed.
[0033] In some implementations, the step of sequentially saving copies of the database operation objects in the second queue to the operation array includes:
[0034] Copy the current database operation object in the second queue to obtain a copy of the current database operation object, save the copy to the operation array, and delete the current database operation object from the second queue;
[0035] Accordingly, the batch processing of the copies in the operation array to generate a target identifier corresponding to the copy, and saving the target identifier to the third queue, includes:
[0036] Determine whether the current condition is met; wherein, the preset condition is that all the files to be parsed in the first queue have been parsed and the second queue is empty;
[0037] If the current preset condition is not met, the number of replicas currently stored in the operation array is determined. If the number of replicas is equal to the second preset threshold, all replicas in the operation array are processed to generate a target identifier corresponding to each replica. The target identifier is saved to the third queue, and then the operation array is cleared. If the number of replicas is less than the second preset threshold, the process jumps back to the step of determining whether the current preset condition is met.
[0038] If the preset conditions are met, all copies in the operation array are processed to save the generated target identifier to the third queue, and then the operation array is cleared.
[0039] Secondly, this disclosure relates to a media scanning task execution apparatus, which includes:
[0040] The directory scanning module is configured to trigger a media scanning service based on the connection operation of the external storage device, and use a binary search algorithm to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory;
[0041] The information filtering module is configured to obtain the first file information of each media file in the target subdirectory, filter out the file information to be parsed from the first file information that does not match the file information currently stored in the media database, and store the file information to be parsed in the first queue;
[0042] The information parsing module is configured to obtain the file information to be parsed from the first queue and store it in the parsing thread pool, so that the parsing thread pool can parse the file information to be parsed to obtain parsed file information, and use the storage thread to store the parsed file information as a database operation object in the second queue; wherein, the parsing thread pool and the storage thread are executed in a concurrent execution mode;
[0043] The identifier generation module is configured to sequentially save copies of the database operation objects in the second queue to the operation array, and batch process the copies in the operation array to generate target identifiers corresponding to the copies, and save the target identifiers to the third queue;
[0044] The information update module is configured to update the media file information in the media database based on the target identifier in the third queue in order to complete the media scanning task.
[0045] Thirdly, this disclosure relates to electronic devices, including:
[0046] Memory, configured to store computer programs;
[0047] A processor configured to execute the computer program to implement the disclosed media scanning task execution method.
[0048] Fourthly, this disclosure relates to a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the media scanning task execution method described in this disclosure.
[0049] In some implementations, after the media scanning service is started, a binary search algorithm is used to traverse and scan each subdirectory in the target directory, which can speed up the directory scanning speed. Furthermore, this disclosure uses a parsing thread pool and a storage thread to complete the parsing of the file information to be parsed. The use of multi-threaded concurrent processing can improve scanning efficiency. Batch processing of copies in the operation array can reduce resource waste and improve processing efficiency compared to piecemeal processing. In this way, this disclosure can improve the execution speed of media scanning tasks, thereby improving the loading speed of media file information.
[0050] Brief description of the attached figures
[0051] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0052] Figure 1 is a flowchart of a media scanning task execution method according to an embodiment of the present disclosure;
[0053] Figure 2 is a schematic diagram of redundant data cleanup according to an embodiment of this disclosure;
[0054] Figure 3 is a flowchart of a catalog scanning process according to an embodiment of this disclosure;
[0055] Figure 4 is a flowchart of document information filtering according to an embodiment of this disclosure;
[0056] Figure 5 is a schematic diagram of a file information parsing process according to an embodiment of the present disclosure;
[0057] Figure 6 is a flowchart of an embodiment of the present disclosure for generating an identifier;
[0058] Figure 7 is a schematic diagram of a media scanning task execution device according to an embodiment of the present disclosure; and
[0059] Figure 8 is a structural diagram of an electronic device according to an embodiment of the present disclosure.
[0060] Detailed Explanation
[0061] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this disclosure.
[0062] Android's open-source nature, high scalability, and rich ecosystem make it the preferred operating system for current IVI systems. Media scanning service is a crucial component of the Android multimedia system. When the Android system boots up or an external storage device is connected, the system scans the media files in the corresponding storage space of the external storage device and stores the relevant information in the vehicle's media database. Upper-layer applications can directly query the media database to retrieve multimedia file information and display it to the user as needed.
[0063] Android's native media scanning service is deployed in the system as an app (MediaProvider.apk). The current main technical solution for this service is as follows: When the vehicle's infotainment system powers on or an external storage device is connected, it receives a media scanning broadcast and initiates a scanning service for the storage space. A unique identifier ID is generated for the newly connected external storage device. The scanning service traverses the directories in the storage space, parses each file in the directory, and then stores the file data under that identifier ID in the media database. However, when there are many files on the external storage device, the Android native media scanning service in the vehicle's infotainment system is slow, which in turn leads to slow loading of media file information.
[0064] To this end, this disclosure provides a media scanning task execution scheme to improve the media scanning task execution speed and thus increase the media file information loading speed.
[0065] Referring to Figure 1, one embodiment of this disclosure provides a media scanning task execution method, which includes:
[0066] Step S11: Trigger media scanning service based on connection operation of external storage device, and use binary search algorithm to traverse and scan each subdirectory in target directory of external storage device to obtain target subdirectory;
[0067] Step S12: Obtain the first file information of each media file in the target subdirectory, and based on the first file information, filter out the files to be parsed that do not match the files currently stored in the media database from each media file, and store the files to be parsed in the first queue;
[0068] Step S13: Obtain the file information to be parsed from the first queue and store it in the parsing thread pool so that the parsing thread pool can parse the file information to be parsed and obtain the parsed file information. Use the storage thread to generate a database operation object from the parsed file and store the database operation object in the second queue; wherein, the execution mode of the parsing thread pool and the storage thread is concurrent execution mode.
[0069] Step S14: Sequentially save the copies of the database operation objects in the second queue to the operation array, and batch process the copies in the operation array to generate target identifiers corresponding to the copies, and save the target identifiers to the third queue; and
[0070] Step S15: Update the media file information in the media database based on the target identifier in the third queue to complete the media scanning task.
[0071] In some implementations, the media scanning service is started based on the connection operation of the external storage device. When the external storage device is connected to the Android vehicle device, it receives the MEDIA_MOUNTED (media mounted) broadcast, at which point the media scanning service is started.
[0072] In some implementations, the media scanning task execution method further includes: receiving a device startup command from the vehicle-mounted device; and activating a data maintenance service according to the device startup command, so that the data maintenance service cleans up the target media data in the media database when the vehicle-mounted device is in a target state.
[0073] In some implementation schemes, as shown in the redundant data cleanup diagram in Figure 2, a device startup command is received; a data maintenance service is started according to the device startup command. This data maintenance service can clean up the target media data in the media database when the device is in the target state, that is, clean up the redundant data. Here, the target state machine is the state in which the vehicle device is charging and idle. In this way, the reliability and effectiveness of the media data can be improved, the redundant data and the data size of the media database can be reduced, thereby improving the efficiency of media database operations. Performing redundant data cleanup when the vehicle device is charging and idle can prevent the data maintenance service from preempting the computing resources of the vehicle device when it is processing other tasks.
[0074] In some implementations, cleaning the target media data in the media database includes: filtering target media data from the media database that has not been used for a longer period than a first preset threshold based on a preset time interval, and then cleaning the target media data. Target media data with an unused time exceeding the first preset threshold can be filtered from the media database and cleaned based on a preset time interval. For example, a data maintenance service performs redundant data cleanup every two hours. The purpose of the data maintenance service is to clean up redundant data in the media database, which exists in the FILES table of the media database. Redundant data can be data stored in the media database on storage devices that have not been used for a long period of time since their first use, or expired content data stored in the FILES table.
[0075] In some implementations, the step of using a binary search algorithm to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory includes: determining the current subdirectory in the target directory of the external storage device, and using a binary search algorithm to determine whether the current subdirectory exists in a preset scanning strategy file; if the current subdirectory does not exist in the preset scanning strategy file, then the current subdirectory is determined to be the target subdirectory. The preset scanning strategy file is an XML configuration file that sets the scanning strategy used during the media scanning service's scanning process. This file includes a preset non-scanned directory list and a preset non-scanned directory list. The process involves traversing and scanning each subdirectory in the target directory, sequentially treating each subdirectory as the current subdirectory, and using a binary search algorithm to determine whether the current subdirectory exists in the preset scanning strategy file; if the current subdirectory does not exist in the preset scanning strategy file, then the current subdirectory is determined to be the target subdirectory.
[0076] In some implementations, after determining whether the current subdirectory exists in the preset scanning strategy file using a binary search algorithm, the method further includes: if the current subdirectory exists in the preset scanning strategy file, then determining whether the current subdirectory exists in the preset non-scanned directory list; if the current subdirectory exists in the preset non-scanned directory list, then determining that the current subdirectory is the target subdirectory; if the current subdirectory does not exist in the preset non-scanned directory list, then determining whether the preset non-scanned directory list is empty; if the preset non-scanned directory list is empty, then determining that the current subdirectory is the target subdirectory; if the preset non-scanned directory list is not empty, then determining whether the current subdirectory exists in the preset forced scanning directory list; if the current subdirectory exists in the preset forced scanning directory list, then determining that the current subdirectory is the target subdirectory.
[0077] In some implementations, as shown in the directory scanning flowchart in Figure 3, the specific directory scanning process is as follows:
[0078] 1) If the current subdirectory exists in the preset scanning strategy file, then determine whether the current subdirectory exists in the preset non-scanned directory list;
[0079] 2) If the current subdirectory exists in the preset non-scanned directory list, then the current subdirectory is determined to be the target subdirectory;
[0080] 3) If the current subdirectory does not exist in the preset non-scanned directory list, then determine whether the preset non-scanned directory list is empty;
[0081] 3.1) If the preset non-scanned directory list is empty, then the current subdirectory is determined to be the target subdirectory;
[0082] 3.2) If the preset non-scanned directory list is not empty, then determine whether the current subdirectory exists in the preset forced scanned directory list;
[0083] 3.2.1) If the current subdirectory exists in the preset forced scan directory list, determine the current subdirectory as the target subdirectory;
[0084] 3.2.2) If the current subdirectory does not exist in the preset forced scan directory list, the current subdirectory is determined to be a non-target subdirectory;
[0085] In some implementations, after determining whether the current subdirectory is the target subdirectory or a non-target subdirectory, it is necessary to determine the next subdirectory from the target directory and then repeat the above process until all subdirectories have been scanned, that is, to obtain the judgment result for each subdirectory.
[0086] In some implementations, a singleton pattern is used to read the preset scanning strategy file. After receiving and initiating the media scanning operation, the preset scanning strategy file will be used to determine whether the current subdirectory needs to be traversed and scanned. The parsing of the preset scanning strategy file uses a binary search method to search whether the scanned directory exists in the directory strategy of the configuration file, skipping subdirectories that do not need to be scanned, thus speeding up the media scanning speed for the vehicle's built-in storage space.
[0087] In some implementations, the step of filtering out file information to be parsed that does not match the file information currently stored in the media database from the first file information includes: dividing the first file information into first media file information and second media file information; wherein, the first media file information is corresponding media file information that does not exist in the media database, and the second media file information is corresponding media file information that exists in the media database; determining the second file information stored in the media database that corresponds to the second media file information, and filtering out third media file information that is inconsistent with the second media file information from the second media file information; and determining the first media file information and the third media file information as file information to be parsed.
[0088] In some implementations, the first file information of each media file in the target subdirectory is obtained. This first file information includes the size, path, creation time, etc., of each media file. This first file information is first divided into two categories: first media file information and second media file information. The first media file information consists of media files that do not exist in the media database, while the second media file information consists of media files that do exist in the media database. For example, the first file information might be information A, information B, information C, and information D, and the media database might contain information a, information b, information c, and information f. Information A, information B, and information C correspond to information a, information b, and information c, respectively. The number of media files... The database does not contain information corresponding to information D. Therefore, the first media file information is information D, and the second media file information is information A, information B, and information C. The second file information is information a, information b, and information c. Next, information that is different from the media database is identified from the second media file information, which is the third media file information. For example, although information a in the second file information corresponds to information A, information a is different from information A. However, information b and information c in the second file information are the same as information B and information C, respectively. Therefore, information A is the third media file information. Finally, the first media file information and the third media file information are identified as the file information to be parsed, that is, information D and information A are identified as the file information to be parsed.
[0089] In some implementation schemes, as shown in the file information filtering flowchart in Figure 4, each media file in the target subdirectory is sequentially identified as the current media file. The specific process is as follows:
[0090] 1) Determine whether the media database contains information about the current second file that corresponds to the information about the current first file;
[0091] 2) If the media database does not contain information about the current second file, then the information about the current first file is used as the file information to be parsed and saved to the first queue;
[0092] 3) If the media database stores the information of the current second file, then determine whether the information of the current first file matches the information of the current second file;
[0093] 4) If a match is found, the current first file information is determined to be non-file information to be parsed, that is, the current first file information does not need to be saved to the first queue; if no match is found, the current first file information is treated as file information to be parsed and saved to the first queue.
[0094] 5) If there are untraversed file information, continue traversing; if there are no untraversed file information, complete the file information filtering process.
[0095] In some implementations, as shown in Figure 5, which illustrates the file information parsing process, multiple threads are created using a singleton pattern: a parsing thread pool and a storage thread. These threads execute concurrently, using the singleton pattern to read configuration resources. Data synchronization between threads is ensured using a producer-consumer pattern. The specific file information parsing process is as follows:
[0096] 1) Sequentially obtain the information of each file to be parsed in the first queue, and then store each file information to be parsed in the parsing thread pool in sequence until all the file information to be parsed in the first queue has been obtained; when scanning the file information to be parsed, you can always scan the first file information in the first queue, add the first file information to be parsed to the parsing thread pool, and then delete the first file information to be parsed from the first queue, that is, the original second file information to be parsed becomes the new first file information to be parsed;
[0097] 2) The parsing thread pool is responsible for parsing the received file information to be parsed in turn to obtain the parsed file information; it can be understood that the parsing operation of the media scanning service adopts the thread pool method, and the number of threads opened in the parsing operation thread pool can be configured.
[0098] 3) When the storage thread detects the existence of parsed file information, it generates a database operation object from the parsed file information and stores the database operation object in the second queue;
[0099] 4) When the parsing thread pool does not have any file information to be parsed, and the storage thread stores all parsed file information into the second queue, the file information parsing process ends.
[0100] In some implementations, the step of sequentially saving copies of the database operation objects in the second queue to the operation array includes: copying the current database operation object in the second queue to obtain a copy of the current database operation object, saving the copy to the operation array, and deleting the current database operation object from the second queue. This process is repeated sequentially, copying each database operation object, saving the copied copy to the operation array, and deleting database operation objects with existing copies from the second queue, until the second queue is empty and all files to be parsed in the first queue have been parsed. For example, each time, the first database operation object in the second queue is identified as the current database operation object, then the current database operation object is copied, the copied copy is saved to the operation array, and the current database operation object is deleted.
[0101] In some implementations, the step of batch processing the copies in the operation array to generate target identifiers corresponding to the copies and saving the target identifiers to a third queue includes: determining whether a preset condition is currently met; wherein the preset condition is that all files to be parsed in the first queue have been parsed and the second queue is empty; if the preset condition is not currently met, then determining the number of copies currently stored in the operation array; if the number of copies is equal to a second preset threshold, then processing all the copies in the operation array to generate target identifiers corresponding to each copy, saving the target identifiers to the third queue, and then clearing the operation array; if the number of copies is less than the second preset threshold, then reverting to the step of determining whether the preset condition is currently met; if the preset condition is currently met, then processing all the copies in the operation array to save the generated target identifiers to the third queue, and then clearing the operation array. Figure 6 shows a specific flowchart of identifier generation. If the file information to be parsed in the first queue has not been completely parsed and the second queue is not empty, then it is determined whether the number of currently stored replicas in the operation array is equal to a second preset threshold, for example, the second preset threshold is 32. If the number of replicas is equal to 32, then all replicas in the operation array are processed to generate target identifiers corresponding to each replica, and the target identifiers are saved to the third queue, and then the operation array is cleared. If the number of replicas is less than 32, then the step of determining whether the current condition is met is re-entered. If the current condition is met, then all replicas in the operation array are processed to save the generated target identifiers to the third queue, and then the operation array is cleared. That is to say, in this embodiment, for example, replicas in the operation array are processed in groups of 32. When the file information to be parsed in the first queue has been completely parsed and the second queue is empty, it means that all file information to be parsed has been parsed, and there are no database operation objects to be scanned in the second queue. Therefore, even if the number of replicas in the operation array is less than 32, these replicas can be processed in batches directly. In some implementations, batch processing of replicas can avoid the resource waste caused by processing replicas piecemeal and save resources.
[0102] In some implementations, after an external storage device is moved, the media database may contain data that is still present but the media file information may no longer exist. However, the target identifier stored in the third queue is consistent with the actual media file information; that is, the target identifier stored in the third queue is the most up-to-date and reliable. Therefore, updating the media file information in the media database based on the target identifier—for example, by performing deletion or modification operations—ensures that the media file information stored in the media database matches the actual media file information, guaranteeing the reliability and validity of the data in the media database.
[0103] In some implementations, after the media scanning service is started, a binary search algorithm is used to traverse and scan each subdirectory in the target directory, which can speed up the directory scanning speed. Furthermore, this disclosure uses a parsing thread pool and a storage thread to complete the parsing of the file information to be parsed. The use of multi-threaded concurrent processing can improve scanning efficiency. Batch processing of copies in the operation array can reduce resource waste and improve processing efficiency compared to the scattered processing in the prior art. In this way, this disclosure can improve the execution speed of media scanning tasks, thereby improving the loading speed of media file information.
[0104] Referring to Figure 7, this disclosure provides a media scanning task execution apparatus, which includes:
[0105] The directory scanning module 11 is configured to trigger a media scanning service based on the connection operation of the external storage device, and use a binary search algorithm to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory.
[0106] Information filtering module 12 is configured to obtain the first file information of each media file in the target subdirectory, filter out the file information to be parsed from the first file information that does not match the file information currently stored in the media database, and store the file information to be parsed in a first queue;
[0107] The information parsing module 13 is configured to obtain the file information to be parsed in the first queue and store it in the parsing thread pool, so that the parsing thread pool can parse the file information to be parsed to obtain parsed file information, and use the storage thread to store the parsed file information as a database operation object in the second queue; wherein, the execution mode of the parsing thread pool and the storage thread is concurrent execution mode;
[0108] The identifier generation module 14 is configured to sequentially save copies of the database operation objects in the second queue to an operation array, batch process the copies in the operation array to generate target identifiers corresponding to the copies, and save the target identifiers to a third queue; and
[0109] The information update module 15 is configured to update the media file information in the media database based on the target identifier in the third queue in order to complete the media scanning task.
[0110] In some implementations, after the media scanning service is started, a binary search algorithm is used to traverse and scan each subdirectory in the target directory, which can speed up the directory scanning speed. Furthermore, this disclosure uses a parsing thread pool and a storage thread to complete the parsing of the file information to be parsed. The use of multi-threaded concurrent processing can improve scanning efficiency. Batch processing of copies in the operation array can reduce resource waste and improve processing efficiency compared to the scattered processing in the prior art. In this way, this disclosure can improve the execution speed of media scanning tasks, thereby improving the loading speed of media file information.
[0111] This disclosure also provides an electronic device. Figure 8 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content of the figure should not be construed as limiting the scope of use of this disclosure.
[0112] Figure 8 is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure, which may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, which is loaded and executed by the processor 21 to implement the media scanning task execution method performed by the electronic device according to this disclosure.
[0113] In some implementations, power supply 23 is configured to provide operating voltage to various hardware devices on the electronic device; communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this disclosure, and is not specifically limited here; input / output interface 25 is configured to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0114] In some implementations, processor 21 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 21 may be implemented using at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). In some implementations, processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is configured to process data in the wake-up state; the coprocessor is a low-power processor configured to process data in the standby state. In some implementations, processor 21 may integrate a GPU (Graphics Processing Unit), which is configured to render and draw the content required to be displayed on the screen. In some implementations, processor 21 may also include an AI (Artificial Intelligence) processor configured to handle computational operations related to machine learning.
[0115] In some implementations, the memory 22 serves as a carrier for resource storage and may be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon include an operating system 221, computer programs 222, and data 223, etc., and the storage method may be temporary storage or permanent storage.
[0116] In some embodiments, the operating system 221 is used to manage and control various hardware devices and computer programs 222 on the electronic device to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system 221 can be Windows, Unix, Linux, etc. In addition to including computer programs capable of performing the media scanning task execution method described in this disclosure, the computer program 222 may further include computer programs capable of performing other specific tasks. In some embodiments, the data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.
[0117] This disclosure also provides a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the media scanning task execution method described in this disclosure. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0118] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0119] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure. The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly in hardware, software modules executed by a processor, or a combination of both. The software module may be located in random access memory (RAM), memory, read-only memory (ROM), electrically programmable EPROM (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable disks, CD-ROMs (Compact Disc Read-Only Memory), or any other form of storage medium known in the art.
[0120] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0121] The media scanning task execution method, apparatus, device, and medium provided in this disclosure have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this disclosure. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.
Claims
1. A media scanning task execution method, which includes: The media scanning service is triggered based on the connection operation of the external storage device, and the binary search algorithm is used to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory. Obtain the first file information of each media file in the target subdirectory, filter out the file information to be parsed that does not match the file information currently stored in the media database from the first file information, and store the file information to be parsed in the first queue; The file information to be parsed is obtained from the first queue and stored in the parsing thread pool so that the parsing thread pool can parse the file information to obtain parsed file information. The parsed file information is then used to generate a database operation object using the storage thread, and the database operation object is stored in the second queue. The parsing thread pool and the storage thread are executed in a concurrent execution mode. The database operation objects in the second queue are sequentially saved to the operation array, and the copies in the operation array are processed in batches to generate target identifiers corresponding to the copies. The target identifiers are then saved to the third queue. The media file information in the media database is updated based on the target identifier in the third queue to complete the media scanning task.
2. The media scanning task execution method as described in claim 1, further comprising: Receive device start command from vehicle-mounted equipment; as well as The data maintenance service is activated according to the device startup command, so that the data maintenance service can clean up the target media data in the media database when the vehicle device is in the target state.
3. The media scanning task execution method as described in claim 2, wherein cleaning the target media data in the media database includes: Based on a preset time interval, target media data with an unused time greater than a first preset threshold is selected from the media database, and the target media data is then cleaned up.
4. The media scanning task execution method according to any one of claims 1 to 3, wherein the method of traversing and scanning each subdirectory in the target directory of the external storage device using a binary search algorithm to obtain the target subdirectory includes: The current subdirectory is determined in the target directory of the external storage device, and a binary search algorithm is used to determine whether the current subdirectory exists in the preset scanning strategy file; If the current subdirectory does not exist in the preset scanning strategy file, then the current subdirectory is determined to be the target subdirectory.
5. The media scanning task execution method as described in claim 4, wherein after determining whether the current subdirectory exists in the preset scanning strategy file using a binary search algorithm, the method further includes: If the current subdirectory exists in the preset scanning strategy file, then determine whether the current subdirectory exists in the preset non-scanned directory list; If the current subdirectory exists in the preset non-scanned directory list, then the current subdirectory is determined to be the target subdirectory; If the current subdirectory does not exist in the preset non-scanned directory list, then determine whether the preset non-scanned directory list is empty; If the preset non-scanned directory list is empty, then the current subdirectory is determined to be the target subdirectory; If the preset non-scanned directory list is not empty, then it is determined whether the current subdirectory exists in the preset forced scanned directory list. If the current subdirectory exists in the preset forced scanned directory list, the current subdirectory is determined to be the target subdirectory.
6. The media scanning task execution method according to any one of claims 1 to 5, wherein filtering out the file information to be parsed from the first file information that does not match the file information currently stored in the media database includes: The first file information is divided into first media file information and second media file information; wherein, the first media file information is the corresponding media file information that does not exist in the media database, and the second media file information is the corresponding media file information that exists in the media database; Determine the second file information stored in the media database that corresponds to the second media file information, and filter out the third media file information that is inconsistent with the second file information from the second media file information; and The first media file information and the third media file information are identified as the file information to be parsed.
7. The media scanning task execution method according to any one of claims 1 to 6, wherein sequentially saving copies of the database operation objects in the second queue to the operation array includes: Copy the current database operation object in the second queue to obtain a copy of the current database operation object, save the copy to the operation array, and delete the current database operation object from the second queue; Accordingly, the batch processing of the copies in the operation array to generate a target identifier corresponding to the copy, and saving the target identifier to the third queue, includes: Determine whether the current condition is met; wherein, the preset condition is that all the files to be parsed in the first queue have been parsed and the second queue is empty; If the current preset condition is not met, the number of replicas currently stored in the operation array is determined. If the number of replicas is equal to the second preset threshold, all replicas in the operation array are processed to generate a target identifier corresponding to each replica. The target identifier is saved to the third queue, and then the operation array is cleared. If the number of replicas is less than the second preset threshold, the process jumps back to the step of determining whether the current preset condition is met. If the preset conditions are met, all copies in the operation array are processed to save the generated target identifier to the third queue, and then the operation array is cleared.
8. A media scanning task execution device, comprising: The directory scanning module is configured to trigger a media scanning service based on the connection operation of the external storage device, and use a binary search algorithm to traverse and scan each subdirectory in the target directory of the external storage device to obtain the target subdirectory; The information filtering module is configured to obtain the first [number] media file from each media file in the target subdirectory. The system retrieves file information and filters out file information that does not match the currently stored file information in the media database, storing the file information to be parsed in a first queue. The information parsing module is configured to obtain the file information to be parsed from the first queue and store it in the parsing thread pool, so that the parsing thread pool can parse the file information to be parsed to obtain parsed file information, and use the storage thread to store the parsed file information as a database operation object in the second queue; wherein, the parsing thread pool and the storage thread are executed in a concurrent execution mode; The identifier generation module is configured to sequentially save copies of the database operation objects in the second queue to an operation array, batch process the copies in the operation array to generate target identifiers corresponding to the copies, and save the target identifiers to a third queue; and The information update module is configured to update the media file information in the media database based on the target identifier in the third queue in order to complete the media scanning task.
9. Electronic equipment, including: Memory, configured to store computer programs; A processor configured to execute the computer program to implement the media scanning task execution method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the media scanning task execution method of any one of claims 1 to 7.
Citation Information
Patent Citations
Method for rapidly scanning media files and set top box
CN105744343A
Scanning method and related equipment
CN111881305A
File scanning method and device, terminal equipment and storage medium
CN114706825A
Multimedia file scanning method and device and electronic equipment
CN115344406A
Media scanning task execution method and device, equipment and medium
CN118331935A