Video file reading and writing method and device

文档序号:1046816 发布日期:2020-10-09 浏览:22次 中文

阅读说明:本技术 一种录像文件读写方法及装置 (Video file reading and writing method and device ) 是由 杭振 梁硕 于 2020-06-19 设计创作,主要内容包括:本申请实施例提供了一种录像文件读写方法及装置,方法包括:获取录像文件包括的多个视频帧中发生的事件信息,事件信息为对视频帧进行图像识别后得到的;基于预设分片时长范围和多个视频帧中发生的事件信息,对录像文件进行分片处理,得到多个分片;对每一分片的属性信息进行结构化处理,得到每一分片的结构化信息,分片的结构化信息包括分片的属性信息;基于分片的结构化信息,将多个分片上传至云存储设备。基于录像文件包括多个分片的结构化信息,确定满足目标回放信息的结构化信息对应的目标分片;从云存储设备下载目标分片。应用本申请实施例提供的技术方案,提高了录像文件上传和下载的效率。(The embodiment of the application provides a video file read-write method and a device, wherein the method comprises the following steps: acquiring event information occurring in a plurality of video frames included in a video file, wherein the event information is obtained by carrying out image recognition on the video frames; based on a preset fragmentation duration range and event information generated in a plurality of video frames, performing fragmentation processing on the video file to obtain a plurality of fragments; structuring the attribute information of each fragment to obtain the structured information of each fragment, wherein the structured information of each fragment comprises the attribute information of the fragment; and uploading the plurality of fragments to the cloud storage device based on the structural information of the fragments. Based on the structural information of the video file including the plurality of fragments, determining a target fragment corresponding to the structural information meeting the target playback information; and downloading the target fragment from the cloud storage device. By applying the technical scheme provided by the embodiment of the application, the uploading and downloading efficiency of the video files is improved.)

1. A video file writing method is characterized by comprising the following steps:

acquiring event information occurring in a plurality of video frames included in a video file, wherein the event information is obtained by carrying out image recognition on the video frames;

based on a preset fragment duration range and event information generated in the plurality of video frames, performing fragment processing on the video file to obtain a plurality of fragments;

structuring the attribute information of each fragment to obtain the structured information of each fragment, wherein the structured information of the fragments comprises the attribute information of the fragments;

and uploading the plurality of fragments to a cloud storage device based on the structural information of the fragments.

2. The method according to claim 1, wherein the step of structuring the attribute information of each of the slices to obtain the structured information of each of the slices comprises:

determining the priority of each fragment according to the corresponding relation between preset event information and the priority and the event information generated in each fragment;

performing structural processing on the attribute information of each fragment and the priority of each fragment to obtain the structural information of each fragment, wherein the structural information of the fragments comprises the attribute information of the fragments and the priority of the fragments;

the step of uploading the plurality of shards to a cloud storage device based on the structured information of the shards includes:

and uploading the plurality of fragments to the cloud storage device in sequence according to the sequence of the priorities included in the structured information of the fragments from high to low.

3. The method according to claim 2, wherein the step of sequentially uploading the plurality of shards to the cloud storage device according to the order of the priority included in the structured information of the shards from high to low comprises:

and according to the sequence of the priority included by the structural information of the fragments from high to low, sequentially and concurrently uploading the fragments to the cloud storage device by adopting multiple threads.

4. The method of claim 1, wherein after obtaining a plurality of the slices, the method further comprises:

creating an uploading bitmap for a plurality of the fragments, wherein the bits in the uploading bitmap correspond to the fragments one by one, and the value of each bit is a first preset value;

for each fragment, if the fragment is successfully uploaded to the cloud storage device, setting the value of the bit corresponding to the fragment in the uploading bitmap as a second preset value.

5. The method of claim 4, further comprising:

after the uploading process of the plurality of fragments is interrupted, obtaining the residual fragments corresponding to the bits of the first preset value in the uploading bitmap;

uploading the remaining fragments to a cloud storage device;

after the remaining fragments are successfully uploaded to the cloud storage device, setting the value of the bit corresponding to the remaining fragments in the uploading bitmap as the second preset value.

6. The method according to any of claims 1-5, wherein the slice starts with a key frame, and the slice comprises a plurality of video frames with the same event information.

7. The method according to any one of claims 1-5, further comprising:

and uploading the structural information of the plurality of the fragments to a cloud storage device.

8. A method for reading a video file is characterized by comprising the following steps:

acquiring target playback information for the video file;

based on the structural information of the video file comprising a plurality of fragments, determining a target fragment corresponding to the structural information meeting the target playback information;

and downloading the target fragment from the cloud storage device.

9. The method of claim 8, wherein the structured information comprises a video recording time of the slice;

the step of obtaining target playback information for the video recording file includes:

acquiring a first target video recording time indicated by a playback cursor of a video recording file;

the step of determining a target segment corresponding to the structural information meeting the target playback information based on the structural information of the plurality of segments included in the video file includes:

and determining the fragments within the preset time length taking the first target video recording time as the starting time as target fragments based on the structural information of the plurality of fragments included in the video recording file.

10. The method of claim 8, wherein the structured information comprises event information occurring in the slice;

the step of obtaining target playback information for the video recording file includes:

acquiring target event information aiming at a video file;

the step of determining a target segment corresponding to the structural information meeting the target playback information based on the structural information of the plurality of segments included in the video file includes:

and determining the fragment in which the target event information occurs as a target fragment based on the structural information of the plurality of fragments included in the video file.

11. The method of claim 10, further comprising:

acquiring a second target video recording time indicated by the playback cursor of the video recording file;

and downloading the target fragment from cloud storage equipment by taking the second target video recording time as the starting time.

12. An apparatus for writing a video file, the apparatus comprising:

the video recording device comprises a first acquisition unit, a second acquisition unit and a processing unit, wherein the first acquisition unit is used for acquiring event information generated in a plurality of video frames included in a video file, and the event information is obtained by carrying out image recognition on the video frames;

the fragment unit is used for carrying out fragment processing on the video file based on a preset fragment duration range and event information generated in the plurality of video frames to obtain a plurality of fragments;

the structuring unit is used for performing structuring processing on the attribute information of each fragment to obtain the structuring information of each fragment, wherein the structuring information of the fragment comprises the attribute information of the fragment;

and the uploading unit is used for uploading the fragments to the cloud storage device based on the structural information of the fragments.

13. An apparatus for reading a video file, the apparatus comprising:

an acquisition unit configured to acquire target playback information for a video file;

the determining unit is used for determining a target fragment corresponding to the structural information meeting the target playback information based on the structural information of the video file comprising a plurality of fragments;

and the downloading unit is used for downloading the target fragments from the cloud storage equipment.

14. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;

a memory for storing a computer program;

a processor for implementing the method steps of any of claims 1-7 or 8-11 when executing a program stored in a memory.

15. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 7 or 8 to 11.

Technical Field

The present application relates to the field of video surveillance technology, and in particular, to a method and an apparatus for reading and writing a video file.

Background

After receiving a Video stream collected by a network camera, a conventional Network Video Recorder (NVR) converts the Video stream into a Video file and stores the Video file in a local hard disk or a Solid State Disk (SSD) of the NVR. In this way, the video file may be lost as the life of the hard disk or SSD of the computer is expired, or as the hard disk or SSD of the computer is stolen.

With the rapid development and maturity of cloud storage technology, cloud storage devices have the advantages of being convenient for centralized management, expanding storage space and preventing theft, and the adoption of the cloud storage devices to replace local hard disks or SSDs of NVRs (network video recorders) to store video files becomes a better choice.

At present, in a method for storing a video file by using a cloud storage device, an NVR integrally uploads the video file to the cloud storage device, and then the cloud storage device stores the video file. And when the video file is played back, the video file is downloaded from the whole cloud storage equipment. However, if the video file is interrupted in the process of uploading the video file to the cloud storage device by the NVR or the video file is interrupted in the process of downloading the video file from the cloud storage device by the NVR, the NVR needs to upload or download the video file again. This results in inefficient uploading and downloading of video files.

Disclosure of Invention

An object of the embodiments of the present application is to provide a method and an apparatus for reading and writing a video file, so as to improve the efficiency of uploading and downloading the video file. The specific technical scheme is as follows:

in a first aspect, an embodiment of the present application provides a video file writing method, where the method includes:

acquiring event information occurring in a plurality of video frames included in a video file, wherein the event information is obtained by carrying out image recognition on the video frames;

based on a preset fragment duration range and event information generated in the plurality of video frames, performing fragment processing on the video file to obtain a plurality of fragments;

structuring the attribute information of each fragment to obtain the structured information of each fragment, wherein the structured information of the fragments comprises the attribute information of the fragments;

and uploading the plurality of fragments to a cloud storage device based on the structural information of the fragments.

Optionally, the step of performing structural processing on the attribute information of each segment to obtain the structural information of each segment includes:

determining the priority of each fragment according to the corresponding relation between preset event information and the priority and the event information generated in each fragment;

performing structural processing on the attribute information of each fragment and the priority of each fragment to obtain the structural information of each fragment, wherein the structural information of the fragments comprises the attribute information of the fragments and the priority of the fragments;

the step of uploading the plurality of shards to a cloud storage device based on the structured information of the shards includes:

and uploading the plurality of fragments to the cloud storage device in sequence according to the sequence of the priorities included in the structured information of the fragments from high to low.

Optionally, the step of sequentially uploading the plurality of fragments to the cloud storage device according to the order from high to low of the priority included in the structured information of the fragments includes:

and according to the sequence of the priority included by the structural information of the fragments from high to low, sequentially and concurrently uploading the fragments to the cloud storage device by adopting multiple threads.

Optionally, after obtaining a plurality of fragments, the method further includes:

creating an uploading bitmap for a plurality of the fragments, wherein the bits in the uploading bitmap correspond to the fragments one by one, and the value of each bit is a first preset value;

for each fragment, if the fragment is successfully uploaded to the cloud storage device, setting the value of the bit corresponding to the fragment in the uploading bitmap as a second preset value.

Optionally, the method further includes:

after the uploading process of the plurality of fragments is interrupted, obtaining the residual fragments corresponding to the bits of the first preset value in the uploading bitmap;

uploading the remaining fragments to a cloud storage device;

after the remaining fragments are successfully uploaded to the cloud storage device, setting the value of the bit corresponding to the remaining fragments in the uploading bitmap as the second preset value.

Optionally, the slice starts with a key frame, and event information occurring in a plurality of video frames included in the slice is the same.

Optionally, the method further includes:

and uploading the structural information of the plurality of the fragments to a cloud storage device.

In a second aspect, an embodiment of the present application provides a method for reading a video file, where the method includes:

acquiring target playback information for the video file;

based on the structural information of the video file comprising a plurality of fragments, determining a target fragment corresponding to the structural information meeting the target playback information;

and downloading the target fragment from the cloud storage device.

Optionally, the structured information includes a video recording time of the segment;

the step of obtaining target playback information for the video recording file includes:

acquiring a first target video recording time indicated by a playback cursor of a video recording file;

the step of determining a target segment corresponding to the structural information meeting the target playback information based on the structural information of the plurality of segments included in the video file includes:

and determining the fragments within the preset time length taking the first target video recording time as the starting time as target fragments based on the structural information of the plurality of fragments included in the video recording file.

Optionally, the structured information includes event information occurring in the slice;

the step of obtaining target playback information for the video recording file includes:

acquiring target event information aiming at a video file;

the step of determining a target segment corresponding to the structural information meeting the target playback information based on the structural information of the plurality of segments included in the video file includes:

and determining the fragment in which the target event information occurs as a target fragment based on the structural information of the plurality of fragments included in the video file.

Optionally, the method further includes:

acquiring a second target video recording time indicated by the playback cursor of the video recording file;

and downloading the target fragments from the cloud storage equipment by taking the second target video recording time as the starting time according to the sequence of the video recording time.

In a third aspect, an embodiment of the present application provides a video file writing apparatus, where the apparatus includes:

the video recording device comprises a first acquisition unit, a second acquisition unit and a processing unit, wherein the first acquisition unit is used for acquiring event information generated in a plurality of video frames included in a video file, and the event information is obtained by carrying out image recognition on the video frames; (ii) a

The fragment unit is used for carrying out fragment processing on the video file based on a preset fragment duration range and event information generated in the plurality of video frames to obtain a plurality of fragments;

the structuring unit is used for performing structuring processing on the attribute information of each fragment to obtain the structuring information of each fragment, wherein the structuring information of the fragment comprises the attribute information of the fragment;

and the uploading unit is used for uploading the fragments to the cloud storage device based on the structural information of the fragments.

Optionally, the structuring unit is specifically configured to determine the priority of each segment according to a preset correspondence between event information and priority and event information occurring in each segment; performing structural processing on the attribute information of each fragment and the priority of each fragment to obtain the structural information of each fragment, wherein the structural information of the fragments comprises the attribute information of the fragments and the priority of the fragments;

the uploading unit is specifically configured to upload the multiple fragments to the cloud storage device in sequence according to a sequence from high to low of priorities included in the structured information of the fragments.

Optionally, the uploading unit is specifically configured to sequentially and concurrently upload the multiple fragments to the cloud storage device by using multiple threads according to a sequence from high to low of the priority included in the structured information of the fragments.

Optionally, the apparatus further comprises:

the creating unit is used for creating an uploading bitmap for the fragments after the fragments are obtained, wherein the bits in the uploading bitmap correspond to the fragments one by one, and the value of each bit is a first preset value;

and the setting unit is used for setting the value of the bit corresponding to each fragment in the uploading bitmap as a second preset value if the fragment is successfully uploaded to the cloud storage device.

Optionally, the apparatus further comprises: a second acquisition unit;

the second obtaining unit is configured to obtain, after an interruption of the uploading process of the multiple fragments, a remaining fragment corresponding to a bit of the first preset value in the upload bitmap;

the uploading unit is further used for uploading the remaining fragments to a cloud storage device;

the setting unit is further configured to set, after the remaining fragments are successfully uploaded to the cloud storage device, values of bits corresponding to the remaining fragments in the upload bitmap to the second preset value.

Optionally, the slice starts with a key frame, and event information occurring in a plurality of video frames included in the slice is the same.

Optionally, the uploading unit is further configured to upload the structured information of the plurality of segments to a cloud storage device.

In a fourth aspect, an embodiment of the present application provides a video file reading apparatus, where the apparatus includes:

an acquisition unit configured to acquire target playback information for a video file;

the determining unit is used for determining a target fragment corresponding to the structural information meeting the target playback information based on the structural information of the video file comprising a plurality of fragments;

and the downloading unit is used for downloading the target fragments from the cloud storage equipment.

Optionally, the structured information includes a video recording time of the segment;

the acquisition unit is specifically used for acquiring a first target video recording time indicated by a playback cursor of a video recording file;

the determining unit is specifically configured to determine, based on the structural information that the video file includes multiple segments, a segment within a preset duration with the first target video recording time as a start time as a target segment.

Optionally, the structured information includes event information occurring in the slice;

the acquiring unit is specifically configured to acquire target event information for a video file;

the determining unit is specifically configured to determine, based on the structural information that the video file includes multiple segments, a segment in which the target event information occurs, as a target segment.

Optionally, the obtaining unit is further configured to obtain a second target video recording time indicated by the playback cursor of the video recording file;

the downloading unit is further configured to download the target segment from a cloud storage device with the second target video recording time as a start time.

In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;

a memory for storing a computer program;

a processor configured to implement any of the method steps provided in the first aspect when executing a program stored in the memory.

In a sixth aspect, an embodiment of the present application provides an electronic device, which includes a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;

a memory for storing a computer program;

a processor configured to implement any of the method steps provided in the second aspect when executing the program stored in the memory.

In a seventh aspect, this application provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any of the method steps provided in the first aspect.

In an eighth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any of the method steps provided in the second aspect.

In a ninth aspect, embodiments of the present application provide a computer program that, when run on a computer, causes the computer to perform any of the method steps provided in the first aspect.

In a tenth aspect, embodiments of the present application provide a computer program that, when run on a computer, causes the computer to perform any of the method steps provided in the second aspect.

The embodiment of the application has the following beneficial effects:

in the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. And similarly, downloading the fragments from the cloud storage device. Under the circumstance, if the interruption occurs in the process of uploading the fragments to the cloud storage device or the interruption occurs in the process of downloading the fragments from the cloud storage device, only the corresponding fragments need to be uploaded or downloaded again, and the uploading and downloading efficiency of the video files is effectively improved.

Of course, not all advantages described above need to be achieved at the same time in the practice of any one product or method of the present application.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

Fig. 1 is a schematic structural diagram of a video file read-write system according to an embodiment of the present disclosure;

fig. 2 is a first flowchart illustrating a video file writing method according to an embodiment of the present application;

fig. 3 is a schematic flowchart of a second method for writing a video file according to an embodiment of the present disclosure;

fig. 4(a) is a schematic diagram of an upload bitmap provided in an embodiment of the present application;

FIG. 4(b) is a schematic diagram of the set upload bitmap shown in FIG. 4 (a);

fig. 5 is a schematic flow chart of a video file writing method according to an embodiment of the present application;

fig. 6 is a fourth flowchart illustrating a video file writing method according to an embodiment of the present application;

fig. 7 is a first flowchart illustrating a video file reading method according to an embodiment of the present application;

fig. 8 is a schematic flowchart of a second video file reading method according to an embodiment of the present disclosure;

fig. 9 is a schematic flowchart of a video file reading method according to an embodiment of the present application;

fig. 10 is a schematic diagram of a progress bar provided in the embodiment of the present application;

fig. 11 is a fourth flowchart illustrating a video file reading method according to an embodiment of the present application;

fig. 12 is a schematic flowchart of a fifth method for reading a video file according to an embodiment of the present application;

fig. 13 is another schematic diagram of a progress bar provided in the embodiment of the present application;

fig. 14 is a schematic structural diagram of a video file writing apparatus according to an embodiment of the present application;

fig. 15 is a schematic structural diagram of a video file reading apparatus according to an embodiment of the present application;

fig. 16 is a schematic structural diagram of a first electronic device according to an embodiment of the present application;

fig. 17 is a second structural schematic diagram of an electronic device according to an embodiment of the present application.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

NVR: and receiving the video code stream transmitted by the network camera through a network to realize monitoring and centralized storage and retrieval of audio and video data.

At present, in order to facilitate centralized management, expansion of storage space, and improvement of anti-theft performance, a cloud storage device is generally used to store video files acquired by NVR. In the method for storing the video file acquired by the NVR by using the cloud storage device, if the video file is interrupted in the process of uploading the video file to the cloud storage device by the NVR or the video file is interrupted in the process of downloading the video file from the cloud storage device by the NVR, the video file needs to be uploaded or downloaded again by the NVR. This results in inefficient uploading and downloading of video files.

In order to solve the above problem, an embodiment of the present application provides a video file read-write system, as shown in fig. 1. The system includes NVR 10 and cloud storage 11. The NVR 10 acquires a video file, acquires event information occurring in a plurality of video frames included in the video file, and the event information is obtained by performing image recognition on the video frames; based on a preset fragmentation duration range and event information generated in a plurality of video frames, performing fragmentation processing on the video file to obtain a plurality of fragments; structuring the attribute information of each fragment to obtain the structured information of each fragment; and uploading the plurality of fragments to the cloud storage device 11 based on the structural information of the fragments. The cloud storage device 11 stores the fragments uploaded by the NVR 10.

When playing back the video file, the NVR 10 acquires target playback information for the video file; based on the structural information of a plurality of fragments included in the video file, determining a target fragment corresponding to the structural information meeting the target playback information; the target segment is downloaded from the cloud storage 11. And further, the playback of the video files is realized.

In the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. And similarly, downloading the fragments from the cloud storage device. Under the circumstance, if the interruption occurs in the process of uploading the fragments to the cloud storage device or the interruption occurs in the process of downloading the fragments from the cloud storage device, only the corresponding fragments need to be uploaded or downloaded again, and the uploading and downloading efficiency of the video files is effectively improved.

Based on the video file read-write system, the embodiment of the application provides a video file write method and a video file read method. The following describes in detail a video file writing method and a video file reading method provided in the embodiments of the present application, respectively, by specific embodiments.

Referring to fig. 2, fig. 2 is a schematic flowchart of a video file writing method according to an embodiment of the present disclosure. The video file writing method can be applied to the NVR 10 shown in the figure or a device with NVR function. For convenience, NVR is taken as the main implementation body for the sake of convenience, and is not limited. The video file writing method comprises the following steps.

Step 21, acquiring event information occurring in a plurality of video frames included in the video file, wherein the event information is obtained by performing image recognition on the video frames.

In the embodiment of the application, the video file may be generated by the NVR based on a video stream transmitted by the network camera, may also be obtained by the NVR from a database of a preset video file, and may also be input by the user. This is not particularly limited. Event information includes, but is not limited to: the information of no event, the information of mobile detection video event, the information of human face event, the information of vehicle event, the information of intrusion event and the information of alarm event, etc.

In one embodiment, a video file includes a plurality of video frames. When the video file is stored, the NVR extracts one video frame from the video file every other preset number of video frames, and performs image recognition on the extracted video frames to further obtain event information occurring in the extracted video frames.

In another embodiment, the video file includes a plurality of video frames and event information occurring in the plurality of video frames. Specifically, the NVR receives video frames transmitted by the network camera, and performs image recognition on the received video frames every preset number of video frames, thereby obtaining event information occurring in the extracted video frames. And generating a video file based on all the received video frames and event information obtained by carrying out image recognition on the video frames. When the video file is stored, the NVR directly acquires event information generated in a plurality of video frames from the video file.

The preset number may be set according to actual requirements, for example, the preset number may be 0, 1, 2, and the like. The event information is obtained by analyzing every preset number of video frames, and the occurrence of the event information generally disappears after a period of time, so that it can be understood that after the event information a occurring in one video frame is obtained by performing image recognition on the one video frame, the event information a occurs in the preset number of video frames until the next video frame for performing image recognition.

In the embodiment of the present application, the convolutional neural network may be used to perform image recognition on the video frame, and other image recognition algorithms may also be used to perform image recognition on the video frame, which is not specifically limited.

And step 22, based on the preset fragment duration range and event information occurring in a plurality of video frames, performing fragment processing on the video file to obtain a plurality of fragments.

In the embodiment of the present application, the segment duration is the total playing duration of the video frames included in the segment. A fragmentation duration range is preset in the NVR, that is, a fragmentation duration range is preset. And the NVR carries out fragmentation processing on the video file based on the preset fragmentation duration range and event information generated in a plurality of video frames included by the video file to obtain a plurality of fragments. Here, the fragments are not overlapped, and a plurality of fragments are spliced together according to the sequence of the video recording time, so that a complete video file can be obtained.

In the embodiment of the application, the size of the preset fragmentation time length range can be set according to actual requirements, for example, the preset fragmentation time length range can be 0-30 seconds, 10-30 seconds and the like. The slicing rule based on the preset slicing time length range and the event information occurring in a plurality of video frames can be set according to actual requirements.

In one example, the fragmentation rule may be: the fragmentation time length of one fragment is in a preset fragmentation time length range, and the quantity of event information occurring in one fragment is less than or equal to a preset event threshold value. The event information occurring in the slice is the event information occurring in the video frames included in the slice.

In another example, the fragmentation rule may be: the slice duration of one slice is within the preset slice duration range, and the number of event information occurring in one slice is 1, that is, the event information occurring in each video frame included in one slice is the same. The event information occurring in the slice is the event information occurring in the video frames included in the slice.

For example, a video file includes 1500 video frames, each of which has a play duration of 40 milliseconds. According to the sequence of the video recording time, the event information occurring in the 1500 video frames is as follows:

event information occurring in the 1 st to 300 th video frames is no event;

event information occurring in 301 th to 1100 th video frames is a vehicle event;

the event information occurring in the 1101-1500 th video frame is a face event.

The total playing time of the 1 st to 300 th video frames is 300 × 40 ms 12000 ms 12 seconds. 0<12<30, and dividing the 1 st to 300 th video frames into a slice 1. The total playing duration of the 301-1100 video frames is (1100-300) × 40 ms-32000 ms-32 s. And 32>30, dividing the video frames of the first 30 seconds in the 301-1100 video frames into a slice 2, wherein the 30 seconds are 1000/40 ═ 750, and the 300+750 ═ 1050, namely dividing the 301-1050 video frames into a slice 2, and dividing the remaining 2 seconds video frames into a slice 3, namely dividing the 1051-1100 video frames into a slice 3. The total playing time length of the 1101-1500 th video frames is 400 × 40 ms 16000 ms 16 seconds. 0<16<30, and the 1101-1500 th video frame is divided into one slice 4.

And step 23, performing structuring processing on the attribute information of each fragment to obtain the structured information of each fragment, wherein the structured information of the fragment comprises the attribute information of the fragment.

In the embodiment of the present application, the attribute information of a segment includes, but is not limited to: the fragment User Identification (UID) to which the fragment belongs, the fragment number, the offset start, the length size, the start time, the end time, the event description, and the like.

The segment UID to which the segment belongs refers to the UID of the original video file to which the segment belongs. And associating the fragments with the original video file through the fragments UID to which the fragments belong.

And a fragment number indicating that the fragment is the first fragment. In one example, the earlier the recording time of a slice, the smaller the slice number.

Offset Start refers to the offset of a slice corresponding to the start of the original video file. The slice can be accurately positioned by offsetting the start.

The length size refers to the length of the slice to be small.

The start time refers to the starting video recording time of the segment.

The ending time refers to the ending video recording time of the segment. The difference between the ending time and the starting time is the playing time length of the sub-slice.

The event description refers to the description of event information occurring in the slice. Such as face attributes, face models, license plate models of vehicles, etc.

After obtaining the plurality of fragments of the video file, the NVR extracts the attribute information of each fragment, and performs structuring processing on the attribute information of each fragment to obtain the structured information of each fragment. For example, the attribute information of a fragment includes a fragment UID to which the fragment belongs, a fragment number, an offset start, a length size, a start time, an end time, and an event description, and the NVR performs a structuring process on the attribute information of the fragment to obtain structured information, as shown in table 1.

TABLE 1

In an embodiment of the present application, each segment starts with a key frame, that is, an I frame, which ensures that each segment can be played independently, and can be played after the segment is downloaded.

In another embodiment of the present application, the slice does not start with a key frame. In this case, the attribute information of the segment may further include an associated segment. The associated slice includes key frames that enable the device to correctly decode the video frames in the current slice. When downloading a fragment, the NVR also needs the fragment associated with the fragment to ensure normal playing of the fragment.

And 24, uploading the plurality of fragments to the cloud storage device based on the structural information of the fragments.

In the embodiment of the application, the NVR uploads the multiple fragments of the obtained video file to the cloud storage device based on the structural information of the multiple fragments. The cloud storage device correspondingly stores the plurality of fragments and the structural information of the plurality of fragments. In this way, when the video file is played back subsequently, the NVR may download the plurality of fragments from the cloud storage device based on the structured information of the fragments.

In one example, the structural information of the slice includes a video start time of the slice. And the NVR uploads the plurality of fragments to the cloud storage device according to the sequence of the video starting time of the fragments from morning to evening included in the structural information of the fragments.

In the embodiment of the present application, the video file read-write system further includes other devices in addition to the NVR. In order to facilitate other devices to download the video files, the NVR may also upload the structured information of the plurality of segments to the cloud storage device. When other equipment downloads the video files, the other equipment can download the structural information of the multiple fragments from the cloud storage equipment, and then download the fragments from the cloud storage equipment based on the structural information, so that the other equipment can conveniently download the fragments.

In an embodiment of the application, after the NVR uploads the plurality of fragments to the cloud storage device in sequence, the structured information of the plurality of fragments is uploaded to the cloud storage device, so that the problem that the fragments cannot be uploaded according to the structured information after the fragment uploading process is interrupted is solved.

In an embodiment of the application, the NVR may compose the structured information of the plurality of fragments into a fragment index file, and upload the fragment index file to the cloud storage device. And the cloud storage device correspondingly stores the plurality of fragments and the fragment index file. When the video file is played back subsequently, the NVR or other equipment can directly download the fragment index file, so that the structured information of the plurality of fragments is obtained, and the efficiency of structured information downloading is improved.

In the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. Under the circumstance, if interruption occurs in the process of uploading the fragments to the cloud storage device, only the rest fragments need to be uploaded again, and the efficiency of uploading the video files is effectively improved.

Based on the video file writing method shown in fig. 2, an embodiment of the present application further provides a video file writing method. As shown in fig. 3, step 23 of the video file writing method can be subdivided into step 231 and step 232, and step 24 can be subdivided into step 241. Specifically, as follows, the following description will be given,

step 231, determining the priority of each segment according to the corresponding relationship between the preset event information and the priority and the event information occurring in each segment.

In the embodiment of the application, the priority of the fragmentation can be divided into three levels, namely high, medium and low, and can also be divided into 1, 2, 3, 4 and the like.

The NVR presets a correspondence between event information and priority. Taking the example that the priority of the fragmentation can be divided into high, medium and low, the correspondence relationship between the preset event information and the priority can be shown in table 2.

TABLE 2

The dividing mode of the priority of the specific event information can be set according to the actual requirement.

After determining the event information occurring in each segment of the video file, the NVR determines the priority corresponding to the event information occurring in each segment from the preset correspondence between the event information and the priority, where the determined priority is the priority of the segment.

In one example, if there is one piece of event information occurring in a segment, the NVR determines, from a preset correspondence between event information and priority, that the priority corresponding to the event information is the priority of the segment.

In another example, if a plurality of event information occurs in a segment, the NVR determines a priority corresponding to each event information from a preset correspondence between the event information and the priority; the highest priority is selected as the priority of the slice.

Step 232, performing structural processing on the attribute information of each segment and the priority of each segment to obtain structural information of each segment, where the structural information of a segment includes the attribute information of the segment and the priority of the segment.

In the embodiment of the application, the NVR performs structured processing on the attribute information of each segment and the priority of each segment to obtain structured information of each segment.

For example, the attribute information of a fragment includes a fragment UID to which the fragment belongs, a fragment number, an offset start, a length size, a start time, an end time, and an event description, and the NVR performs a structuring process on the attribute information of the fragment to obtain structured information, as shown in table 3.

TABLE 3

Figure BDA0002548674540000141

And 241, sequentially uploading the plurality of fragments to the cloud storage device according to the sequence of the priorities included in the structured information of the fragments from high to low.

In the embodiment of the application, the NVR performs fragmentation processing on the video file to obtain a plurality of fragments, and the priorities of the plurality of fragments may be completely the same or not. In this case, the NVR sequentially uploads the plurality of shards to the cloud storage device in an order from high to low in priority included in the structured information of the shards. For example, the NVR adds the fragments to the upload queue in the order of the priority included in the structured information of the fragments from high to low, and the NVR uploads the fragments in the upload queue to the cloud storage device.

In this way, the NVR preferentially uploads the high-priority fragments. The higher the priority of the fragments is, the more important the data in the fragments is, the higher the priority of the fragments is uploaded preferentially, so that the priority storage of the important data is ensured, the probability of losing the important data is reduced, and the safety of the important data is improved.

In an embodiment of the application, after the NVR uploads the plurality of fragments to the cloud storage device in sequence, the structured information of the plurality of fragments is uploaded to the cloud storage device, so that the problem that the fragments cannot be uploaded in the order from high to low according to the priority after the fragment uploading process is interrupted is avoided, and the security of important data is further improved.

In an embodiment of the application, the step 241 may specifically be that, according to an order from high to low of priorities included in the structured information of the fragments, multiple fragments are sequentially and concurrently uploaded to the cloud storage device by using multiple threads. In the NVR, the multi-thread uploading fragments are adopted, and a plurality of fragments can be uploaded to the cloud storage device concurrently, so that the fragment uploading efficiency is further improved.

In an embodiment of the application, in order to facilitate control of fragment uploading, after obtaining a plurality of fragments, the NVR creates an uploading bitmap for the plurality of fragments, bits in the uploading bitmap correspond to the fragments one by one, and a value of each bit is a first preset value; for each fragment, if the fragment is successfully uploaded to the cloud storage device, setting the value of the bit corresponding to the fragment in the uploading bitmap as a second preset value. The first preset value indicates that the fragments are not uploaded to the storage device, and the second preset value indicates that the fragments are successfully uploaded to the storage device. The first preset value and the second preset value can be set according to actual needs. And when the values of all the bits in the uploading bitmap are the second preset values, all the fragments of the video file are uploaded to the cloud storage device, and the uploading of the video file is completed.

For example, the first preset value is 0, and the second preset value is 1. There are 45 slices of video files. The upload bitmap created based on this is as shown in fig. 4 (a). Each rectangle in fig. 4(a) represents a bit, and the initial value of the bit is 0, that is, all fragments of the video file are not successfully uploaded to the cloud storage device. After the 1 st, 3 rd, 4 th, 7 th and 8 th fragments of the video file are successfully uploaded to the cloud storage device, setting the bit values corresponding to the 1 st, 3 rd, 4 th, 7 th and 8 th fragments in the uploading bitmap as 1. As shown in fig. 4(a), the 1 st row and 1 st column rectangular boxes represent the 1 st slice, the 1 st row and 3 rd column rectangular boxes represent the 3 rd slice, the 1 st row and 4 th column rectangular boxes represent the 4 th slice, the 1 st row and 7 th column rectangular boxes represent the 7 th slice, the 1 st row and 8 th column rectangular boxes represent the 8 th slice, and the values of the 1 st row and 1 st column rectangular boxes, the 1 st row and 3 th column rectangular boxes, the 1 st row and 4 th column rectangular boxes, the 1 st row and 7 th column rectangular boxes and the 1 st row and 8 th column rectangular boxes are set to 1, so as to obtain the upload bitmap after the 1 st, 3 rd, 4 th, 7 th and 8 th slices of the video file are successfully uploaded to the cloud storage device, as shown in fig. 4 (b).

In the embodiment of the application, the uploading state of the fragments can be conveniently and quickly determined by uploading the bitmap, and the problem of repeated uploading or missing of the fragments is avoided.

Due to network interruption or equipment abnormality and the like, fragment uploading of the video file fails, and the fragment uploading process is interrupted. In an embodiment of the application, in order to ensure that a video file uploaded to a cloud storage device is complete and improve the uploading efficiency of the video file, after the uploading process of a plurality of fragments is interrupted and after network recovery or abnormal recovery of the device occurs, the NVR searches for a bit of a first preset value in an uploading bitmap, and uses the fragment corresponding to the found bit of the first preset value as a remaining fragment. The remaining slices may be one or more. And the NVR uploads the obtained residual fragments to the cloud storage device. As described above, the NVR sequentially and concurrently uploads the remaining fragments to the cloud storage device by using multiple threads according to the order of the priorities included in the structured information of the remaining fragments from high to low. After the remaining fragments are successfully uploaded to the cloud storage device, the NVR sets the bit values corresponding to the remaining fragments in the upload bitmap to a second preset value. And when the values of all the bits in the uploading bitmap are the second preset values, all the fragments of the video file are uploaded to the cloud storage device, and the uploading of the video file is completed.

In the embodiment of the application, the breakpoint continuous transmission of the fragments is realized according to the uploading bitmap, only the fragments (namely, the remaining fragments) which are not successfully uploaded to the cloud storage device need to be uploaded to the cloud storage device again, all the fragments of the video file do not need to be retransmitted, and the uploading efficiency of the video file is further improved.

The following describes in detail the video file writing method provided in the embodiment of the present application with reference to the flowchart of the video file writing method shown in fig. 5 and fig. 6. The first preset value is 0, and the second preset value is 1.

Step 51, after the uploading of the video file is started, the NVR performs fragment preprocessing on the video file to obtain a plurality of fragments of the video file, the structural information of each fragment, and an uploading bitmap, wherein bits in the uploading bitmap correspond to the fragments one by one, and the value of each bit is 0.

Specifically, the fragment preprocessing may include: carrying out image recognition on a plurality of video frames included in the video file, and determining event information occurring in the plurality of video frames; based on a preset fragmentation duration range and event information generated in a plurality of video frames, performing fragmentation processing on the video file to obtain a plurality of fragments; determining the priority of each fragment according to the corresponding relation between the preset event information and the priority and the event information generated in each fragment; extracting attribute information of each fragment, and performing structuring processing on the attribute information of each fragment and the priority of each fragment to obtain the structured information of each fragment; and creating an upload bitmap for the plurality of segments.

And step 52, requesting the fragment uploading from the cloud storage device by the NVR according to the allocated operation identifier.

And step 53, after the request fragments are successfully uploaded, the NVR sequentially adds the fragments into the uploading queue according to the sequence of the priorities of the fragments from high to low.

And step 54, the NVR uploads the fragments in the uploading queue to the cloud storage device in a concurrent mode by adopting multiple threads.

And step 55, successfully uploading each fragment to the cloud storage device, and setting the value of the bit corresponding to the fragment in the uploading bitmap to be 1 by the NVR.

And 56, when the values of all the bits in the uploading bitmap are 1, uploading the fragmented structured information to the cloud storage device by the NVR. And at the moment, uploading of the video file is completed.

If the fragment uploading fails due to network interruption or equipment abnormity in the concurrent fragment uploading process, the fragment breakpoint is continuously transmitted after the network is recovered or the equipment is abnormally recovered. With particular reference to the flow shown in fig. 6.

And 61, searching the 0 bit in the uploading bitmap by the NVR, and taking the fragment corresponding to the searched 0 bit as the residual fragment. The remaining slices may be one or more.

Step 62, requesting the cloud storage device for fragment uploading by the operation identifier uploaded by the last fragment of the NVR.

And step 63, after the request fragment is successfully uploaded, sequentially adding the remaining fragments into the uploading queue by the NVR according to the sequence of the priorities of the remaining fragments from high to low.

And step 64, the NVR uploads the fragments in the uploading queue to the cloud storage device in a concurrent mode by adopting multiple threads.

And step 65, each fragment is successfully uploaded to the cloud storage device, and the NVR sets the value of the bit corresponding to the fragment in the upload bitmap to 1.

And step 66, when the values of all the bits in the upload bitmap are 1, uploading the fragmented structured information to the cloud storage device by the NVR. And at the moment, uploading of the video file is completed.

The description of steps 51-56 and steps 61-66 above is relatively simple and reference is made in particular to the description relating to fig. 2-4 above.

Based on the video file writing method shown in fig. 2 to 6, the embodiment of the present application further provides a video file reading method. Referring to fig. 7, fig. 7 is a first flowchart illustrating a video file reading method according to an embodiment of the present application. The video file reading method can be applied to the NVR 10 shown in the figure or a device with NVR function. For convenience, NVR is taken as the main implementation body for the sake of convenience, and is not limited. The video file reading method comprises the following steps.

Step 71, target playback information for the video file is acquired.

In the embodiment of the application, when the video file needs to be played back, the NVR acquires target playback information for the video file. Playback information may be understood as playback conditions, and may include playback time, playback event, and the like. The playback time is the video recording time of the segment needing to be played back, and the playback event is event information occurring in the segment needing to be played back.

And 72, determining a target fragment corresponding to the structural information meeting the target playback information based on the structural information of the plurality of fragments included in the video file.

In the embodiment of the present application, the video file includes a plurality of segments, and each segment has a piece of structural information, as shown in table 3 above. The structural information of the fragments may be pre-stored in the NVR, may also be input into the NVR for a user, and may also be downloaded from the cloud storage device for the NVR.

After the video file comprises the structural information of the plurality of fragments, the NVR matches the target playback information with the structural information of the plurality of fragments, the structural information meeting the target playback information is determined from the structural information of the plurality of fragments of the video file, and the fragment corresponding to the determined structural information is the target fragment. The target shards may be one or more.

And 73, downloading the target fragment from the cloud storage device.

In the embodiment of the application, the NVR can download the target fragments from the cloud storage device one by one according to the sequence of the video recording time, so that the fluency of downloading the single fragments is improved, and the fluency of playback of the fragments is improved. Here, the recording time may be the recording time of any video frame in the slice.

For example, target segments satisfying the target playback information include: slice 1, 2, 3. And sequencing the 1 st, 2 nd and 3 rd slices according to the sequence of the video recording time, wherein the sequencing result is the 1 st slice → the 2 nd slice → the 3 rd slice. And the NVR downloads the 1 st fragment from the cloud storage device, then downloads the 2 nd fragment and then downloads the 3 rd fragment.

In the embodiment of the application, the NVR may also concurrently download the plurality of target segments from the cloud storage device by using multiple threads, so as to improve the downloading efficiency.

For example, target segments satisfying the target playback information include: slice 1, 2, 3. And sequencing the 1 st, 2 nd and 3 rd slices according to the sequence of the video recording time, wherein the sequencing result is the 1 st slice → the 2 nd slice → the 3 rd slice. And the NVR starts the 2-thread downloading fragment, then the 1 st fragment and the 2 nd fragment can be downloaded from the cloud storage device in a concurrent manner, and then the 3 rd fragment is downloaded.

In the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. And similarly, downloading the fragments from the cloud storage device. Under the condition, if the interruption occurs in the process of downloading the fragments from the cloud storage device, only the corresponding fragments need to be downloaded again, so that the efficiency of downloading the video files is effectively improved.

In one embodiment of the present application, the structured information includes the recording time of the segment. The playback information includes the recording time indicated by the playback cursor. Based on this, referring to the flowchart of the video file reading method shown in fig. 8, in this method, the step 71 may be subdivided into a step 711, and the step 72 may be subdivided into a step 721, which is specifically as follows.

In step 711, the first target video recording time indicated by the playback cursor of the video recording file is obtained.

In the embodiment of the application, the user can input the initial playback time of the video file needing to be played back into the NVR. And the NVR receives the initial playback time input by the user, takes the initial playback time as the first target video recording time, and drags the playback cursor to the first target video recording time.

In the embodiment of the application, the user can also drag the playback cursor of the progress bar of the video file displayed by the NVR, and drag the playback cursor to the position of the initial playback time needing to be played back. The NVR quickly locates to the first target recording time indicated by the playback cursor for the video file based on the position of the playback cursor on the progress bar.

In step 721, based on the structural information that the video file includes multiple segments, the segments within the preset duration with the first target video recording time as the start time are determined as the target segments.

The structured information includes the recording time of the segment. After the first target video recording time is determined, the NVR determines the fragments within the preset time length taking the first target video recording time as the starting time as the target fragments based on the structural information that the video file comprises the plurality of fragments. The preset duration can be set according to actual requirements. For example, the preset time period may be 2 minutes, 3 minutes, or the like.

Specifically, the step 721 may specifically be: and determining a target time period of preset duration taking the first target video recording time as the starting time. Based on the fact that the video file comprises the structural information of the plurality of fragments, the NVR determines the fragment with intersection between the video time period and the target time period as the target fragment. The video recording time period is a time period formed by the starting video recording time and the ending video recording time of the fragment.

For example, the target time period is 10 minutes 20 seconds to 15 minutes 20 seconds. The initial recording time of segment 1 is 10 minutes, and the end recording time of segment 1 is 11 minutes. In this case, the NVR may determine that the video period of segment 1 intersects with the target period, and segment 1 is the target segment.

And after the NVR acquires the target fragment from the cloud storage device, playing back the target fragment, and moving the position of the playback cursor on the progress bar along with the playback of the target fragment. After a period of time, when the NVR caches and the video recording duration of the target segment that is not played back is less than the preset duration, the NVR may re-execute steps 711 and 721, re-determine the target segment, and download the re-determined target segment that is not cached by the NVR from the cloud storage device. Therefore, the sufficient fragmentation of the cache in the NVR is ensured, the playback of the video file is smooth, and the efficiency of data access and downloading is improved.

The following describes in detail the video file reading method according to the embodiment of the present application with reference to the flowchart of the video file reading method shown in fig. 9 and the schematic of the progress bar shown in fig. 10. The preset time period is 2 minutes.

Step 91, for the video file, the NVR obtains the first target video recording time indicated by the current playback cursor. As shown in FIG. 10, the user drags the playback cursor to t of the progress bar1To (3). NVR acquires that the first target video recording time is t1

Step 92, NVR detects whether t has been downloaded from the cloud storage device1-t2Fragmentation within these 2 minutes. If yes, wait for a period of time (e.g., wait for 10 seconds), and then re-execute step 91. If not, go to step 93.

Step 93, NVR retrieves the structural information of the segment and determines that the video file is in t1-t2The uncached slices in these 2 minutes.

At step 94, the NVR requests a fragmented download from the cloud storage device.

Step 95, the NVR downloads the determined shards from the cloud storage device. After waiting for a period of time (e.g., 10 seconds), step 91 is re-executed.

The NVR downloads only the determined fragment. And along with the playing of the fragments, the playback cursor moves on the progress bar, and then the NVR continuously downloads the fragments.

In the embodiment of the application, the fragments are loaded as required, are continuously played, and then the fragments of the subsequent video recording time are continuously loaded, so that all complete videos do not need to be downloaded, and the data access downloading efficiency is improved.

In one embodiment of the present application, the structured information includes event information occurring in the slice. The playback information includes event information. Based on this, referring to the flowchart of the video file reading method shown in fig. 11, in this method, the step 71 may be subdivided into a step 712, and the step 72 may be subdivided into a step 722, which is specifically described as follows.

In step 712, target event information for the video file is obtained.

In the embodiment of the application, the user can input the time information generated in the segment needing to be played back into the NVR. Such as human faces, vehicles, license plates, etc. The NVR receives event information input by a user, and takes the event information as target event information.

In the embodiment of the application, the target event information may also be sent to the NVR by other devices. The manner of acquiring the target event information is not limited.

Step 722, based on the structural information that the video file includes a plurality of segments, determining the segment in which the target event information occurs as the target segment.

The structured information includes event information for the tiles. After the target event information is determined, the NVR determines the fragment in which the target event information occurs to be the target fragment based on the structural information that the video file comprises a plurality of fragments.

The target shards may be one or more.

And after the NVR acquires the target fragment from the cloud storage device, playing back the target fragment. At the moment, the required fragment is accurately and efficiently positioned according to the event information, and the NVR only plays back the target fragment with the target event information, so that the computing resource is saved.

In an embodiment of the application, after the NVR acquires the target event information, the NVR may acquire a second target video recording time indicated by a playback cursor for the video recording file. And the NVR downloads the target fragment from the cloud storage equipment by taking the second target video recording time as the starting time.

The following describes in detail the video file reading method according to the embodiment of the present application with reference to the flowchart of the video file reading method shown in fig. 12 and the schematic diagram of the progress bar shown in fig. 13.

In step 121, the NVR acquires target event information for the video file. For example, the target event information is a face event. Here, the target event information is the playback condition.

And step 122, the NVR retrieves the structural information of the fragments and determines the fragments with the face events as target fragments. As shown in fig. 13, NVR determines that a target segment of a face event includes t11-t12、t13-t14、t15-t16And (4) inner slicing.

And step 123, the NVR updates the progress bar based on the retrieved video recording time of the fragments. And only the fragments meeting the target event information are guaranteed to be played.

Step 124, NVR downloads t from cloud storage11-t12、t13-t14、t15-t16And (4) inner slicing.

The NVR control fragment is played along with the movement of the playback cursor, and only the fragment meeting the target event information is played, namely only t is played11-t12、t13-t14、t15-t16And (4) inner slicing. And if the user drags the playback cursor, the NVR determines second target video recording time indicated by the playback cursor, and downloads the target fragment from the cloud storage device by taking the second target video recording time as starting time.

In the embodiment of the application, the fragments are loaded as required, are continuously played, and then the fragments of the subsequent video recording time are continuously loaded, so that all complete videos do not need to be downloaded, and the data access downloading efficiency is improved.

Corresponding to the embodiment of the video file writing method, the embodiment of the application also provides a video file writing device. Referring to fig. 14, fig. 14 is a schematic structural diagram of a video file writing apparatus according to an embodiment of the present application. The device may be located on the NVR. The video file writing device may include:

a first obtaining unit 141, configured to obtain event information occurring in a plurality of video frames included in a video file, where the event information is obtained by performing image recognition on the video frames;

the fragmentation unit 142 is configured to perform fragmentation processing on the video file based on a preset fragmentation duration range and event information occurring in a plurality of video frames to obtain a plurality of fragments;

the structuring unit 143 is configured to perform structuring processing on the attribute information of each segment to obtain the structured information of each segment, where the structured information of each segment includes the attribute information of the segment;

and an uploading unit 144, configured to upload the multiple shards to the cloud storage device based on the structured information of the shards.

In an embodiment, the structuring unit 143 is specifically configured to determine the priority of each segment according to a preset correspondence between event information and priority and event information occurring in each segment; performing structuralization processing on the attribute information of each fragment and the priority of each fragment to obtain the structuralization information of each fragment, wherein the structuralization information of the fragments comprises the attribute information of the fragments and the priority of the fragments;

the uploading unit 144 may be specifically configured to upload the multiple fragments to the cloud storage device sequentially according to the order from high to low of the priority included in the structured information of the fragments.

In an embodiment, the uploading unit 144 may be specifically configured to sequentially and concurrently upload the multiple fragments to the cloud storage device by using multiple threads according to the order from high to low of the priority included in the structured information of the fragments.

In an embodiment, the video file writing apparatus may further include:

the creating unit is used for creating an uploading bitmap for the plurality of fragments after the plurality of fragments are obtained, bits in the uploading bitmap correspond to the fragments one by one, and the value of each bit is a first preset value;

and the setting unit is used for setting the value of the bit corresponding to each fragment in the uploading bitmap as a second preset value if the fragment is successfully uploaded to the cloud storage device.

In an embodiment, the video file writing apparatus may further include a second obtaining unit;

the second acquisition unit is used for acquiring the residual fragments corresponding to the bits of the first preset value in the uploading bitmap after the uploading process of the plurality of fragments is interrupted;

the uploading unit 144 may be further configured to upload the remaining fragments to the cloud storage device;

and the setting unit is further used for setting the value of the bit corresponding to the remaining fragment in the uploading bitmap as a second preset value after the remaining fragment is successfully uploaded to the cloud storage device.

In one embodiment, the slice starts with a key frame and the slice includes the same event information occurring in multiple video frames.

In an embodiment, the uploading unit 144 may be further configured to upload the structured information of the plurality of segments to the cloud storage device.

In the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. . Under the circumstance, if interruption occurs in the process of uploading the fragments to the cloud storage device, only the corresponding fragments need to be uploaded again, and the efficiency of uploading the video files is effectively improved.

Corresponding to the embodiment of the video file reading method, the embodiment of the application also provides a video file reading device. Referring to fig. 15, fig. 15 is a schematic structural diagram of a video file reading apparatus according to an embodiment of the present disclosure. The device may be located on the NVR. The video file reading device may include:

an acquisition unit 151 for acquiring target playback information for a video recording file;

a determining unit 152, configured to determine, based on the structural information that the video file includes multiple segments, a target segment corresponding to the structural information that satisfies the target playback information;

and a downloading unit 153, configured to download the target segment from the cloud storage device.

In one embodiment, the structured information may include the recording time of the segment;

an obtaining unit 151, which may be specifically configured to obtain a first target video recording time indicated by a playback cursor for a video recording file;

the determining unit 152 may be specifically configured to determine, based on the structural information that the video file includes multiple segments, a segment within a preset duration taking the first target video recording time as the start time as a target segment.

In one embodiment, the structured information may include event information occurring in the slice;

an obtaining unit 151, which may be specifically configured to obtain target event information for a video recording file;

the determining unit 152 may be specifically configured to determine, based on the structural information that the video file includes multiple segments, a segment in which the target event information occurs, as the target segment.

In an embodiment, the obtaining unit 151 may be further configured to obtain a second target video recording time indicated by the playback cursor for the video recording file;

the downloading unit 153 may further be configured to download the target segment from the cloud storage device with the second target video recording time as a start time.

In the technical scheme provided by the embodiment of the application, the video file is divided into a plurality of fragments based on the preset fragment duration range and event information occurring in a plurality of video frames, and the plurality of fragments are uploaded to the cloud storage device. And similarly, downloading the fragments from the cloud storage device. Under the circumstance, if the interruption occurs in the process of downloading the fragments from the cloud storage device, only the corresponding fragments need to be downloaded again, and the efficiency of downloading the video files is effectively improved.

Corresponding to the above video file writing method embodiment, an embodiment of the present application further provides an electronic device, as shown in fig. 16, including a processor 161, a communication interface 162, a memory 163, and a communication bus 164, where the processor 161, the communication interface 162, and the memory 163 complete communication with each other through the communication bus 164;

a memory 163 for storing a computer program;

the processor 161 is configured to implement any of the steps of the video file writing method shown in fig. 2 to 6 when executing the program stored in the memory 163.

Corresponding to the above video file reading method embodiment, an embodiment of the present application further provides an electronic device, as shown in fig. 17, including a processor 171, a communication interface 172, a memory 173, and a communication bus 174, where the processor 171, the communication interface 172, and the memory 173 complete communication with each other through the communication bus 174;

a memory 173 for storing computer programs;

the processor 171 is configured to implement any one of the steps of the video file reading method shown in fig. 7 to 13 when executing the program stored in the memory 173.

The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.

The communication interface is used for communication between the electronic equipment and other equipment.

The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.

The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.

In yet another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program realizes any step of the video file writing method shown in fig. 2 to 6 when being executed by a processor.

In yet another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program realizes any step of the video file reading method shown in fig. 7 to 13 when being executed by a processor.

In yet another embodiment provided by the present application, there is also provided a computer program which, when run on a computer, causes the computer to perform any of the steps of the video file writing method shown in fig. 2-6.

In yet another embodiment provided by the present application, there is also provided a computer program which, when run on a computer, causes the computer to perform any of the steps of the video file reading method shown in fig. 7-13.

In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the embodiments of the video file read/write apparatus, the electronic device, the computer-readable storage medium, and the computer program, since they are substantially similar to the embodiments of the method, the description is relatively simple, and the relevant points can be referred to the partial description of the embodiments of the method.

The above description is only for the preferred embodiment of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

27页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种像素数据处理方法和集成芯片

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类