CN110825697B - Method and apparatus for formatting a storage device - Google Patents
Method and apparatus for formatting a storage device Download PDFInfo
- Publication number
- CN110825697B CN110825697B CN201911079524.3A CN201911079524A CN110825697B CN 110825697 B CN110825697 B CN 110825697B CN 201911079524 A CN201911079524 A CN 201911079524A CN 110825697 B CN110825697 B CN 110825697B
- Authority
- CN
- China
- Prior art keywords
- file
- camera
- storage device
- size
- file group
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
- G06F16/113—Details of archiving
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
- G06F16/162—Delete operations
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/1737—Details of further file system functions for reducing power consumption or coping with limited storage space, e.g. in mobile devices
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Television Signal Processing For Recording (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Embodiments of the present disclosure disclose methods and apparatus for formatting a storage device. One embodiment of the method comprises: in response to detecting a storage device insertion operation, identifying a capacity value of a storage device into which the storage device insertion operation is inserted, and determining the number of connected cameras; determining a formatting parameter set based on the capacity value of the storage device and the number of cameras, wherein the formatting parameter set comprises: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group; the method further includes deploying the file system in the storage device, and creating the file group and files in the file group on the storage device on which the file system is deployed according to the determined set of formatting parameters. This embodiment helps to improve the performance of the storage device.
Description
Technical Field
Embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a method and an apparatus for formatting a storage device.
Background
In order to obtain more comprehensive and accurate video monitoring data, a video monitoring device (e.g., a car recorder, an Internet Protocol Camera (IPC), etc.) is usually connected with a plurality of cameras which are distributed and installed. The video monitoring device generally employs a storage device (such as an SD card) to store and transmit video monitoring data collected by the camera.
In the related art, after a storage device adopted by a video monitoring device is used for a certain period of time, more and more fragments are generated, which results in reducing the writing performance of the storage device.
Disclosure of Invention
Embodiments of the present disclosure propose methods and apparatuses for formatting a storage device.
In a first aspect, an embodiment of the present disclosure provides a method for formatting a storage device, the method including: in response to detecting a storage device insertion operation, identifying a capacity value of a storage device into which the storage device insertion operation is inserted, and determining the number of connected cameras; determining a formatting parameter set based on the capacity value of the storage device and the number of cameras, wherein the formatting parameter set comprises: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group; the method further includes deploying the file system in the storage device, and creating the file group and files in the file group on the storage device on which the file system is deployed according to the determined set of formatting parameters.
In some embodiments, the method further comprises: and associating each created file group with the camera so as to store the data shot by the camera into the associated file group.
In some embodiments, the method further comprises obtaining relevant information for each camera, the relevant information comprising a resolution; and determining the set of formatting parameters based on the capacity value of the storage device and the number of cameras comprises: determining the number of file groups required to be created according to the number of the cameras; and calculating the size of a file group associated with each camera, the number of files in the file group and the space size of the files in the file group according to the resolution of each camera, the capacity value of the storage device and a preset calculation formula.
In a second aspect, an embodiment of the present disclosure provides a method for storing data, where the method is applied to a storage device formatted by a method described in any implementation manner of the first aspect, and includes: selecting a file group from the created file groups in response to receiving the video data collected by the camera; determining a file corresponding to the last operation time and closest to the current time from the selected file group according to the last operation time of each file in the selected file group; and determining the storage position of the video data according to the size of the residual storage space of the latest file.
In some embodiments, the camera is pre-associated with a file group; and selecting a file group from the created file groups, including: and selecting the file group associated with the camera from the created file group.
In some embodiments, determining the storage location of the video data according to the size of the remaining storage space of the latest file comprises: in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file; in response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files corresponding to the last operation time that is longest from the current time, deleting data stored in the longest file, and storing the video data in the longest file.
In a third aspect, an embodiment of the present disclosure provides an apparatus for formatting a storage device, including: a device detection unit configured to identify a capacity value of a storage device into which a storage device insertion operation is inserted and determine the number of connected cameras in response to detecting the storage device insertion operation; a parameter determination unit configured to determine a formatting parameter set based on a capacity value of the storage device and the number of cameras, wherein the formatting parameter set includes: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group; a device operation unit configured to deploy a file system in the storage device, and create a file group and files in the file group on the storage device on which the file system is deployed according to the determined formatting parameter group.
In some embodiments, the apparatus further comprises: and the equipment association unit is configured to associate each created file group with the camera so as to store the data shot by the camera into the associated file group.
In some embodiments, the apparatus further includes an information acquisition unit configured to acquire relevant information of each camera, the relevant information including a resolution; and the parameter determination unit is further configured to: determining the number of file groups required to be created according to the number of the cameras; and calculating the size of a file group associated with each camera, the number of files in the file group and the space size of the files in the file group according to the resolution of each camera, the capacity value of the storage device and a preset calculation formula.
In a fourth aspect, an embodiment of the present disclosure provides an apparatus for storing data, where the apparatus is applied to a storage device formatted by a method described in any implementation manner of the first aspect, and the apparatus includes: a data receiving unit configured to select a file group from the created file groups in response to receiving video data collected by the camera; the file determining unit is configured to determine a file corresponding to the last operation time and closest to the current time from the selected file group according to the last operation time of each file in the selected file group; and the data storage unit is configured to determine the storage position of the video data according to the size of the residual storage space of the latest file.
In some embodiments, the cameras are pre-associated with a file group; and in the data receiving unit, selecting a file group from the created file groups, including: and selecting a file group associated with the camera from the created file group.
In some embodiments, the data storage unit is further configured to: in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file; in response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files corresponding to the last operation time that is longest from the current time, deleting data stored in the longest file, and storing the video data in the longest file.
In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by the one or more processors, cause the one or more processors to implement a method as described in an implementation manner of any one of the first or second aspects.
In a sixth aspect, embodiments of the present disclosure provide a computer readable medium, on which a computer program is stored, which when executed by a processor, implements a method as described in any of the implementations of the first or second aspects.
Embodiments of the present disclosure provide a method and apparatus for formatting a storage device, which may identify a capacity value of the storage device inserted by a storage device insertion operation and determine the number of connected cameras in response to detecting the storage device insertion operation. Then, based on the capacity value of the storage device and the number of cameras, a set of formatting parameters is determined. Wherein the formatting parameter set comprises: the number of file groups that need to be created, the size of each file group, the number of files in each file group, and the size of the space for the files in each file group. Finally, a file system is deployed in the storage device, and a file group and files in the file group are created on the storage device on which the file system is deployed according to the determined set of formatting parameters. The method and the device provided by the embodiment of the disclosure format the storage device into the file allocated with the storage space, which is beneficial to realizing that the data can be directly stored into each file when the formatted storage device stores the data. Because the storage space is not required to be opened up for the data when the data is received, the fragments are not generated in the storage device, and the performance of the storage device is improved.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is a flow diagram of one embodiment of a method for formatting a storage device according to the present disclosure;
FIG. 2 is a flow diagram of one embodiment of a method for storing data, according to the present disclosure;
FIG. 3 is a block diagram illustrating one embodiment of an apparatus for formatting a storage device according to the present disclosure;
FIG. 4 is a schematic block diagram illustrating one embodiment of an apparatus for storing data according to the present disclosure;
FIG. 5 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and the features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
FIG. 1 illustrates a flow 100 of one embodiment of a method for formatting a storage device according to the present disclosure. The method for formatting the storage device comprises the following steps:
in response to detecting a storage device insertion operation, identifying a capacity value of a storage device into which the storage device insertion operation is inserted, and determining the number of connected cameras, step 101.
In this embodiment, the main execution body of the method for formatting the storage device may be an electronic device such as a video monitoring device. As an example, the execution subject may be a car recorder, a network Camera IPC (IP Camera), or the like.
In this embodiment, when the storage device is inserted into an Input/Output Interface (I/O Interface) of the video monitoring device, the Input/Output Interface of the video monitoring device usually has a level change. Therefore, the execution main body can detect the insertion operation of the storage device by detecting the level change of the input/output interface of the video monitoring device. The storage device may be a pluggable device with a storage function, such as an SD Card (Secure Digital Memory Card).
After detecting the memory device insertion operation, the execution body may obtain the capacity value of the inserted memory device by reading a value in a register in the memory device for recording the capacity value of the memory device. In addition, since the video monitoring device usually generates one camera device file after connecting one camera, the execution main body can obtain the number of connected cameras by calculating the number of the camera device files.
Wherein the formatting parameter set comprises: the number of file groups that need to be created, the size of each file group, the number of files in each file group, and the size of the space for the files in each file group.
As an example, after obtaining the capacity value of the storage device and the number of cameras, the executing body may determine the formatting parameter group by: first, the number of cameras is determined as the number of file groups that need to be created. Then, the capacity value of the storage device is divided by the number of cameras to obtain the size of each file group. And finally, taking the preset number value as the number of the files in each file group, and dividing the size of the obtained file group by the preset number value to obtain the space size of the files in each file group.
As another example, after obtaining the capacity value of the storage device and the number of cameras, the executing body may determine the formatting parameter set by: and searching a formatting parameter group corresponding to the capacity value of the storage equipment and the number of the cameras from a pre-stored corresponding relation table by adopting the capacity value of the storage equipment and the number of the cameras. The corresponding relation table stored in advance stores capacity values, the number of cameras and formatting parameter sets, and a pair of capacity values and the number of cameras corresponds to one formatting parameter set.
In this embodiment, the execution subject may adopt a pre-stored deployment file to deploy a file system on the storage device. The deployment file is a file used for deploying a file system. The file system deployed on the storage device may include, but is not limited to: FAT16 file system, FAT32 file system, NTFS file system, etc. It should be noted that the FAT32 file system can hold information relatively more efficiently and is well compatible with the PC (Personal Computer) side. Therefore, in practice, the file system deployed in the above-described storage device is typically a FAT32 file system.
After the file system is deployed on the storage device, the execution main body can create the file group and the files in the file group on the storage device on which the file system is deployed by calling the pre-stored plug-in for creating the file group and the files in the file group. Specifically, the execution body may use the determined formatting parameter group as an input of the plug-in, so as to create a file group and files in the file group that match the formatting parameter group on a storage device in which the file system is deployed.
As an example, if the number of file groups to be created in the above formatting parameter group is 2, the size of the first file group is 1G, the size of the other file group is 2G, the number of files in the first file group is 10 and the space size of each file in the first file group is 0.1G, the number of files in the second file group is 5 and the space size of each file in the second file group is 0.4G. The execution subject may create one file group with a size of 1G and another file group with a size of 2G on the storage device on which the file system is deployed, and the created file group with 1G includes 10 files with a space size of 0.1G, and the created file group with 2G includes 5 files with a space size of 0.4G.
In this embodiment, the storage device is formatted into the file allocated with the storage space, which is helpful for realizing that the data can be directly stored into each file when the formatted storage device stores the data. Because the storage space is not required to be opened up for the data when the data is received, no fragments are generated in the storage device, and the performance of the storage device is improved.
In some optional implementation manners of this embodiment, the method for formatting the storage device may further include the following steps: and associating each created file group with the camera so as to store the data shot by the camera into the associated file group.
Here, after a file group and files in the file group are created on a storage device in which a file system is deployed, the execution body may associate the created file group with a camera in various ways. For example, associating the file group with the camera may be achieved by associating an identity of the file group with an identity of the camera. In this way, the video data shot by the camera can be stored in the fixed file group associated with the camera, and the data access efficiency can be improved. It should be noted that a plurality of file groups may be associated with one camera, that is, a plurality of file groups are used to store video data shot by the same camera. In practice, to further improve the data access efficiency, one camera is usually uniquely associated with one file group.
In the foregoing implementation manner, the method for formatting the storage device may further include the following steps: and acquiring related information of each camera.
Wherein the related information comprises a resolution.
As an example, the execution body may directly obtain the related information of the camera input by the user, may also obtain the related information of the camera input by the user through a network, and may also obtain the related information of the camera by reading information in a register for storing the related information in the camera.
When the related information of each camera is obtained, the determining the formatting parameter group based on the capacity value of the storage device and the number of cameras may include:
in the first step, the number of file groups required to be created is determined according to the number of cameras.
Here, the execution body may directly take the number of cameras as the number of file groups that need to be created.
And secondly, calculating to obtain the file group size of the file group associated with each camera, the number of files in the file group and the space size of the files in the file group according to the resolution of each camera, the capacity value of the storage equipment and a preset calculation formula.
Wherein, the preset calculation formula may be presetA formula for allocating the capacity of the storage device is specified. As an example, the predetermined calculation formula may be R i =M÷(x1+x2+...+x n )×x i . Wherein R is i Is the size of the file group associated with the ith camera, M is the capacity value of the storage device, n is the number of cameras, x n For capacity allocation coefficient, x, of the nth camera i And distributing coefficients for the capacity of the ith camera.
Here, the execution main body searches the capacity allocation coefficient corresponding to the resolution from the previously stored resolution-capacity allocation coefficient correspondence table using the resolution of each camera, thereby obtaining the capacity allocation coefficient of each camera. The pre-stored resolution-capacity allocation coefficient correspondence table may be a pre-stored correspondence table for describing a correspondence between resolutions and capacity allocation coefficients.
After obtaining the capacity allocation coefficient of each camera, the execution body may use a preset calculation formula to calculate the size of the file group associated with each camera. For example, if the predetermined formula is R i =M÷(x1+x2+...+x n )×x i The number of the connected cameras is 2, namely a camera and a camera, the capacity distribution coefficient of the camera A is 3, the capacity distribution coefficient of the camera B is 5, and the capacity value of the storage device is 8G. It can be obtained that the size of the file group associated with the camera a is 3G and the size of the file group associated with the camera b is 5G.
After the size of each file group is obtained, the execution main body may search for the file size corresponding to the resolution from a pre-stored resolution-file size correspondence table by using the resolution of the camera associated with the file group. The pre-stored resolution-file size correspondence table may be a pre-stored correspondence table for describing a correspondence between resolution and file size. In addition, after the size of the files in each file group is obtained, the number of files in the file group can be obtained by dividing the size of the file group by the size of each file.
In this implementation manner, the storage space of the storage device is allocated based on the resolution of the camera, so that the size of the file group associated with the camera with the higher resolution is larger and the storage space of the files in the file group is also larger, which is helpful for improving the reading performance of the storage device after formatting, and can realize full utilization of the storage device and improve the utilization rate of the storage resource.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for storing data is shown. The process 200 of the method for storing data is applied to the storage device formatted by the method for formatting the storage device, and includes the following steps:
In the present embodiment, an execution subject for executing the above-described method for storing data is generally an electronic device (storage device) having a storage function. When the camera stores the collected video data into the storage device, the execution main body may receive the video data collected by the camera and select a file group from the created file group to store the received video data into the selected file group.
Here, as an implementation, when the camera stores the acquired video data into the storage device for the first time, the execution main body may randomly select one file group from unused file groups for storing the data acquired by the camera. And then, when the camera continues to store the acquired video data into the storage device, the execution main body can directly store the data acquired by the camera into the file group selected during the first storage.
In some optional implementations of this embodiment, the camera may be pre-associated with a file group. At this time, the selecting the file group from the created file group may include: and selecting the file group associated with the camera from the created file group.
In the implementation mode, the video data collected by the camera is directly stored in the file group associated with the camera, so that the video data can be stored more quickly. In addition, when the data in the storage device is read, the video data collected by each camera can be quickly found because the video data collected by each camera is stored in the file group associated with the camera. That is, the present implementation helps to improve the efficiency of access to data by the storage device.
In this embodiment, since the storage device usually records the last operation time when the file is operated. Therefore, the execution body can find the file with the last operation time closest to the current time from the file group according to the last operation time of each file in the file group.
In this embodiment, the execution subject may compare the size of the remaining storage space of the latest file with the size of the video data to be stored, so as to determine the storage location of the video data. As an example, if the size of the remaining storage space of the latest file is larger than or equal to the size of the video data required to be stored, the video data is directly stored in the latest file. On the contrary, if the size of the remaining storage space of the latest file is smaller than the size of the video data required to be stored, the video data is stored into other files.
According to the method provided by the embodiment of the disclosure, since the formatted file is directly allocated with the storage space, the data can be directly stored in each file when the formatted storage device stores the data. Because the storage space is not required to be opened up for the data when the data is received, the fragments are not generated in the storage device, and the performance of the storage device is improved.
In some optional implementation manners of this embodiment, the determining a storage location of the video data according to the size of the remaining storage space of the latest file may include: in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file. In response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files corresponding to the last operation time that is longest from the current time, deleting data stored in the longest file, and storing the video data in the longest file.
In this implementation, when the size of the remaining storage space of the latest file is greater than or equal to the size of the video data to be stored, the video data is directly stored in the latest file. And when the size of the residual storage space of the latest file is smaller than the size of the video data required to be stored, continuously searching the file with the last operation time being longest from the current time from the current file group. After finding the oldest file, deleting the currently stored content in the oldest file, and then storing the video data required to be stored in the oldest file.
In the implementation mode, the content in the file with the last operation time being longest from the current time is deleted and the data which needs to be stored currently is stored, so that the effective utilization of the space of the storage device is realized while the retention time of the stored data is ensured to be as long as possible, and the storage resource utilization rate of the storage device is improved.
With further reference to fig. 3, as an implementation of the method shown in fig. 1, the present disclosure provides an embodiment of an apparatus for formatting a storage device, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 1, and the apparatus may be applied to various electronic devices in particular.
As shown in fig. 3, the apparatus 300 for formatting a storage device of the present embodiment includes: a device detection unit 301 configured to identify a capacity value of a storage device into which a storage device insertion operation is inserted and determine the number of connected cameras in response to detection of the storage device insertion operation; a parameter determining unit 302 configured to determine a formatting parameter set based on the capacity value of the storage device and the number of cameras, wherein the formatting parameter set includes: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group; a device operation unit 303 configured to deploy the file system in the storage device, and create the file group and the files in the file group on the storage device on which the file system is deployed according to the determined formatting parameter group.
In some optional implementations of this embodiment, the apparatus may further include a device associating unit (not shown in the figure). The device associating unit may be configured to associate each created file group with the camera so that data photographed by the camera is stored into the associated file group.
In some optional implementations of this embodiment, the apparatus may further include an information obtaining unit (not shown in the figure). The information acquisition unit may be configured to acquire the relevant information of each camera. The relevant information includes resolution. At this time, the parameter determination unit may be further configured to: determining the number of file groups required to be created according to the number of the cameras; and calculating the size of a file group associated with each camera, the number of files in the file group and the space size of the files in the file group according to the resolution of each camera, the capacity value of the storage device and a preset calculation formula.
In the apparatus provided by the above embodiment of the present disclosure, the device detection unit 301, in response to detecting the storage device insertion operation, identifies the capacity value of the storage device inserted by the storage device insertion operation, and determines the number of connected cameras. Then, the parameter determination unit 302 determines the formatting parameter group based on the capacity value of the storage device and the number of cameras. Wherein, the formatting parameter group comprises: the number of file groups that need to be created, the size of each file group, the number of files in each file group, and the size of the space for the files in each file group. Finally, the device operating unit 303 deploys the file system in the storage device, and creates a file group and files in the file group on the storage device on which the file system is deployed, according to the determined formatting parameter group. The apparatus of this embodiment formats the storage device into the file allocated with the storage space, which is helpful for realizing that the formatted storage device can directly store the data into each file when storing the data. Because the storage space is not required to be opened up for the data when the data is received, no fragments are generated in the storage device, and the performance of the storage device is improved.
With further reference to fig. 4, as an implementation of the method shown in fig. 2, the present disclosure provides an embodiment of an apparatus for storing data, which corresponds to the method embodiment shown in fig. 2, and which can be applied to various electronic devices with a storage function.
As shown in fig. 4, the apparatus 400 for storing data of the present embodiment includes: a data receiving unit 401 configured to select a file group from the created file groups in response to receiving video data collected by the camera; a file determining unit 402 configured to determine, according to the last operation time of each file in the selected file group, a file corresponding to the last operation time and closest to the current time from the selected file group; a data storage unit 403 configured to determine a storage location of the video data according to a size of a remaining storage space of the latest file.
In some optional implementations of this embodiment, the camera may be pre-associated with a file group. At this time, in the data receiving unit 401, selecting a file group from the created file groups may include: and selecting the file group associated with the camera from the created file group.
In some optional implementations of this embodiment, the data storage unit 403 may be further configured to: in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file; in response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files corresponding to the last operation time that is longest from the current time, deleting data stored in the longest file, and storing the video data in the longest file.
In the apparatus provided by the above embodiment of the present disclosure, the data receiving unit 401 selects a file group from the created file groups in response to receiving the video data collected by the camera. Then, the file determining unit 402 determines a file corresponding to the last operation time closest to the current time from the selected file group according to the last operation time of each file in the selected file group. Finally, the data storage unit 403 determines the storage location of the video data according to the size of the remaining storage space of the latest file. According to the device of the embodiment, since the formatted file is directly allocated with the storage space, the data can be directly stored in each file when the formatted storage device stores the data. Because the storage space is not required to be opened up for the data when the data is received, the fragments are not generated in the storage device, and the performance of the storage device is improved.
Referring now to FIG. 5, a schematic diagram of an electronic device (e.g., video surveillance device, storage device) 500 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, the electronic device 500 may include a processing means (e.g., central Processing Unit (CPU), graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 500 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 5 may represent one device or may represent multiple devices as desired.
In particular, the processes described above with reference to the flow diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program, when executed by the processing device 501, performs the above-described functions defined in the methods of the embodiments of the present disclosure. It should be noted that the computer readable medium of the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may be separate and not incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the steps of: in response to detecting a storage device insertion operation, identifying a capacity value of a storage device into which the storage device insertion operation is inserted, and determining the number of connected cameras; determining a formatting parameter set based on the capacity value of the storage device and the number of cameras, wherein the formatting parameter set comprises: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group; the method further includes deploying the file system in the storage device, and creating the file group and files in the file group on the storage device on which the file system is deployed according to the determined set of formatting parameters.
When the one or more programs are executed by the electronic device, the electronic device may also be caused to perform the steps of: selecting a file group from the created file groups in response to receiving the video data collected by the camera; determining a file corresponding to the last operation time and closest to the current time from the selected file group according to the last operation time of each file in the selected file group; and determining the storage position of the video data according to the size of the residual storage space of the latest file.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, which may be described as: a processor includes a device detection unit, a parameter determination unit, and a device operation unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, the device detection unit may also be described as a "unit that identifies a capacity value of a storage device into which a storage device insertion operation is inserted, and determines the number of connected cameras, in response to detection of the storage device insertion operation".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept as defined above. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Claims (12)
1. A method for formatting a storage device for use in a video surveillance appliance, comprising:
in response to detecting a storage device insertion operation, identifying a capacity value of a storage device into which the storage device insertion operation is inserted and determining the number of connected cameras;
determining a set of formatting parameters based on the capacity value of the storage device and the number of cameras, wherein the set of formatting parameters comprises: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group;
deploying a file system in the storage device, and creating a file group and files in the file group on the storage device on which the file system is deployed according to the determined formatting parameter group;
associating each created file group with a camera so as to store data shot by the camera into the associated file group;
wherein the determining a set of formatting parameters based on the capacity value of the storage device and the number of cameras comprises:
determining the number of file groups required to be created according to the number of the cameras;
according to the resolution of each camera, inquiring the capacity distribution coefficient corresponding to each camera from a pre-stored resolution-capacity distribution coefficient corresponding relation table; determining the size of a file group associated with each camera according to the capacity distribution coefficient corresponding to each camera and a preset calculation formula;
according to the resolution of each camera, inquiring the file size corresponding to each camera from a pre-stored resolution-file size corresponding relation table;
determining the number of files in the file group associated with the corresponding camera according to the size of the file group associated with each camera and the size of the file corresponding to the corresponding camera;
when the resolution of the camera is higher, the size of the file group associated with the camera is larger, and the size of the space of the file in the file group associated with the camera is also larger.
2. The method for formatting a storage device according to claim 1, wherein the method further comprises obtaining relevant information for each camera, the relevant information comprising a resolution.
3. A method for storing data for a storage device formatted using the method for formatting a storage device according to any of claims 1-2, comprising:
selecting a file group from the created file groups in response to receiving the video data collected by the camera;
determining a file corresponding to the last operation time and closest to the current time from the selected file group according to the last operation time of each file in the selected file group;
and determining the storage position of the video data according to the size of the residual storage space of the latest file.
4. The method for storing data according to claim 3, wherein the camera has a file group associated therewith in advance; and
the selecting of the file group from the created file group includes:
and selecting the file group associated with the camera from the created file group.
5. The method for storing data according to any one of claims 3-4, wherein said determining a storage location of said video data according to a size of a remaining storage space of said most recent file comprises:
in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file;
in response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files that corresponds to a last operation time that is the longest from a current time, deleting data stored in the longest file, and storing the video data in the longest file.
6. An apparatus for formatting a storage device for use in a video surveillance appliance, comprising:
a device detection unit configured to identify a capacity value of a storage device into which a storage device insertion operation is inserted and determine the number of connected cameras in response to detecting the storage device insertion operation;
a parameter determination unit configured to determine a set of formatting parameters based on a capacity value of the storage device and a number of cameras, wherein the set of formatting parameters includes: the number of file groups to be created, the size of each file group, the number of files in each file group and the space size of the files in each file group;
a device operating unit configured to deploy a file system in the storage device, and create a file group and files in the file group on the storage device on which the file system is deployed according to the determined formatting parameter group;
a device associating unit configured to associate each created file group with a camera so that data photographed by the camera is stored into the associated file group;
wherein the parameter determination unit is further configured to:
determining the number of file groups required to be created according to the number of the cameras;
according to the resolution of each camera, inquiring the capacity distribution coefficient corresponding to each camera from a pre-stored resolution-capacity distribution coefficient corresponding relation table; determining the size of a file group associated with each camera according to the capacity distribution coefficient corresponding to each camera and a preset calculation formula;
according to the resolution of each camera, inquiring the file size corresponding to each camera from a pre-stored resolution-file size corresponding relation table;
determining the number of files in the file group associated with the corresponding camera according to the size of the file group associated with each camera and the size of the file corresponding to the corresponding camera;
when the resolution of the camera is higher, the size of the file group associated with the camera is larger, and the size of the space of the file in the file group associated with the camera is also larger.
7. The apparatus for formatting a storage device according to claim 6, wherein the apparatus further comprises an information obtaining unit configured to obtain relevant information of each camera, the relevant information including resolution.
8. An apparatus for storing data, applied to a storage device formatted by the method for formatting a storage device according to any one of claims 1-2, comprising:
a data receiving unit configured to select a file group from the created file groups in response to receiving video data collected by the camera;
the file determining unit is configured to determine a file corresponding to the last operation time and closest to the current time from the selected file group according to the last operation time of each file in the selected file group;
a data storage unit configured to determine a storage location of the video data according to a size of a remaining storage space of the latest file.
9. The apparatus for storing data according to claim 8, wherein the camera has a file group associated therewith in advance; and
in the data receiving unit, the selecting a file group from the created file groups includes:
and selecting the file group associated with the camera from the created file group.
10. The apparatus for storing data according to one of claims 8-9, wherein the data storage unit is further configured to:
in response to determining that the size of the remaining storage space is greater than or equal to the size of the video data, storing the video data to the most recent file;
in response to determining that the size of the remaining storage space is less than the size of the video data, determining a file from the set of files corresponding to a last operation time that is longest from a current time, deleting data stored in the longest file, and storing the video data in the longest file.
11. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method for formatting a storage device as claimed in any one of claims 1-2, or to implement the method for storing data as claimed in any one of claims 3-5.
12. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method for formatting a storage device according to any one of claims 1-2, or carries out the method for storing data according to any one of claims 3-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911079524.3A CN110825697B (en) | 2019-11-07 | 2019-11-07 | Method and apparatus for formatting a storage device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911079524.3A CN110825697B (en) | 2019-11-07 | 2019-11-07 | Method and apparatus for formatting a storage device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110825697A CN110825697A (en) | 2020-02-21 |
CN110825697B true CN110825697B (en) | 2022-12-20 |
Family
ID=69553038
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911079524.3A Active CN110825697B (en) | 2019-11-07 | 2019-11-07 | Method and apparatus for formatting a storage device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110825697B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104750858A (en) * | 2015-04-16 | 2015-07-01 | 成都影泰科技有限公司 | Network-based data storage method |
CN106027934A (en) * | 2016-07-13 | 2016-10-12 | 深圳市爱培科技术股份有限公司 | Vehicle driving video storing method and system based on rearview mirror |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005122439A (en) * | 2003-10-16 | 2005-05-12 | Sharp Corp | Device equipment and format conversion method for recording device of device equipment |
CN100362492C (en) * | 2005-07-20 | 2008-01-16 | 杭州海康威视数字技术有限公司 | Digital hard disc recorder file managing method for preventing file fragment production |
CN102932622B (en) * | 2012-11-08 | 2015-08-05 | 珠海全志科技股份有限公司 | The kinescope method of digital video recording equipment and device |
CN107562766B (en) * | 2016-07-01 | 2020-11-27 | 杭州海康威视数字技术股份有限公司 | Data file writing method, device and system |
CN107229421B (en) * | 2017-05-31 | 2020-08-04 | 浙江大华技术股份有限公司 | Method and device for creating video data storage system, method and device for writing file into video data storage system and method and device for reading video data storage system |
CN108124112B (en) * | 2017-12-28 | 2020-04-03 | 福州瑞芯微电子股份有限公司 | Performance improving method for multi-path storage stream media data |
CN109542842B (en) * | 2018-11-02 | 2022-07-26 | 安徽创世科技股份有限公司 | Video sequence storage and query method compatible with fat32 file system and device thereof |
-
2019
- 2019-11-07 CN CN201911079524.3A patent/CN110825697B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104750858A (en) * | 2015-04-16 | 2015-07-01 | 成都影泰科技有限公司 | Network-based data storage method |
CN106027934A (en) * | 2016-07-13 | 2016-10-12 | 深圳市爱培科技术股份有限公司 | Vehicle driving video storing method and system based on rearview mirror |
Non-Patent Citations (1)
Title |
---|
嵌入式数字视频监控系统中的媒体存储研究;欧阳甸;《视频应用于工程》;20140131;第38卷(第1期);第[157]页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110825697A (en) | 2020-02-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110213614B (en) | Method and device for extracting key frame from video file | |
EP2660761A1 (en) | Timestamp management method for data synchronization and terminal therefor | |
CN111198859B (en) | Data processing method, device, electronic equipment and computer readable storage medium | |
CN110275723A (en) | Obtain method, apparatus, electronic equipment and the readable medium of resource | |
CN112433920B (en) | A method, device, equipment and medium for reporting buried data | |
KR101238374B1 (en) | Method and appratus for supplying mashup service | |
CN112199048B (en) | Data reading method, system, device and medium | |
CN109753332B (en) | Method and device for displaying information | |
CN111309228A (en) | Multimedia processing method and device and electronic equipment | |
CN111241137B (en) | Data processing method, device, electronic equipment and storage medium | |
CN114021016A (en) | Data recommendation method, device, equipment and storage medium | |
CN111857518A (en) | Method and device for canceling image editing operation, electronic equipment and medium | |
CN110381365A (en) | Video takes out frame method, device and electronic equipment | |
CN111857915B (en) | Application page display method and device | |
CN110825697B (en) | Method and apparatus for formatting a storage device | |
CN109947613B (en) | File reading test method and device | |
CN109587553A (en) | Method for playing music, device, electronic equipment and computer storage medium | |
CN112291121A (en) | Data processing method and related equipment | |
CN112884376A (en) | Work order processing method and device, electronic equipment and computer readable storage medium | |
US8811756B2 (en) | Image compression | |
US11366613B2 (en) | Method and apparatus for writing data | |
CN111198853A (en) | Data processing method and device, electronic equipment and computer readable storage medium | |
CN115061743A (en) | Interface calling method and device, computer readable medium and electronic equipment | |
CN116166522A (en) | Method for determining test coverage rate of application program, electronic equipment and program product | |
CN117520228B (en) | Command processing method, device, equipment and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |