Media file data synchronization method and system, terminal and storage medium
By hash value comparison and synchronization processing of the video file and database media data of the dash recorder, the problems of resource waste and file mismatch in the existing technology are solved, and efficient data synchronization and system fluency are achieved.
Patent Information
- Application Number
- CN202411762464.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-28
AI Technical Summary
The prior art consumes a lot of resources when scanning and parsing media files for driving videos, and may cause mismatch between the files and database data when unplugging the TF card.
By obtaining the target video file of the driving recorder and the target media data of the database, preprocessing is performed separately to obtain the hash value, and the file consistency is judged based on the hash value, and if it is inconsistent, synchronization is performed. This method adopts the time-grained comparison method to reduce resource waste, improve system fluency, and achieve accurate synchronization when unplugging and plugging in TF cards.
It effectively reduces resource waste, improves system fluency, and solves the problem of mismatch between files and database data when unplugging TF cards, achieving accurate data synchronization.
Smart Images

Figure CN119728715A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data synchronization, and in particular to a method, system, terminal and computer-readable storage medium for synchronizing data of media files. Background Art
[0002] With the rapid development of navigation technology, in-vehicle navigation applications are becoming more and more widespread, especially in-vehicle Android terminals, which have a wide audience; in-vehicle Android terminals refer to multimedia control systems with Android operating systems, and their appearance includes streaming media rearview mirrors and large-screen car computers. Such devices generally have the function of recorders, and support loop recording using external memory cards or built-in high-speed flash. Unlike ordinary Android phones, such devices will continuously write a large amount of media data and generate video files during their working cycle; and the media file scanning service built into the Android system will frequently scan the memory card to generate the corresponding database. When it is necessary to access these files on the device itself, the database can be quickly read and the files can be displayed, for example, displaying information such as file lists in the device album.
[0003] Driving record videos are generally generated as files named with time and with fixed recording duration. For example, a 3-minute looping video generates a video file every three minutes, and there may be thousands of video files in the loop directory. However, it takes a lot of resources to parse all of them. In addition, the native Android system will scan all media files when the memory card is plugged in and out and the system is woken up, which will consume a lot of CPU and IO (Input Output) resources, causing the system to freeze and become unresponsive for a short period of time. In vehicle-mounted application scenarios, hot plugging of TF (TransFlash, storage) cards is a common scenario, but each plugging and unplugging of the card may cause the actual file to not match the data recorded in the database.
[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0005] The main purpose of the present invention is to provide a data synchronization method, system, terminal and storage medium for media files, aiming to solve the problem in the prior art that when scanning and parsing the media files of driving recording videos, a large amount of resources are consumed, resulting in system freezes and unresponsiveness for a short period of time, and the actual files will not match the data recorded in the database when the TF card is pulled out and inserted.
[0006] To achieve the above object, the present invention provides a method for synchronizing media file data, the method comprising the following steps:
[0007] Obtaining a target video file of the driving recorder and target media data from a database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value;
[0008] Whether the target video file is consistent with the target media data is determined according to the first hash value and the second hash value; if the target video file is inconsistent with the target media data, the target video file is synchronized to the database.
[0009] Optionally, the method for synchronizing media file data, wherein the step of acquiring a target video file of a driving recorder and target media data of a database, and preprocessing the target video file and the target media data respectively to obtain the target video data and the target media data, specifically includes:
[0010] When it is detected that the user performs a preset operation, a target video file of the driving recorder and target media data of the database are obtained, wherein the preset operation is any one of a power-on operation, a system wake-up operation, and a card change operation;
[0011] Segment the target video file according to the time granularity to obtain a plurality of segmented video files, concatenate the file names of all the segmented video files to obtain a first string, and calculate a hash value of the first string to obtain a first hash value;
[0012] The target media data is segmented according to the time granularity to obtain a plurality of segmented media data, the data names of all the segmented media data are concatenated to obtain a second character string, and a hash value of the second character string is calculated to obtain a second hash value.
[0013] Optionally, the method for synchronizing media file data, wherein when it is detected that the user performs a preset operation, obtaining the target video file of the driving recorder and the media data of the target database, specifically includes:
[0014] When it is detected that the user performs a preset operation, a file scan is performed on the circular directory of the driving recorder to obtain a plurality of video files, and all the video files are sorted according to the file time to obtain a first sorting result, and the video files corresponding to the head and the tail in the first sorting result are removed to obtain a target video file;
[0015] The database is queried to obtain a plurality of media data, and all the media data are sorted according to the data time to obtain a second sorting result, and the media data corresponding to the head and the tail of the second sorting result are removed to obtain the target media data.
[0016] Optionally, in the method for synchronizing media file data, the step of determining whether the target video file and the target media data are consistent according to the first hash value and the second hash value specifically includes:
[0017] Performing a numerical comparison on the first hash value and the second hash value to obtain a comparison result, and determining whether the target video file and the target media data are consistent according to the comparison result;
[0018] If the comparison result is that the first hash value and the second hash value are inconsistent, determining that the target video file and the target media data are inconsistent;
[0019] If the comparison result is that the first hash value is consistent with the second hash value, it is determined that the target video file is consistent with the target media data.
[0020] Optionally, the method for synchronizing media file data, wherein if the target video file is inconsistent with the target media data, synchronizing the target video file to a database, specifically includes:
[0021] If the target video file is inconsistent with the target media data, a data synchronization instruction is generated, and the target video file and the target media data are divided into time granularities according to the data synchronization instruction to obtain multiple video file granularities and multiple media data granularities;
[0022] All the video file granularities are matched with all the media data granularities to obtain a matching result, a corresponding synchronization method is determined according to the matching result, and the target video file is synchronized to the database according to the synchronization method.
[0023] Optionally, in the data synchronization method of the media file, the synchronization mode includes local synchronization and global synchronization;
[0024] Determining the corresponding synchronization mode according to the matching result specifically includes:
[0025] If the matching result is that the matching degree between the video file granularity and the media data granularity is less than or equal to a preset ratio, determining that the synchronization mode is local synchronization;
[0026] If the matching result is that the matching degree between the video file granularity and the media data granularity is greater than a preset ratio, it is determined that the synchronization mode is global synchronization.
[0027] Optionally, the method for synchronizing media file data, wherein synchronizing the target video file to a database according to the synchronization method, specifically includes:
[0028] If the synchronization mode is local synchronization, unmatched media data in the database is deleted according to the matching result, and corresponding video data is inserted into the database;
[0029] If the synchronization mode is global synchronization, generating global data synchronization reminder information according to the matching result, and reminding the user to synchronize data according to the global data synchronization reminder information;
[0030] If it is detected that the user confirms the synchronization data, the database is cleared and all the target video files are inserted into the database.
[0031] Optionally, in the method for synchronizing media file data, the media file data synchronization system comprises:
[0032] A data processing module, used for acquiring a target video file of the driving recorder and target media data of the database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value;
[0033] A data synchronization module is used to determine whether the target video file is consistent with the target media data according to the first hash value and the second hash value, and if the target video file is inconsistent with the target media data, synchronize the target video file to the database.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a data synchronization program for media files stored in the memory and executable on the processor, and when the data synchronization program for media files is executed by the processor, the steps of the media file data synchronization method as described above are implemented.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data synchronization program for media files, and when the data synchronization program for media files is executed by a processor, the steps of the media file data synchronization method described above are implemented.
[0036] In the present invention, the target video file of the driving recorder and the target media data of the database are obtained, and the target video file and the target media data are preprocessed respectively to obtain a first hash value and a second hash value; according to the first hash value and the second hash value, it is determined whether the target video file and the target media data are consistent, and if the target video file and the target media data are inconsistent, the target video file is synchronized to the database. The present invention compares data through the time granularity comparison method, reduces the waste of resources, thereby improving the fluency of the system, and can accurately synchronize according to the scene, solving the problem of mismatch between the actual file and the data recorded in the database when plugging and unplugging the TF card. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 is a flow chart of a preferred embodiment of the method for synchronizing media file data of the present invention;
[0038] Figure 2 It is a schematic diagram of the overall solution flow of the media file data synchronization method of the present invention;
[0039] Figure 3 It is an overall flow chart of a preferred embodiment of the method for synchronizing media file data of the present invention;
[0040] Figure 4 is a structural diagram of a preferred embodiment of the data synchronization system for media files of the present invention;
[0041] Figure 5 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0043] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0044] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0045] The data synchronization method of the media file described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the data synchronization method of the media file includes the following steps:
[0046] Step S10: Acquire a target video file of the driving recorder and target media data from a database, and preprocess the target video file and the target media data respectively to obtain a first hash value and a second hash value.
[0047] The step S10 comprises:
[0048] Step S11, when it is detected that the user performs a preset operation, a target video file of the driving recorder and target media data of the database are obtained, wherein the preset operation is any one of a power-on operation, a system wake-up operation, and a card change operation;
[0049] Step S12: segmenting the target video file according to the time granularity to obtain a plurality of segmented video files, concatenating the file names of all the segmented video files to obtain a first string, and calculating a hash value of the first string to obtain a first hash value;
[0050] Step S13: segment the target media data according to the time granularity to obtain a plurality of segmented media data, concatenate the data names of all the segmented media data to obtain a second string, and calculate the hash value of the second string to obtain a second hash value.
[0051] Specifically, in order to reduce the waste of resources when reading the corresponding data and solve the problem of mismatch between the actual file and the data recorded in the database when plugging and unplugging the TF card, in an embodiment of the present invention, Figure 2As shown, accurate synchronization according to the scene is achieved through the file synchronization service, and user control is achieved during the synchronization process. The specific implementation process is that when it is detected that the user performs a preset operation, such as a power-on operation, a system wake-up operation, and a card change operation, there are four card change operations. The first is to replace the TF card, the second is to take out the TF card, read and copy it, and then put it back, the third is to take out the TF card, delete and add some files, and then put it back, and the fourth is to use two TF cards in turn; the circular directory of the driving recorder (with a TF card inserted) is scanned for files to obtain multiple video files, wherein the circular directory refers to the directory of the video in the driving recorder, and this directory will be cyclically overwritten. For example, if you choose to record a video file every 3 minutes, then continuously record a 20 files will be generated in one hour. When the continuous recording time is long, the number of files and the total size will always reach the capacity limit of the memory card. Therefore, when a new file is generated, the earliest stored file needs to be deleted, so as to realize a circular directory, wherein the circular directory stores real video files; and sort all the video files according to the file time to obtain a first sorting result, remove the video files corresponding to the first and last parts of the first sorting result, and obtain the target video file, wherein the purpose of removing the first and last files is to prevent interference and reduce errors, because the earliest stored file may be deleted at any time, and the latest stored file may be an incomplete file obtained due to the incomplete recording, therefore, during the circular recording, the first and last files are variables. Afterwards, the database is queried to obtain multiple media data, wherein the database stores some key information of the video file, which generally includes the file name, path, size, start time, recording duration, etc.; the database can quickly access the real video file; and sort all the media data according to the data time to obtain a second sorting result, remove the media data corresponding to the first and last parts of the second sorting result, and obtain the target media data.
[0052] Afterwards, it is necessary to determine whether the target media file and the target media data have changed. The purpose is to compare the actual file, that is, the target media file and the file information recorded in the database, that is, whether the target media data is consistent. If they are consistent, no synchronization is required; if they are inconsistent, a synchronous update is required. For example, if a new chapter is added to an article, the corresponding index needs to be added to the directory. If a chapter is deleted, the corresponding index in the directory needs to be deleted; then, the target video file is segmented according to the time granularity to obtain multiple segmented video files, wherein the time granularity means that the 24 hours of a day can be divided into 24 granularities, and each granularity represents one hour. In the present invention, each video file is located at which granularity according to the created file name, that is, the generation time. For example, the video file 20240101162050.mp4 is located at the granularity 16 of the day. All videos on the day All the files generated at 16 o'clock belong to this granularity; the file names of all the segmented video files are concatenated to obtain a first string, and the hash value of the first string is calculated by the SHA-1 algorithm to obtain a first hash value, wherein the purpose of calculating the hash value is to determine whether the corresponding data has changed by comparing whether the string has changed; similarly, the target media data is segmented according to the time granularity to obtain multiple segmented media data, the data names of all the segmented media data are concatenated to obtain a second string, and the hash value of the second string is calculated to obtain a second hash value.
[0053] Step S20: determining whether the target video file is consistent with the target media data according to the first hash value and the second hash value; if the target video file is inconsistent with the target media data, synchronizing the target video file to the database.
[0054] The step S20 comprises:
[0055] Step S21: numerically compare the first hash value and the second hash value to obtain a comparison result, and determine whether the target video file and the target media data are consistent according to the comparison result;
[0056] Step S22: If the comparison result is that the first hash value is inconsistent with the second hash value, it is determined that the target video file and the target media data are inconsistent;
[0057] Step S23: If the comparison result is that the first hash value is consistent with the second hash value, it is determined that the target video file is consistent with the target media data;
[0058] Step S24: if the target video file is inconsistent with the target media data, a data synchronization instruction is generated, and the target video file and the target media data are divided into time granularities according to the data synchronization instruction to obtain a plurality of video file granularities and a plurality of media data granularities;
[0059] Step S25: Match all the video file granularities with all the media data granularities to obtain a matching result, determine a corresponding synchronization method according to the matching result, and synchronize the target video file to the database according to the synchronization method.
[0060] Specifically, in an embodiment of the present invention, after obtaining the first hash value and the second hash value, a comparison process needs to be performed, specifically, the first hash value and the second hash value are numerically compared to obtain a comparison result, and whether the target video file and the target media data are consistent is determined according to the comparison result; if the comparison result is that the first hash value and the second hash value are consistent, then the target video file and the target media data are determined to be consistent, indicating that no synchronization process is required, and the TF card may only be hot-plugged or taken out for reading and then put back; if the comparison result is that the first hash value and the second hash value are inconsistent, then the target video file and the target media data are determined to be consistent. If the target video file and the target media data are inconsistent, data synchronization processing is required to generate a data synchronization instruction, and the target video file is divided into time granularities according to the data synchronization instruction to obtain multiple video file granularities. The target media data is also divided into time granularities according to the data synchronization instruction to obtain multiple media data granularities; then, all the video file granularities are matched with all the media data granularities to obtain a matching result, in order to select the best synchronization method and improve synchronization efficiency; the corresponding synchronization method is determined according to the matching result, and the target video file is synchronized to the database according to the synchronization method.
[0061] Wherein, the synchronization mode includes local synchronization and global synchronization. If the matching result is that the matching degree between the video file granularity and the media data granularity is less than or equal to a preset ratio (for example, 50%), the synchronization mode is determined to be local synchronization; if the matching result is that the matching degree between the video file granularity and the media data granularity is greater than a preset ratio, the synchronization mode is determined to be global synchronization; if the synchronization mode is local synchronization, the unmatched media data in the database is deleted according to the matching result, and the corresponding video data is obtained from the loop directory and inserted into the database to complete the synchronization process; if the synchronization mode is global synchronization, global data synchronization reminder information is generated according to the matching result, and the user is reminded to synchronize data according to the global data synchronization reminder information, so that the user decides whether to synchronize, thereby realizing the controllability of the data synchronization process; if the user is not detected to confirm the synchronization data or the user is detected to cancel the synchronization data, the data synchronization is not performed; if the user is detected to confirm the synchronization data, the database is cleared and all the target video files are inserted into the database.
[0062] The present invention compares data through a time granularity comparison method, thereby reducing waste of resources and improving the fluency of the system, and can perform accurate synchronization according to the scenario, solving the problem of mismatch between actual files and data recorded in the database when plugging and unplugging a TF card.
[0063] Furthermore, the overall flow chart of a preferred embodiment of the method for synchronizing media file data in the present invention is as follows: Figure 3 As shown, specifically:
[0064] Step S1: when it is detected that the user performs a preset operation, such as a power-on operation, a system wake-up operation, and a card change operation, a file scan is performed on the circular directory of the driving recorder to obtain multiple video files, namely, data A;
[0065] Step S2, querying the database to obtain a plurality of media data, namely, book B;
[0066] Step S3, sorting all the video files to obtain a first sorting result, removing the video files corresponding to the first and the last in the first sorting result to obtain a target video file, sorting all the media data to obtain a second sorting result, removing the media data corresponding to the first and the last in the second sorting result to obtain target media data, and then comparing the target video file with the target media data. If they are consistent, proceed to step S9; if they are inconsistent, proceed to step S4;
[0067] Step S4, dividing the target video file and the target media data into time granularities respectively to obtain a plurality of video file granularities and a plurality of media data granularities;
[0068] Step S5, matching and comparing all the video file granularities with all the media data granularities to obtain a matching result. If the matching result is less than or equal to a preset ratio, proceed to step S6; if the matching result is greater than the preset ratio, proceed to step S7;
[0069] Step S6: If the matching result is that the matching degree between the video file granularity and the media data granularity is less than or equal to the preset ratio, the synchronization mode is determined to be local synchronization, the unmatched media data in the database is deleted, and the corresponding video data is inserted into the database. After the insertion is completed, step S9 is entered;
[0070] Step S7: if the matching result is that the matching degree between the video file granularity and the media data granularity is greater than a preset ratio, the synchronization mode is determined to be global synchronization, and global data synchronization reminder information is generated, and the user is reminded to synchronize data according to the global data synchronization reminder information;
[0071] Step S8: If it is detected that the user confirms the synchronization data, the database is cleared and all the target video files are inserted into the database;
[0072] Step S9: complete synchronization.
[0073] Furthermore, if Figure 4 As shown, based on the above-mentioned media file data synchronization method, the present invention also provides a media file data synchronization system accordingly, wherein the media file data synchronization system includes:
[0074] A data processing module 51 is used to obtain a target video file of the driving recorder and target media data of the database, and pre-process the target video file and the target media data respectively to obtain a first hash value and a second hash value;
[0075] The data synchronization module 52 is used to determine whether the target video file and the target media data are consistent according to the first hash value and the second hash value, and if the target video file and the target media data are inconsistent, synchronize the target video file to the database.
[0076] Furthermore, if Figure 5 As shown, based on the above-mentioned method for synchronizing media file data, the present invention also provides a terminal, which includes a processor 10, a memory 20 and a display 30. Figure 5Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0077] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal, etc. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a data synchronization program 40 for media files is stored on the memory 20, and the data synchronization program 40 for media files can be executed by the processor 10, thereby realizing the data synchronization method for media files in the present application.
[0078] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code stored in the memory 20 or process data, such as executing the data synchronization method of the media file.
[0079] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components of the terminal communicate with each other via a system bus.
[0080] In one embodiment, when the processor 10 executes the data synchronization program 40 for the media files in the memory 20, the following steps are implemented:
[0081] Obtaining a target video file of the driving recorder and target media data from a database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value;
[0082] Whether the target video file is consistent with the target media data is determined according to the first hash value and the second hash value; if the target video file is inconsistent with the target media data, the target video file is synchronized to the database.
[0083] The step of acquiring a target video file of the driving recorder and target media data of the database, and preprocessing the target video file and the target media data respectively to obtain the target video data and the target media data specifically includes:
[0084] When it is detected that the user performs a preset operation, a target video file of the driving recorder and target media data of the database are obtained, wherein the preset operation is any one of a power-on operation, a system wake-up operation, and a card change operation;
[0085] Segment the target video file according to the time granularity to obtain a plurality of segmented video files, concatenate the file names of all the segmented video files to obtain a first string, and calculate a hash value of the first string to obtain a first hash value;
[0086] The target media data is segmented according to the time granularity to obtain a plurality of segmented media data, the data names of all the segmented media data are concatenated to obtain a second character string, and a hash value of the second character string is calculated to obtain a second hash value.
[0087] The method of acquiring the target video file of the driving recorder and the media data of the target database when detecting that the user performs a preset operation specifically includes:
[0088] When it is detected that the user performs a preset operation, a file scan is performed on the circular directory of the driving recorder to obtain a plurality of video files, and all the video files are sorted according to the file time to obtain a first sorting result, and the video files corresponding to the head and the tail in the first sorting result are removed to obtain a target video file;
[0089] The database is queried to obtain a plurality of media data, and all the media data are sorted according to the data time to obtain a second sorting result, and the media data corresponding to the head and the tail of the second sorting result are removed to obtain the target media data.
[0090] The determining, according to the first hash value and the second hash value, whether the target video file and the target media data are consistent specifically includes:
[0091] Performing a numerical comparison on the first hash value and the second hash value to obtain a comparison result, and determining whether the target video file and the target media data are consistent according to the comparison result;
[0092] If the comparison result is that the first hash value and the second hash value are inconsistent, determining that the target video file and the target media data are inconsistent;
[0093] If the comparison result is that the first hash value is consistent with the second hash value, it is determined that the target video file is consistent with the target media data.
[0094] If the target video file is inconsistent with the target media data, synchronizing the target video file to the database specifically includes:
[0095] If the target video file is inconsistent with the target media data, a data synchronization instruction is generated, and the target video file and the target media data are divided into time granularities according to the data synchronization instruction to obtain multiple video file granularities and multiple media data granularities;
[0096] All the video file granularities are matched with all the media data granularities to obtain a matching result, a corresponding synchronization method is determined according to the matching result, and the target video file is synchronized to the database according to the synchronization method.
[0097] Wherein, the synchronization mode includes local synchronization and global synchronization;
[0098] Determining the corresponding synchronization mode according to the matching result specifically includes:
[0099] If the matching result is that the matching degree between the video file granularity and the media data granularity is less than or equal to a preset ratio, determining that the synchronization mode is local synchronization;
[0100] If the matching result is that the matching degree between the video file granularity and the media data granularity is greater than a preset ratio, it is determined that the synchronization mode is global synchronization.
[0101] The step of synchronizing the target video file to the database according to the synchronization method specifically includes:
[0102] If the synchronization mode is local synchronization, unmatched media data in the database is deleted according to the matching result, and corresponding video data is inserted into the database;
[0103] If the synchronization mode is global synchronization, generating global data synchronization reminder information according to the matching result, and reminding the user to synchronize data according to the global data synchronization reminder information;
[0104] If it is detected that the user confirms the synchronization data, the database is cleared and all the target video files are inserted into the database.
[0105] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data synchronization program for media files, and when the data synchronization program for media files is executed by a processor, the steps of the media file data synchronization method described above are implemented.
[0106] In summary, the present invention provides a data synchronization method, system, terminal and storage medium for media files, the method comprising: obtaining a target video file of a driving recorder and target media data of a database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value; judging whether the target video file and the target media data are consistent according to the first hash value and the second hash value, and if the target video file and the target media data are inconsistent, synchronizing the target video file to the database. The present invention performs data comparison through a time granularity comparison method, reduces the waste of resources, thereby improving the fluency of the system, and can perform precise synchronization according to the scene, solving the problem of mismatch between the actual file and the data recorded in the database when plugging and unplugging the TF card.
[0107] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.
[0108] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0109] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for synchronizing media file data, characterized in that: The data synchronization method of the media file comprises: Obtaining a target video file of the driving recorder and target media data from a database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value; Whether the target video file is consistent with the target media data is determined according to the first hash value and the second hash value; if the target video file is inconsistent with the target media data, the target video file is synchronized to the database.
2. The method for synchronizing media files according to claim 1, characterized in that: The step of obtaining a target video file of the driving recorder and target media data from a database, and preprocessing the target video file and the target media data respectively to obtain the target video data and the target media data, specifically includes: When it is detected that the user performs a preset operation, a target video file of the driving recorder and target media data of the database are obtained, wherein the preset operation is any one of a power-on operation, a system wake-up operation, and a card change operation; Segment the target video file according to the time granularity to obtain a plurality of segmented video files, concatenate the file names of all the segmented video files to obtain a first string, and calculate a hash value of the first string to obtain a first hash value; The target media data is segmented according to the time granularity to obtain a plurality of segmented media data, the data names of all the segmented media data are concatenated to obtain a second character string, and a hash value of the second character string is calculated to obtain a second hash value.
3. The method for synchronizing media files according to claim 2, characterized in that: When it is detected that the user performs a preset operation, the target video file of the driving recorder and the media data of the target database are obtained, which specifically includes: When it is detected that the user performs a preset operation, a file scan is performed on the circular directory of the driving recorder to obtain a plurality of video files, and all the video files are sorted according to the file time to obtain a first sorting result, and the video files corresponding to the head and the tail in the first sorting result are removed to obtain a target video file; The database is queried to obtain a plurality of media data, and all the media data are sorted according to the data time to obtain a second sorting result, and the media data corresponding to the head and the tail of the second sorting result are removed to obtain the target media data.
4. The method for synchronizing media files according to claim 1, characterized in that: The determining, according to the first Hash value and the second Hash value, whether the target video file and the target media data are consistent specifically includes: Numerically comparing the first hash value and the second hash value to obtain a comparison result, and determining whether the target video file and the target media data are consistent according to the comparison result; If the comparison result is that the first hash value and the second hash value are inconsistent, determining that the target video file and the target media data are inconsistent; If the comparison result is that the first hash value is consistent with the second hash value, it is determined that the target video file is consistent with the target media data.
5. The method for synchronizing media file data according to claim 1, characterized in that: If the target video file is inconsistent with the target media data, synchronizing the target video file to the database specifically includes: If the target video file is inconsistent with the target media data, a data synchronization instruction is generated, and the target video file and the target media data are divided into time granularities according to the data synchronization instruction to obtain multiple video file granularities and multiple media data granularities; All the video file granularities are matched with all the media data granularities to obtain a matching result, a corresponding synchronization method is determined according to the matching result, and the target video file is synchronized to the database according to the synchronization method.
6. The method for synchronizing media file data according to claim 5, characterized in that: The synchronization mode includes local synchronization and global synchronization; Determining the corresponding synchronization mode according to the matching result specifically includes: If the matching result is that the matching degree between the video file granularity and the media data granularity is less than or equal to a preset ratio, determining that the synchronization mode is local synchronization; If the matching result is that the matching degree between the video file granularity and the media data granularity is greater than a preset ratio, it is determined that the synchronization mode is global synchronization.
7. The method for synchronizing media file data according to claim 6, characterized in that: The step of synchronizing the target video file to the database according to the synchronization method specifically includes: If the synchronization mode is local synchronization, unmatched media data in the database are deleted according to the matching result, and corresponding video data are inserted into the database; If the synchronization mode is global synchronization, generating global data synchronization reminder information according to the matching result, and reminding the user to synchronize data according to the global data synchronization reminder information; If it is detected that the user confirms the synchronization data, the database is cleared and all the target video files are inserted into the database.
8. A media file data synchronization system, characterized in that: The media file data synchronization system comprises: A data processing module, used for acquiring a target video file of the driving recorder and target media data of the database, and preprocessing the target video file and the target media data respectively to obtain a first hash value and a second hash value; A data synchronization module is used to determine whether the target video file is consistent with the target media data according to the first hash value and the second hash value, and if the target video file is inconsistent with the target media data, synchronize the target video file to the database.
9. A terminal, characterized in that: The terminal includes: a memory, a processor, and a data synchronization program for media files stored in the memory and executable on the processor. When the data synchronization program for media files is executed by the processor, the steps of the media file data synchronization method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data synchronization program for media files, and when the data synchronization program for media files is executed by a processor, the steps of the method for data synchronization of media files according to any one of claims 1 to 7 are implemented.