Background technique
File system is operating system for clearly (commonly disk also to have based on NAND Flash's storage equipment
Solid state hard disk) or the file on subregion method and data structure, i.e. the method for constituent act on a storage device.Operating system
In be responsible for management and the software mechanism of storage file information is known as file management system, abbreviation file system.File system is by three
Part forms: the interface of file system, to the software assembly of object manipulation and management, object and attribute.From the point of view of system perspective,
File system is to carry out tissue and distribution to the space of file-storage device, is responsible for file and stores and protect to the file of deposit
The system of shield and retrieval.Specifically, it, which is responsible for user, establishes file, deposit is read, modification, dump file, controls file
Access, file etc. is cancelled when user does not use.
General file system is because it has the structure of its complexity, because he will meet a variety of different applications, such as
Fat32, ntfs, ext4.Their versatility is good, but is being applied in vehicle-mounted video recording occasion, then is not necessarily applicable in.It is first
First these file system, which suffer from complicated table structure, will use some special tool ability when these tables are impaired
When the file that you lose is retrieved, and writes these file system, it is easy to produce fragment.Currently available technology has had
A kind of predistribution technology distributes space directly to table, forever motionless, but is like that there is no problem in general video recording occasion,
But when being applied to vehicle-mounted, generate fierce collision in automobile (in the case that certain disk itself is not by physical damage)
Or it when strong electromagnetic interference, often goes wrong, only goes to read it even if not removing written document table, will also result in the damage of table
It is bad.
Summary of the invention
The embodiment of the present invention is designed to provide a kind of vehicle-mounted kinescope method, can be improved video recording efficiency, can be to exception
It is repaired.
The embodiments of the present invention are implemented as follows:
A kind of vehicle-mounted kinescope method, comprising the following steps:
Step 1: checking system information area, operation is formatted to storage medium, and check other identifier, if literary
Part sum mark is destroyed, then according to storage medium situation calculation document sum and writes back system information area again;
Step 2: check file information head, verification to file information head and check, according to record if being destroyed
As information header recovery file information head, if video information head is destroyed, according to the frame originating point information and I frame rope in video file
Draw area's Information recovering video information head;
It is indexed step 3: being rebuild according to video file, searches for the frame head in video file, be written in index according to frame head,
The picture recorded in video file to be synchronized in video information head;
Step 4: the new and old mark according to system information in front, finds out each newest video recording section in channel in storage medium,
Start to record a video;
Step 5: in video process, if current video file record is full, since oldest video file cover.
Wherein, it when occurring bad block in index file, is marked in bad block management area and finds out replacement block and be replaced.
Wherein, power on and off operation is carried out to storage medium, finds storage medium node again, reinitializes file system
System.
Wherein, the storage medium is hard disk or flash card.
The embodiment of the present invention is by directly writing naked disk, the possibility for avoiding traditional file systems table from being destroyed, while no longer
By complicated file system write magnetic disk, magnetic head can be efficiently utilized, it can be according to other regions when key area is destroyed
It is repaired, while no longer each channel is saved as a file, but storage is gone down in sequence, avoids the inclined back and forth of magnetic head
It moves.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
The embodiment of the present invention is by directly writing naked disk, the possibility for avoiding traditional file systems table from being destroyed, while no longer
By complicated file system write magnetic disk, magnetic head can be efficiently utilized, it can be according to other regions when key area is destroyed
It is repaired, while no longer each channel is saved as a file, but storage is gone down in sequence, avoids the inclined back and forth of magnetic head
It moves.
Specific implementation of the invention is described in detail below in conjunction with specific embodiment:
The present invention is based on video recording is efficiently read and write using naked disk, directly operate naked disk, storage medium include hard disk and
Flash memory introduces the contents of the present invention in order to detailed, some concepts is illustrated or is defined below by taking hard disk as an example:
Definition one: naked disk;There is no any universal document system (such as fat32, ntfs, ext4 etc.) on disk.
Definition two: system information area;For describing the subregion of entire hard disk information, flag bit therein includes 1. file systems
System version;2. whether disk formats mark;3. hard disk size information;4. video file is total;5. verification and
Definition three: file information head;Information for describing all to record a video inside video file, including 1. video recording texts
Part initial time terminates the time;2. total length of recording a video in file;3. the sum of all i frames in this document;4. being wrapped in this file
Total attribute (booting, timing, alarm) of the video recording contained;5. section of recording a video sum;6. the new and old mark of video file;7. video recording text
The use state (having used, be not used, bad block occur) of part;8. verification and.
Define four: video information head: the case where for describing each video recording section, including 1. sections are recorded a video initial time, end
The only time;2. segment length of recording a video;3. section i frame number of recording a video;4. resolution ratio of recording a video;5. originating i frame in the offset in I frame index area.
Definition five: frame head: for describing the information of each frame.1. channel number belonging to the frame;2. the frame time is rubbed with the hands;3. the frame
Length;4. Frame Properties (P frame I frame audio frame) 5. verification and.
Define the frame index area six: I: for storing I frame all in video file.Frame head goes out when playing back video recording in the future
It now damages, bad frame can be skipped according to I frame index and continues to play.
It defines seven: bad block management area: for managing the bad block of index file, when bad block occurs in index, finding and replace
Block is changed to be replaced.
Define eight: video file: there are two types of the files of hard disk, and one is index files, and one is video file, video recording texts
There is video recording section in part again.Video file and video recording section are the relationships for including, i.e. have multiple video recording sections in a video file.And it records
As then including I frame index area and bad block management area in file.Only one index file 128M in hard disk, other are video recording text entirely
Part, each video file are 128M, and the number of video file is assigned to maximum according to the size adaptation of hard disk, each
There is a lot of video recording section in video file, at most no more than 250.Each video file corresponds to a file information head,
Each corresponding video information head of video recording section.
Define nine: index file: including system information head in 128M index file, file information head, video information head is bad
Block directorial area, only one index file in hard disk.
As shown in Figure 1, a kind of vehicle-mounted kinescope method includes the following steps:
Step 1: checking system information area, judges whether to format, if unformatted, need that user is prompted to carry out
It formats;If formatted, other identifier is checked, if it find that total number of files identifies (the 4th of system information area
The content of definition) it is destroyed, then it is totalized again according to hard disk situation, is written back system information area;Wherein, it formats specific
Are as follows: it is formatted into vehicle-mounted file system, this file system is system information area, system information head, video information head, bad block
Disk is written in directorial area by way of naked write and common formatting is different, without so-called partitions of file table;According to
Hard disk situation totalizes specifically: reading the size of hard disk, system information area, system information by the driving of hard disk first
Head, video file head in bad block management area all indexed files, account for 128M.Other data files each account for 128M.According to hard
The total amount of disk can calculate the sum of video file.
Step 2: check file information head, verification to file information head and check, if it find that being destroyed then root
Restore file information head according to video information head.During recovery, if it find that video information head has the case where destruction, then root
According in video file frame head (define five) and I frame index area restore video information head.
It is indexed step 3: being rebuild according to video file, this index includes file information head and video information head, last time record
Picture there is also in video file, but be not synchronized to video information face gone in front, at this moment must synchronize, otherwise this
Section video recording will be lost.Synchronous process is the frame head in search video file step by step, is then written to rope according to frame head
Draw, exactly the information inside frame head is write to index the inside by way of cumulative and go.
Step 4: finding out the file that each channel needs to start video recording, there is a flag bit to indicate in file information head
Whether record completely, there are one the new and old markers of file.When initialization, the file information of last time each channel video recording is found
Head looks for the file of next free time to start to record if having recorded full 128M, if do not recorded completely, continues newly to open video recording letter
Breath head continues to record.
Step 5: in video process, if when file record is full (formatting has been allocated in advance), from oldest
File, which rises, to be started to cover.
Abnormality processing:
1. Bad Block Management: when occurring bad block in index file, bad block management area be marked and find out replacement block into
Row replacement, it is total at most no more than the damage of 128 file information heads that bad block management provides hard disk index file, once it is more than just
Think this hard disk corruptions.It is bad to describe that just in bad block management area a new file information head is opened up when being not above
The corresponding video file of that file information head.
2. shake abnormality processing: when vehicle in the process of moving, hard disk is easy the interference being shaken, and file system also can
There is exception, at this moment need to carry out abnormality processing, the abnormality processing mode taken at present is to carry out power-on and power-off, Zhi Houchong to hard disk
New to find hard disk node, this is the hard disk node generated according to hard drive.Generally node/dev/ is mapped to udev tool
On diskHDD, file system, the process of the repetition first step to the 5th step are reinitialized.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to restrict the invention, all in essence of the invention
Made any modifications, equivalent replacements, and improvements etc., should all be included in the protection scope of the present invention within mind and principle.