Storage method, device, system and the storage medium of video dataTechnical field
The present embodiments relate to mobile video monitor technical field more particularly to a kind of storage method of video data,Device, system and storage medium.
Background technology
With the fast development of automobile industry, automobile has become people and goes out indispensable walking-replacing tool.Vehicle-mounted shiftingDynamic video monitoring apparatus (i.e. automobile data recorder) is the instrument of the relevant informations such as image and sound in record vehicle travel process,It is able to record the video image and sound of running car overall process, monitoring video is recorded and is played back, can be that traffic accident etc. is unexpectedSituation provides evidence, thus automobile data recorder is widely installed in vehicle and is used.
And existing vehicle mounted mobile video monitoring device, when storing video data, continuous high frequency write-in data cause to depositThe bad block problem of storage media or video data encounter the abnormal problems such as burst power-off in write-in, and video data can be caused abnormalOr the problems such as video data loss.And vehicle mounted mobile video monitoring device be mainly used in as truck, bus, bus andIt is high for the stability requirement of data in the vehicles such as car, therefore solve the above problems and be particularly important.
Invention content
The embodiment of the present invention provides a kind of storage method of video data, device, system and storage medium, can improve and depositStore up the stability of video data.
In a first aspect, an embodiment of the present invention provides a kind of storage method of video data, this method includes:
Obtain video data;
The video data is written in storage medium;
When storage medium exception is written in the video data, if it is storage medium exception, then suspend write-in, andIt is continued to write to after repairing the storage medium;If it is video data exception, then the video data of default size is carried outCaching, is transferred to the storage medium, and continue to write to after the video data is normal by the video data of caching.
Further, before obtaining video data, further include:
The storage medium is detected, if the storage medium has exception, the storage medium is carried outIt repairs.
Further, it is described to the storage medium be detected including:
The classification of storage medium is obtained, the classification includes USB flash disk, SD card and hard disk;
The storage medium interface is detected according to the classification of the storage medium, judges the storage medium with the presence or absence of differentOften.
Further, if it is storage medium exception, then suspend write-in, and repair that the storage medium is subsequent to be continuedEnter, including:
The storage medium is unloaded, and starts detection and repairs instruction;
After the completion of storage medium reparation, reloads the storage medium and restore data write operation.
Further, described that the video data of caching is transferred to storage Jie after the video data is normalMatter, including:
After data exception is restored, the filename of the video data of caching is obtained;
The video data is transferred to the corresponding position of the storage medium according to the filename.
Further, the video data is that mobile video monitor system abnormal shutdown occurs extremely;
Correspondingly, after data exception is restored, the filename of the video data of caching is obtained, including:
When the mobile video monitor system restarting, the filename of the video data of caching is obtained.
Second aspect, the embodiment of the present invention additionally provide a kind of storage device of video data, which includes:
Video data acquisition module, for obtaining video data;
Video data writing module, for the video data to be written in storage medium;
Abnormality detection module is used for when storage medium exception is written in the video data, if it is the storage mediumIt is abnormal, then suspend write-in, and continued to write to after repairing the storage medium;If it is video data exception, then will presetThe video data of size is cached, and the video data of caching, which is transferred to the storage, after the video data is normal is situated betweenMatter, and continue to write to.
Further, further include:
Storage medium detection module, for being detected to the storage medium, if there is exception in the storage medium,Then the storage medium is repaired.
The third aspect, the embodiment of the present invention additionally provide a kind of mobile video monitor system, including memory, processor andThe computer program that can be run on a memory and on a processor is stored, further includes:Camera, for acquiring image;Wherein,The processor realizes method as described in relation to the first aspect when executing described program.
Fourth aspect, the embodiment of the present invention additionally provide a kind of computer readable storage medium, are stored thereon with computerProgram realizes method as described in relation to the first aspect when the program is executed by processor.
The embodiment of the present invention obtains video data, then writes video data into storage medium, works as video data firstWhen storage medium exception is written, if it is storage medium exception, then suspend write-in, and continued to write to after repairing storage medium, such asFruit is video data exception, then caches the video data of default size, the regarding caching after video data is normalFrequency evidence is transferred to storage medium, and continues to write to.It is abnormal for the video data write-in storage medium of different situations, take phaseThe measure answered, to avoid when continuous high frequency write-in data lead to the bad block problem of storage medium or video data in write-inWhen encountering the abnormal problems such as burst power-off, lead to video data exception or video data loss, to improve storageThe stability of video data.
Description of the drawings
Fig. 1 is a kind of flow chart of the storage method of video data in the embodiment of the present invention one;
Fig. 2 is the flow chart of the storage method of another video data in the embodiment of the present invention one;
Fig. 3 is a kind of flow chart of the storage method of video data in the embodiment of the present invention one;
Fig. 4 is a kind of structural schematic diagram of the storage device of video data in the embodiment of the present invention two;
Fig. 5 is a kind of structural schematic diagram of mobile video monitor system in the embodiment of the present invention three.
Specific implementation mode
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouchedThe specific embodiment stated is used only for explaining the present invention rather than limitation of the invention.It also should be noted that in order to justOnly the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
Fig. 1 is a kind of flow chart of the storage method for video data that the embodiment of the present invention one provides, and the present embodiment can fitThe case where for being stored to mobile video data, this method can be executed by the storage device of video data, the deviceIt can be integrated in movable video monitoring equipment, such as automobile data recorder.As shown in Figure 1, this method specifically comprises the following steps.
Step 110, video data is obtained.
Wherein, video data can be the video data that at least one camera on movable video monitoring equipment is recorded.In the present embodiment, the mode for obtaining video data can be after camera shoots current scene, by the video of shootingBy coding to obtain video data.
Step 120, it writes video data into storage medium.
Wherein, storage medium can carry out subregion based on FAT32 file formats, and the principle of FAT32 can be in FAT tableIt is carried out using internal fragmentation technology when being compared, is small memory block bulk memory fragment.In the present embodiment, by video dataThe mode of write-in storage medium can be, first by the video data packet that partitioning video data is default size, then by oneA video data packet is respectively written into according to the chronological order of recording in storage medium.
Step 130, when storage medium exception is written in video data, if it is storage medium exception, then suspend write-in, andIt is continued to write to after repairing storage medium.
Wherein, storage medium can be that storage medium bad block problem occurs extremely, and storage medium is become from writable patternReading mode, i.e. video data can not be written in storage medium.In the present embodiment, if video data write-in storage medium is abnormalFor storage medium exception, then suspends write operation, storage medium is detected and is repaired, after the completion of reparation, continue to storageVideo data is written in medium.
Step 140, if it is video data exception, then the video data of default size is cached, until video countsAccording to the video data of caching is transferred to storage medium after normal, and continue to write to.
Wherein, video data can be that mobile video monitor system abnormal shutdown occurs extremely, and system exception is caused to shut downThe reason of may include abnormal power-down, spread of voltage etc..Default size can be configured according to the attribute of storage medium, in advanceIf the video data of size can be the current video data packet for being about to that storage medium is written.In the present embodiment, work as video dataWhen abnormal, the video data of default size is cached into fixed flash memory (FLASH) first, will be delayed after video data is normalIt is transferred in storage medium in the presence of the video data in fixed FLASH, video data will be got by, which then proceeding to, is written to storageIn medium.
The technical solution of the present embodiment obtains video data, then writes video data into storage medium first, when regardingWhen frequency is according to write-in storage medium exception, if it is storage medium exception, then suspend write-in, and repair that storage medium is subsequent to be continuedEnter, if it is video data exception, then caches the video data of default size, it will caching after video data is normalVideo data be transferred to storage medium, and continue to write to.It is abnormal for the video data write-in storage medium of different situations, it adoptsCorresponding measure is taken, to avoid causing the bad block problem of storage medium or video data writing when continuous high frequency write-in dataIt is fashionable encounter burst power-off etc. abnormal problems when, lead to video data exception or video data loss, to improveStore the stability of video data.
Optionally, further include following steps before obtaining video data:Storage medium is detected, if storageThere is exception in medium, then repaired to storage medium.
Wherein, can obtain the classification of storage medium to the mode that storage medium is detected, classification includes USB flash disk, SDCard and hard disk detect storage medium interface according to the classification of storage medium, judge storage medium with the presence or absence of abnormal.Storage mediumIn the presence of abnormal type may include storage medium there are bad block, cluster block chaining is incorrect and storage medium format is incorrect etc..
Under this application scene, illustratively, after the completion of operating system electrifying startup, the classification of storage medium is detected first,Then the interface for detecting storage medium of all categories is detected the interface of each classification storage medium, if storage medium is depositedIt in exception, is then repaired, until all storage medium reparations are completed, restarts mobile video monitor system, regarded to obtainFrequency evidence.
Storage medium is detected and is repaired before obtaining video data, to ensure writing video data into storageWhen medium, there is no exceptions for storage medium, can improve the reliability of storage video data.
Optionally, Fig. 2 is the flow chart of the storage method for another video data that the embodiment of the present invention one provides, and is such as schemedShown in 2, step 130:If it is storage medium exception, then suspend write-in, and continued to write to after repairing the storage medium,It can be implemented by following manner:
Step 131, storage medium is unloaded, and starts detection and repairs instruction.
Wherein, unloading storage medium can pop up storage medium from mobile video monitor system.In the present embodiment,Storage medium starts detection and repairs instruction, to be detected and repair to storage medium after mobile video monitor system unloading.
Step 132, it after the completion of storage medium reparation, reloads storage medium and restores data write operation.
Specifically, after the completion of storage medium is repaired, storage medium is reloaded into mobile video monitor system, andReply data write operation.
Under this application scene, when extremely video data can not be written in storage medium, start modular program of meeting an urgent need first, soAfter unload storage medium, and start detection repair instruction, storage medium is detected and is repaired, after the completion of reparation, again plusStorage medium is carried, to complete modular program of meeting an urgent need, restores normal data write-in.
The technical solution of the present embodiment, when storage medium exception, pause write-in, and carry out storage medium detection and repairIt is multiple, the reliability of storage video data can be improved.
Optionally, Fig. 3 is the flow chart of the storage method for another video data that the embodiment of the present invention one provides, and is such as schemedShown in 3, step 140:The video data of caching is transferred to the storage medium after the video data is normal, can be passed throughFollowing manner is implemented:
Step 141, after data exception is restored, the filename of the video data of caching is obtained.
In the present embodiment, data exception can be that mobile video monitor system abnormal shutdown occurs, since hardware anomalies are closedSystem operation time is shorter after machine, and mobile video data are larger, and FAT32 file system first delays video data at this timeIt deposits, the filename of the video data of current preset size and file is stored into fixed FLASH.After data exception is restored,I.e. after mobile video monitor system restarting, the video data that default size whether is stored in fixed FLASH is detected firstPacket, if so, then obtaining the filename of the video data of caching.
Step 142, video data is transferred to the corresponding position of storage medium according to filename.
Video data is transferred to the corresponding position of storage medium according to the filename of video data, to ensure the complete of dataWhole property.In the present embodiment, the video file in storage medium includes provisional video file and formal video file, in write-in videoDuring data, provisional video file can be packaged as formal video file in setting time.
Optionally, video data is that mobile video monitor system abnormal shutdown occurs extremely;Correspondingly, when data exception is extensiveAfter multiple, the filename of the video data of caching is obtained, including:When mobile video monitor system restarts, regarding for caching is obtainedThe filename of frequency evidence.
When abnormal shutdown occurs in mobile video monitor system, video data is cached, then abnormal restoring justThe video data of caching is transferred to storage medium, it is ensured that the integrality of video data by Chang Shi.
The technical solution of the present embodiment, first, according to existing FAT32 file system standards, realize internal fragmentation technologySupport the storage medium reparation of 128G or more;Second, existing mobile video monitor system flow is improved, in os startingDone afterwards to storage medium gives mobile video monitor system to use again repair comprehensively after;Third causes for data are frequently write intoWhen abnormal problem is written in storage medium, storage medium is first unloaded, then carry out reparation completion, and reloads (storage medium progressIt uses;4th, abnormal problem backs up when storage medium is written in storage data, such as powers off, and voltage instability, abnormal end etc. is doneData backup and repair process.Increased function has:Newly increase function:Big subregion (500G or more) FAT32 partitioned file systemsIt repairs and supports;Realize that multimedium compatibility is supported:SD card, flash disk, hard disk, three arrange in pairs or groups and coexist use;To storage medium, carry outIt is be multiplexed after backup and storage medium are write completely by the regular cleaning data of setting more.
Embodiment two
Fig. 4 is a kind of structural schematic diagram of the storage device of video data provided by Embodiment 2 of the present invention, such as Fig. 4 institutesShow, which includes:Video data acquisition module 410, video data writing module 420 and abnormality detection module 430.
Video data acquisition module 410, for obtaining video data;
Video data writing module 420, for writing video data into storage medium;
Abnormality detection module 430 is used for when storage medium exception is written in video data, abnormal if it is storage medium,Then suspend write-in, and is continued to write to after repairing storage medium;If it is video data exception, then by the video data of default sizeIt is cached, the video data of caching is transferred to storage medium after video data is normal, and continue to write to.
Optionally, further include:
Storage medium detection module, for being detected to storage medium, if storage medium has exception, to storageMedium is repaired.
Optionally, abnormality detection module 430, is additionally operable to:
The classification of storage medium is obtained, classification includes USB flash disk, SD card and hard disk;
Storage medium interface is detected according to the classification of storage medium, judges storage medium with the presence or absence of abnormal.
Optionally, abnormality detection module 430, is additionally operable to:
Storage medium is unloaded, and starts detection and repairs instruction;
After the completion of storage medium reparation, reloads storage medium and restore data write operation.
Optionally, abnormality detection module 430, is additionally operable to:
After data exception is restored, the filename of the video data of caching is obtained;
Video data is transferred to the corresponding position of storage medium according to filename.
Optionally, video data is that mobile video monitor system abnormal shutdown occurs extremely;
Correspondingly, abnormality detection module 430, is additionally operable to:
When mobile video monitor system restarts, the filename of the video data of caching is obtained.
The method that the executable aforementioned all embodiments of the present invention of above-mentioned apparatus are provided, it is corresponding to have the execution above methodFunction module and advantageous effect.The not technical detail of detailed description in the present embodiment, reference can be made to the aforementioned all implementations of the present inventionThe method that example is provided.
Embodiment three
Fig. 5 is a kind of structural schematic diagram for mobile video monitor system that the embodiment of the present invention three provides, as shown in figure 5,Mobile video monitor system 500 includes:Memory 501, processor 502 and camera 503, camera 503 is for acquiring image.Wherein, processor 502 is for executing following steps:
Obtain video data;
The video data is written in storage medium;
When storage medium exception is written in the video data, if it is storage medium exception, then suspend write-in, andIt is continued to write to after repairing the storage medium;If it is video data exception, then the video data of default size is carried outCaching, is transferred to the storage medium, and continue to write to after the video data is normal by the video data of caching.
Example IV
The arbitrary of one or more computer-readable media may be used in the computer storage media of the embodiment of the present inventionCombination.Computer-readable medium can be computer-readable signal media or computer readable storage medium.It is computer-readableStorage medium for example may be-but not limited to-the system of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, device orDevice, or the arbitrary above combination.The more specific example (non exhaustive list) of computer readable storage medium includes:ToolThere are one or the electrical connection of multiple conducting wires, portable computer diskette, hard disk, random access memory (RAM), read-only memory(ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.In this document, computer-readable storageMedium, which can be any, includes or the tangible medium of storage program, which can be commanded execution system, device or deviceUsing or it is in connection.
Computer-readable signal media may include in a base band or as the data-signal that a carrier wave part is propagated,Wherein carry computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but unlimitedIn electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer canAny computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used forBy instruction execution system, device either device use or program in connection.
The program code for including on computer-readable medium can transmit with any suitable medium, including --- but it is unlimitedIn wireless, electric wire, optical cable, RF etc. or above-mentioned any appropriate combination.
It can be write with one or more programming languages or combinations thereof for executing the computer that operates of the present inventionProgram code, described program design language include object oriented program language-such as Java, Smalltalk, C++,Further include conventional procedural programming language-such as " C " language or similar programming language.Program code can be withIt fully executes, partly execute on the user computer on the user computer, being executed as an independent software package, portionDivide and partly executes or executed on a remote computer or server completely on the remote computer on the user computer.Be related in the situation of remote computer, remote computer can pass through the network of any kind --- including LAN (LAN) orWide area network (WAN)-be connected to subscriber computer, or, it may be connected to outer computer (such as carried using Internet serviceIt is connected by internet for quotient).
Note that above are only presently preferred embodiments of the present invention and institute's application technology principle.It will be appreciated by those skilled in the art thatThe present invention is not limited to specific embodiments described here, can carry out for a person skilled in the art it is various it is apparent variation,It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out to the present invention by above exampleIt is described in further detail, but the present invention is not limited only to above example, without departing from the inventive concept, alsoMay include other more equivalent embodiments, and the scope of the present invention is determined by scope of the appended claims.