Summary of the invention
The purpose of the embodiment of the present invention is in that to provide a kind of vehicle-mounted kinescope method, it is possible to increase video recording efficiency, can repair abnormal.
The embodiment of the present invention is achieved in that
A kind of vehicle-mounted kinescope method, comprises the following steps:
The first step: check system information district, storage medium is formatted operation, and checks that other identifys, if total number of files mark is destroyed, then again total according to storage medium situation calculation document and write back system information district;
Second step: check file information head, to the verification of file information head with check, if destroyed, recover file information head according to video information head, if video information head is destroyed, then according to the frame originating point information in video file and I frame index district Information recovering video information head;
3rd step: according to video file reconstruction index, the frame head in search video file, according in frame head write index, to be synchronized in video information head by the picture recorded in video file;
4th step: according to system information new and old sign in front, find out the video recording section that each passage in storage medium is up-to-date, starts video recording;
5th step: in video process, if current video file record is full, then starts to cover from the oldest video file.
Wherein, when index file occurs bad block, it is marked and finds out replacement block in bad block management district and be replaced.
Wherein, storage medium is carried out power-on and power-off operation, again find storage medium node, reinitialize file system.
Wherein, described storage medium is hard disk or flash card.
The embodiment of the present invention is by directly writing naked disk, avoid the possibility that traditional file systems table is destroyed, simultaneously not again through complicated file system write magnetic dish, magnetic head can be utilized efficiently, can repair according to other regions when key area is destroyed, simultaneously no longer each passage is saved as a file, but storage is gone down in order, it is to avoid the skew back and forth of magnetic head.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated. Should be appreciated that specific embodiment described herein is only in order to explain the present invention, is not intended to limit the present invention.
The embodiment of the present invention is by directly writing naked disk, avoid the possibility that traditional file systems table is destroyed, simultaneously not again through complicated file system write magnetic dish, magnetic head can be utilized efficiently, can repair according to other regions when key area is destroyed, simultaneously no longer each passage is saved as a file, but storage is gone down in order, it is to avoid the skew back and forth of magnetic head.
Below in conjunction with specific embodiment, implementing of the present invention is described in detail:
The present invention, based on utilizing naked disk to read and write video recording efficiently, directly operates naked disk, and storage medium includes hard disk and flash memory, for hard disk, in order to detailed introduces present disclosure, below some concepts is illustrated or is defined:
Definition one: naked disk; Disk does not have any universal document system (such as fat32, ntfs, ext4 etc.).
Definition two: system information district; For describing the subregion of DISK to Image information, flag bit therein comprises 1. file system versions; 2. whether disk formats mark; 3. hard disk size information; 4. video file sum; 5. verification and
Definition three: file information head; For describing the information of all video recordings inside video file, including 1. video file initial times, terminate the time;2. video recording total length in file; 3. the sum of all i frames in this document; 4. total attribute (start regularly, is reported to the police) of the video recording comprised in this file; 5. video recording section sum; 6. the new and old sign of video file; 7. the use state (use, do not use, bad block occurs) of video file; 8. verification and.
Definition four: video information head: for describing the situation of each video recording section, including 1. this section of video recording initial times, terminates the time; 2. video recording segment length; 3. video recording section i frame number; 4. video recording resolution; 5. the initial i frame skew in I frame index district.
Definition five: frame head: for describing the information of each frame. 1. the channel number belonging to this frame; 2. this frame time is rubbed with the hands; 3. the length of this frame; 4. Frame Properties (P frame I frame audio frame) 5. verify and.
Definition six: I frame index district: be used for depositing in video file all of I frame. Occur damaging once playback video recording frame head in the future, it is possible to skip bad frame according to I frame index and continue to play.
Definition seven: bad block management district: for managing the bad block of index file, when bad block occurs in index time, finds replacement block to be replaced.
Definition eight: video file: the file of hard disk has two kinds, one is index file, and one is video file, has again video recording section in video file. Video file and video recording section are the relations comprised, and namely have multiple video recording section in a video file. Video file then comprises I frame index district and bad block management district. Only one of which index file 128M in hard disk, other are video file entirely, and each video file is all 128M, and the number of video file is maximum according to being assigned to of the size adaptation of hard disk, each video file has a lot of video recording section, not can exceed that at most 250. The corresponding file information head of each video file, each corresponding video information head of video recording section.
Definition nine: index file: comprise system information head, file information head, video information head, bad block management district, only one of which index file in hard disk in 128M index file.
As it is shown in figure 1, a kind of vehicle-mounted kinescope method comprises the steps:
The first step: check system information district, it may be judged whether formatted, if unformatted, it is necessary to prompting user would format; If formatted, then check that other identify, if it find that total number of files mark (content of the 4th definition in system information district) is destroyed, then again totalizes according to hard disk situation, be written back system information district; Wherein, formatting is particularly as follows: be formatted into vehicle-mounted file system, and this file system is system information district, system information head, video information head, bad block management district writes disk by the naked mode write, it it is different with common formatting, it does not have so-called partitions of file table; Totalize specifically according to hard disk situation: what first pass through hard disk drives the size reading hard disk, system information district, system information head, video file head, in bad block management district all indexed files, accounts for 128M. Other data file is each accounts for 128M. Total amount according to hard disk just can calculate the sum of video file.
Second step: check file information head, to the verification of file information head with check, then recovers file information head according to video information head if it find that destroyed. In the process recovered, if it find that video information head has the situation of destruction, then recover video information head according to the frame head (definition five) in video file and I frame index district.
3rd step: rebuild index according to video file, this index comprises file information head and video information head, and the picture of record last time there is also in video file, but be not but synchronized to video information face in front and go, at this moment must synchronizing, otherwise the video recording of this section will be lost. The process synchronized is the frame head in search video file step by step, is then written to index according to frame head, it is simply that by cumulative mode, the information inside frame head is write index the inside.
4th step: finding out each passage needs to start the file of video recording, and record is full to have a flag bit to indicate whether in file information head, also has the new and old flag of a file. During initialization, find the file information head of each passage video recording last time, if having recorded full 128M, then look for next idle file to start record, full without record, continue newly to open video information head and continue record.
5th step: in video process, if when a file has been recorded full (formatting has been allocated in advance), then starts to cover from the oldest file.
Abnormality processing:
1. Bad Block Management: when bad block occurs in index file, it is marked and finds out replacement block in bad block management district to be replaced, bad block management specifies that hard disk index file always not can exceed that at most the damages of 128 file information head, just thinks this hard disk corruptions once exceed. Just a new file information head is opened up in bad block management district to describe the video file that bad file information head is corresponding in time being not above.
2. vibrations abnormality processing: when vehicle in the process of moving, hard disk is easily subject to the interference of vibrations, file system also there will be exception, at this moment need to carry out abnormality processing, the abnormality processing mode taked at present is that hard disk is carried out power-on and power-off, again finding hard disk node afterwards, this is the hard disk node produced according to hard drive. Generally it is mapped on node/dev/diskHDD with udev instrument, reinitializes file system, repeat the first step process to the 5th step.
The foregoing is only presently preferred embodiments of the present invention, be not limited to the present invention, all any amendment, equivalent replacement and improvement etc. made within the spirit and principles in the present invention, should be included within protection scope of the present invention.