CN108833817B - Video data storage method and device - Google Patents

Video data storage method and device Download PDF

Info

Publication number
CN108833817B
CN108833817B CN201810679732.6A CN201810679732A CN108833817B CN 108833817 B CN108833817 B CN 108833817B CN 201810679732 A CN201810679732 A CN 201810679732A CN 108833817 B CN108833817 B CN 108833817B
Authority
CN
China
Prior art keywords
frame
writing
index
code stream
video data
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
Application number
CN201810679732.6A
Other languages
Chinese (zh)
Other versions
CN108833817A (en
Inventor
杨世增
周胜斯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN201810679732.6A priority Critical patent/CN108833817B/en
Publication of CN108833817A publication Critical patent/CN108833817A/en
Application granted granted Critical
Publication of CN108833817B publication Critical patent/CN108833817B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • H04N5/78Television signal recording using magnetic recording
    • H04N5/781Television signal recording using magnetic recording on disks or drums

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

A video data storage method and device are provided, the method comprises: writing a first I frame index frame after writing at least one code stream frame in a video data file, wherein the writing position of an I frame included in the at least one code stream frame in the video data file and the writing position of a next I frame index frame adjacent to the first I frame index frame are recorded in the first I frame index frame, and the writing position of the first I frame index frame is determined according to the writing position of the I frame index frame recorded in the last I frame index frame adjacent to the first I frame index frame. After the first I frame index frame and at least one code stream frame are continuously written, when the writing position of the next I frame index frame recorded in the first I frame index frame is reached, a second I frame index frame is written, and the writing position of the I frame in the video data file and the writing position of the next I frame index frame adjacent to the second I frame index frame, which are included in at least one code stream frame which is continuously written, are recorded in the second I frame index frame.

Description

Video data storage method and device
Technical Field
The present application relates to the field of video storage, and in particular, to a method and an apparatus for storing video data.
Background
The core function of a Network Video Recorder (NVR) is to store video data collected by a front-end encoder, and the standard of video data encoding format in the industry is H264, which includes three frame types of I/P/B, where an I frame (I frame) is an independently decodable video frame, and a P/B frame needs to be decoded by relying on an adjacent I or P frame.
In the process of storing a video data file in a hard disk, in addition to writing a code stream frame, I-frame index information needs to be written for fast playback positioning, and a time stamp, a position and a frame length of a corresponding I-frame are recorded in the I-frame index information. In the video playback process, when a user needs to locate a video at a certain time point, the video data at the time point can be conveniently found according to the I frame index information without traversing the whole video file to find. Therefore, a video data file is constructed based on the structured bitstream frames and the I-frame index information.
In the prior art, in the process of storing video data, a fixed-size header space is allocated in a file, then bitstream frames are written in sequence, if the bitstream frames are I-frames, the header of the file is skipped back, corresponding I-frame index information is written, and then the bitstream frames are continuously written. The defects of the prior art are as follows: in the process of writing in the code stream frame, the head of the jump-back file is needed to write in the index information of the corresponding I frame, which causes frequent jump of the magnetic head of the hard disk and frequent flash of the data cache region. Moreover, the size of the file head is fixed, and the number of pieces of written I-frame index information is limited.
Disclosure of Invention
The embodiment of the application provides a video data storage method and a video data storage device, which are used for solving the problems that in the video data storage process in the prior art, the hard disk magnetic head frequently jumps and the data cache area frequently writes due to the writing of I frame index information.
In a first aspect, the present application provides a video data storage method, which specifically includes:
writing a first I frame index frame after writing at least one code stream frame in a video data file, wherein the writing position of an I frame included in the at least one code stream frame in the video data file and the writing position of a next I frame index frame adjacent to the first I frame index frame are recorded in the first I frame index frame, and the writing position of the first I frame index frame is determined according to the writing position of the I frame index frame recorded in the last I frame index frame adjacent to the first I frame index frame.
In a first aspect, in a possible implementation manner, after a first I frame index frame, at least one bitstream frame is continuously written, and when a writing position of a next I frame index frame recorded in the first I frame index frame is reached, a second I frame index frame is written, where a writing position of an I frame included in the at least one bitstream frame that is continuously written in a video data file and a writing position of a next I frame index frame adjacent to the second I frame index frame are recorded in the second I frame index frame.
According to the method provided by the embodiment of the application, the I frame index information is constructed into the I frame index frame form and written into the video data file, and in the video data storage process, the code stream frame and the I frame index frame keep stream linear sequence writing, so that the write-back action of writing the I frame index information at the head of a jump-back file is avoided, and the storage efficiency is improved.
In a first aspect, a possible implementation manner is that writing at least one bitstream frame between two adjacent I frame index frames in a video data file includes: and if the length between the writing positions of two adjacent I frame index frames is equal to the length of the N code stream frames, writing the N code stream frames between the writing positions of two adjacent I frame index frames.
In the first aspect, in a possible implementation manner, if the length between the writing positions of two adjacent I frame index frames is greater than the length of N-1 bitstream frames and less than the length of N bitstream frames, N-1 bitstream frames are written between the writing positions of two adjacent I frame index frames, and a blank frame is written in a blank place, where the blank frame is an invalid frame.
In the video playback process, the video equipment automatically skips the analysis of the empty frame, and does not occupy the analysis time.
The first I-frame index frame also records a frame length and a time stamp of an I-frame included in the at least one bitstream frame.
In a possible implementation manner of the first aspect, the method provided by the first aspect may further include: and writing a file head frame at the initial position of the video data file, wherein the file head frame records the writing position of the first code stream frame in the video data file and the writing position of the first I frame index frame.
By comparing whether the length from the position of the code stream frame to the position of the I frame index frame meets the frame length of the code stream frame to be written, when the code stream frame is not written enough, a blank frame with a certain length is inserted to play a role of supplementing data, and the sequential writing of the code stream frame and the I frame index frame is ensured.
In a possible implementation manner of the first aspect, the method provided by the first aspect may further include: and after the first I frame index frame, determining that the video data file is closed in the process of continuously writing at least one code stream frame, and recording the writing position of the last written code stream frame. And after the video data file is reopened, writing an empty frame after the writing position of the last recorded code stream frame and before the writing position of the next I frame index frame recorded in the first I frame index frame, wherein the empty frame is an invalid frame. And writing the second I frame index frame when the writing position of the next I frame index frame recorded in the first I frame index frame is reached.
In a second aspect, the present application further provides a video data storage device, where the video data storage device specifically includes:
a first writing unit, configured to write a first I-frame index frame after writing at least one bitstream frame in a video data file, where a writing position of an I-frame included in the at least one bitstream frame in the video data file and a writing position of a next I-frame index frame adjacent to the first I-frame index frame are recorded in the first I-frame index frame, and the writing position of the first I-frame index frame is determined according to a writing position of an I-frame recorded in a last I-frame index frame adjacent to the first I-frame index frame;
and a second writing unit, configured to write a second I-frame index frame after writing at least one bitstream frame after the first I-frame index frame and when a writing position of a next I-frame index frame recorded in the first I-frame index frame is reached, where the second I-frame index frame records a writing position of an I-frame included in the at least one bitstream frame that is continuously written in the video data file and a writing position of a next I-frame index frame adjacent to the second I-frame index frame.
In a possible implementation manner of the second aspect, when at least one bitstream frame is written between two adjacent I frame index frames in the video data file, the first writing unit is specifically configured to:
writing N code stream frames between the writing positions of two adjacent I frame index frames if the length between the writing positions of two adjacent I frame index frames is equal to the length of the N code stream frames;
and if the length between the writing positions of two adjacent I frame index frames is greater than the length of the N-1 code stream frames and less than the length of the N code stream frames, writing the N-1 code stream frames between the writing positions of two adjacent I frame index frames, and writing a blank frame in a spare position, wherein the blank frame is an invalid frame.
In a possible implementation manner of the second aspect, the first I-frame index frame further records a frame length and a timestamp of an I-frame included in the at least one bitstream frame.
In a possible implementation manner of the second aspect, the apparatus of the second aspect further includes:
and the third writing unit is used for writing a file head frame in the initial position of the video data file, and the file head frame records the writing position of the first code stream frame in the video data file and the writing position of the first I frame index frame.
In one possible implementation manner of the second aspect, the apparatus of the second aspect may further include:
a recording unit, configured to determine that the video data file is closed and record a write-in position of a last written code stream frame in a process of continuing to write in at least one code stream frame after the first I frame index frame;
a fourth writing unit, configured to write, after reopening the video data file, an empty frame after a writing position of a last recorded written code stream frame and before a writing position of a next I frame index frame recorded in the first I frame index frame, where the empty frame is an invalid frame; and writing a second I frame index frame when the writing position of the next I frame index frame recorded in the first I frame index frame is reached.
According to the file repairing method under the condition of abnormal file closing, the code stream frame position with the abnormality is quickly located, data in the file are supplemented, and the problem of inaccurate data location in the video playback process caused by abnormal file closing is solved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a diagram illustrating a structure of a video data file in the prior art;
fig. 2 is a schematic structural diagram of a video data file according to an embodiment of the present application;
fig. 3 is a schematic diagram of a video data storage method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a video data file according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an abnormally closed video data file according to an embodiment of the present application;
fig. 6 is a schematic diagram of a video data storage method according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a video data storage device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, 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 invention.
Fig. 1 is a schematic diagram illustrating a structure of a video data file in the prior art. As shown in fig. 1, in the prior art, a fixed-size header space, such as 384 Kilobits (KB), is allocated in a file, and then bitstream frames are written in sequence, if a bitstream frame is an I frame, a file header is skipped back, corresponding I frame index information is written, information of the I frame in the corresponding bitstream frame is recorded, and then the bitstream frame is continuously written.
Fig. 2 is a schematic structural diagram of a video data file according to an embodiment of the present application. As shown in fig. 2, in the video data file structure provided in the embodiment of the present application, a certain space is allocated in the file header space as a file header frame, the file header frame has only one frame in the whole file, and the writing position of the first bitstream frame in the video data file and the writing position of the first I frame index frame are recorded. Each I frame index frame records the writing position, the time stamp and the frame length of at least one corresponding I frame in the video data file, and also records the position information of the next adjacent I frame index frame to form a one-way circular linked list structure. When no I frame exists in the code stream frame to be recorded, 0I frame index information is recorded in the I frame index frame; when the code stream frame to be recorded contains at least one I frame, the I frame index frame records at least one piece of I frame index information. The null frame shown in fig. 2 is an invalid frame, and may have any length not less than the minimum frame length for the purpose of filling up data, where the minimum frame length is the length of the frame header and the frame tail with fixed sizes. During the writing process of the video data, the linear sequential writing of the video data is kept, and the write-back action is avoided. In the process of reading the video data, the I frame index frame records the relevant information of the corresponding I frame, the video at a certain time point can be accurately positioned according to the needs of a user, and the searching of traversing the whole video file is avoided. In the video playback process, the file head frame, the I frame index frame and the empty frame are automatically skipped over for analysis, so that the efficiency is improved.
Fig. 3 is a schematic diagram of a video data storage method according to an embodiment of the present application. As shown in fig. 3, the method includes: and writing a file head frame, wherein the writing position of the first code stream frame and the writing position of the first I frame index frame are recorded in the file head frame. And caching the writing position of the first code stream frame and the writing position of the first I frame index frame in a file buffer area. And acquiring the writing position of the first code stream frame and the writing position of the first I frame index frame from the file buffer area. And a file buffer area is arranged, so that the information reading in a file head frame is avoided in the video data writing process, and the data writing efficiency is improved. The writing position of the first code stream frame is the end position of the head frame of the file, and the writing position of the first I frame index frame is obtained by estimating according to the size of the video data file.
Before writing the code stream frame, the length from the writing position of the code stream frame to be written to the writing position of the recorded I frame index frame needs to be compared, and whether the length is enough to write the frame length of at least one code stream frame or not needs to be compared.
In the data writing process, when the length from the writing position of the code stream frame to the writing position of the recorded I frame index frame is larger than the frame length of the code stream frame to be written, at least one code stream frame is written sufficiently, the code stream frame is directly written, if the written code stream frame is the I frame, the I frame index information is cached, and the cached I frame index information is constructed into the I frame index frame.
When the length from the writing position of the code stream frame to the writing position of the recorded I frame index frame is equal to the frame length of the code stream frame to be written, the code stream frame is directly written without inserting a null frame, if the written code stream frame is an I frame, I frame index information is cached, the cached I frame index information is constructed into the I frame index frame, and the I frame index frame is written in the writing position of the current I frame index frame recorded in the file head frame or the adjacent previous I frame index frame.
When the length from the writing position of the code stream frame to the writing position of the recorded I frame index frame is smaller than the frame length of the code stream frame to be written, the code stream frame is not written enough, a blank frame with a certain length is inserted, data is supplemented, so that the video data reaches the writing position of the I frame index frame recorded in the file head frame or the adjacent previous I frame index frame, if at least one I frame exists in the code stream frame written before the blank frame is inserted, the I frame index information is cached, and the cached I frame index information is constructed into an I frame index frame to be written into the I frame index frame. If the I frame is not recorded before the written I frame index frame, the I frame index frame written this time is marked as invalid.
Fig. 4 is a schematic structural diagram of a video data file according to an embodiment of the present application, and the following describes in detail a video data storage method according to the embodiment of the present application with reference to fig. 4 and a specific example. In a specific example, the length of the I-frame index frame is relatively smaller than that of the written code stream frame, and for convenience of description, the length of the I-frame index frame is not counted. The method for storing the video data file comprising the plurality of I frame index frames and the plurality of code stream frames is consistent with the method provided by the embodiment of the application and is not repeated.
Writing a file head frame, wherein the size of the file head frame is 100KB, the writing point of the first code stream frame is the 100KB position in the file, the file head frame records that the first I frame index frame is located at the 800KB position in the file, the length of the first code stream frame to be written is 300KB, and the first code stream frame is directly written in the file by comparing that the length from the position of the writing point of the first code stream frame to the position of the first I frame index frame is 700KB, which is far greater than the length of the first code stream frame to be written.
And after the first code stream frame is written in, the first code stream frame is an I frame, and the information of the I frame is cached as the construction information of the first I frame index frame. Then, the writing point of the second bitstream frame to be written is 400KB, the second bitstream frame is directly written in the file by comparing the length from the writing point of the second bitstream frame to the position of the first I-frame index frame is 400KB, and the second bitstream frame is a non-I frame. After the second code stream frame is written, the position of the code stream frame in the file reaches the writing position of the first I frame index frame. And according to the position of the first I frame index frame recorded in the file head frame, writing the first I frame index frame. The first I frame index frame contains index information of an I frame, including the timestamp, position, frame length, resolution and other information of the first I frame in the file.
The first I frame index frame records the position of a second I frame index frame at the 1600KB in the file, the length of a third code stream frame to be written is 400KB, the writing position of the third code stream frame to be written is located at the 800KB in the file, and the third code stream frame is directly written in the file by comparing that the length from the writing position of the third code stream frame to the position of the second I frame index frame is 800KB which is far greater than the length of the third code stream frame to be written.
And writing the third code stream frame, wherein the third code stream frame is a non-I frame. Then the writing position of the fourth code stream frame is located at the 1200KB position in the file, and the fourth code stream frame to be written is 500 KB. And by comparing that the length from the writing position of the fourth code stream frame to the position of the second I frame index frame is 400KB, if the length is not enough to write the fourth code stream frame, inserting a null frame with the length of 400KB, and supplementing data, so that the frame in the file reaches the position of the second I frame index frame. And constructing a second I frame index frame according to the position information of the adjacent second I frame index frame recorded by the first I frame index frame, and writing the second I frame index frame into a file. Only one non-I frame and a null frame are written in the bitstream frame between the first I frame index frame and the second I frame index frame, and then the second I frame index frame includes 0 pieces of I frame index information. While the second I frame index frame records the position of the third I frame index frame.
After the second I frame index frame is written, the code stream frame does not need to be written, and the position of the third I frame index frame recorded in the second I frame index frame is the same as the position of the second I frame index frame, which indicates that the end of the file is reached. And closing the file and storing all video data in the file into the hard disk.
Fig. 5 is a schematic structural diagram of an abnormally closed video data file according to an embodiment of the present application. As shown in fig. 5, the video data file is abnormally closed due to restart of the power-off device, so that the I-frame index frame in the file is not ready to be written, and therefore the I-frame included in the code stream frame written in the file before the video data file is closed is not recorded in the I-frame index frame, and the I-frame that is not recorded cannot be timely and accurately found according to the index information in the file reading and video playback processes.
Fig. 6 is a schematic diagram of a video data storage method according to an embodiment of the present application. As shown in fig. 6, data in the file is read from the file header frame, the position of the recorded next I frame index frame is obtained from each I frame index frame, and when the position of the recorded next I frame index frame of the I frame index frame before the file end exceeds the size of the actual file, the position of the recorded next I frame index frame is invalid, which indicates that the file is abnormally closed.
And recording the writing position of the last written code stream frame after judging that the file is abnormally closed. And after the video data file is reopened, acquiring the writing position of the last written code stream frame and the writing position of the next I frame index frame recorded by the I frame index frame before the end of the file, and writing an empty frame after the writing position of the last written code stream frame is recorded and before the writing position of the next I frame index frame is recorded, wherein the empty frame is an invalid frame. And buffering the I frame index information existing between the I frame index frames, constructing the I frame index frame, and writing the I frame index frame when the writing position of the next recorded I frame index frame is reached.
In a specific example, the position information of the next I frame index frame recorded by the I frame index frame before the end of the file is acquired is 500KB, and when the file length is only 300KB during closing, the position of the recorded next I frame index frame is invalid, which indicates that the file is abnormally closed, and the file is repaired. And reopening the video data file, acquiring the writing position of the last written code stream frame and the writing position of the next I frame index frame recorded by the I frame index frame before the file end, inserting 200KB of empty frame supplement data, and writing one I frame index frame. If there is no I frame in the code stream frame, no I frame information is recorded in the written I frame index frame, and the I frame index frame is marked as invalid.
In another specific example, a code stream frame with a frame length of 100KB exists between the writing position of the last written code stream frame and the writing position of the next I frame index frame recorded by the I frame index frame before the file end, and if the code stream frame is an I frame, the I frame information is cached, and a null frame with a length of 100KB is inserted. And constructing an I frame index frame according to the cached I frame information, and writing the I frame index frame at the position of the recorded next I frame index frame.
If the video data file is abnormally closed, the method provided by the embodiment of the application can be used for quickly positioning the code stream frame position with the abnormality and supplementing the data in the file, so that the problem of inaccurate data positioning in the video playback process caused by abnormal closing of the file is solved.
Although some empty frames are inserted in the storing and writing process, the size of the generated video data file is increased, the writing back action is avoided, the writing is always performed in sequence, the data storage efficiency is greatly improved, meanwhile, all I frame index frames in the file are read very quickly through the I frame index frame one-way circular linked list structure, and in addition, other frame types are added at the later stage if needed, the expansion is very convenient. In the practical application process, the optimization can be further carried out, and after a plurality of I frame data are stored, a string of I frame index frames are intensively written, so that the occupation proportion of empty frames in the total length of the file can be reduced, and the storage efficiency of hard disk data is improved.
Based on the above concept, as shown in fig. 7, the present application further provides a video data storage device 700, where the device 700 may include:
a first writing unit 701, configured to write a first I frame index frame after writing at least one bitstream frame in a video data file, where a writing position of an I frame included in the at least one bitstream frame in the video data file and a writing position of a next I frame index frame adjacent to the first I frame index frame are recorded in the first I frame index frame, and the writing position of the first I frame index frame is determined according to a writing position of an I frame index frame recorded in a previous I frame index frame adjacent to the first I frame index frame;
a second writing unit 702, configured to write a second I frame index frame after writing at least one bitstream frame after the first I frame index frame, when a writing position of a next I frame index frame recorded in the first I frame index frame is reached, where a writing position of an I frame included in the at least one bitstream frame that is continuously written in the video data file and a writing position of a next I frame index frame adjacent to the second I frame index frame are recorded in the second I frame index frame.
Optionally, the first writing unit 701, when writing at least one bitstream frame between two adjacent I frame index frames in the video data file, is specifically configured to: writing N code stream frames between the writing positions of two adjacent I frame index frames if the length between the writing positions of two adjacent I frame index frames is equal to the length of the N code stream frames; and if the length between the writing positions of two adjacent I frame index frames is greater than the length of the N-1 code stream frames and less than the length of the N code stream frames, writing the N-1 code stream frames between the writing positions of two adjacent I frame index frames, and writing a blank frame in a spare position, wherein the blank frame is an invalid frame.
Optionally, the frame length and the timestamp of the I frame included in the at least one bitstream frame are further recorded in the first I frame index frame.
Optionally, the apparatus 700 may further include: and the third writing unit is used for writing a file head frame in the initial position of the video data file, and the file head frame records the writing position of the first code stream frame in the video data file and the writing position of the first I frame index frame.
Optionally, the apparatus 700 may further include: a recording unit, configured to determine that the video data file is closed and record a write-in position of a last written code stream frame in a process of continuing to write in at least one code stream frame after the first I frame index frame; a fourth writing unit, configured to write, after reopening the video data file, an empty frame after a writing position of a last recorded written code stream frame and before a writing position of a next I frame index frame recorded in the first I frame index frame, where the empty frame is an invalid frame; and writing a second I frame index frame when the writing position of the next I frame index frame recorded in the first I frame index frame is reached.
For the specific implementation of the apparatus 700, reference may be made to the description of the method, which is not described herein again.
The present application is described above with reference to block diagrams and/or flowchart illustrations of methods, apparatus (systems) and/or computer program products according to embodiments of the application. It will be understood that one block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, and/or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer and/or other programmable data processing apparatus, create means for implementing the functions/acts specified in the block diagrams and/or flowchart block or blocks.
Accordingly, the subject application may also be embodied in hardware and/or in software (including firmware, resident software, micro-code, etc.). Furthermore, the present application may take the form of a computer program product on a computer-usable or computer-readable storage medium having computer-usable or computer-readable program code embodied in the medium for use by or in connection with an instruction execution system. In the context of this application, a computer-usable or computer-readable medium may be any medium that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for storing video data, the method comprising:
writing a first I frame index frame after writing at least one code stream frame in a video data file, wherein the writing position of an I frame included in the at least one code stream frame in the video data file and the writing position of a next I frame index frame adjacent to the first I frame index frame are recorded in the first I frame index frame, and the writing position of the first I frame index frame is determined according to the writing position of the I frame index frame recorded in the last I frame index frame adjacent to the first I frame index frame;
after writing the first I frame index frame, after continuously writing at least one code stream frame, when reaching the writing position of the next I frame index frame recorded in the first I frame index frame, writing a second I frame index frame, wherein the writing position of the I frame included in the continuously written at least one code stream frame in the video data file and the writing position of the next I frame index frame adjacent to the second I frame index frame are recorded in the second I frame index frame.
2. The method of claim 1, wherein writing at least one bitstream frame between two adjacent I-frame index frames in a video data file comprises:
writing N code stream frames between the writing positions of two adjacent I frame index frames if the length between the writing positions of two adjacent I frame index frames is equal to the length of the N code stream frames;
and if the length between the writing positions of two adjacent I frame index frames is greater than the length of the N-1 code stream frames and less than the length of the N code stream frames, writing the N-1 code stream frames between the writing positions of two adjacent I frame index frames, and writing a blank frame in a spare position, wherein the blank frame is an invalid frame.
3. The method according to claim 1, wherein the first I-frame index frame further records a frame length and a time stamp of an I-frame included in the at least one bitstream frame.
4. The method of claim 1, wherein prior to writing at least one bitstream frame in the video data file, the method further comprises:
and writing a file head frame at the initial position of the video data file, wherein the file head frame records the writing position of a first code stream frame in the at least one code stream frame in the video data file and the writing position of a first I frame index frame.
5. The method of claim 1, further comprising:
after the first I frame index frame, in the process of continuously writing at least one code stream frame, determining that the video data file is closed, and recording the writing position of the last written code stream frame;
after the video data file is reopened, writing an empty frame after the writing position of the last recorded code stream frame and before the writing position of the next I frame index frame recorded in the first I frame index frame, wherein the empty frame is an invalid frame;
and writing a second I frame index frame when the writing position of the next I frame index frame recorded in the first I frame index frame is reached.
6. A video data storage apparatus, characterized in that the apparatus comprises:
a first writing unit, configured to write a first I-frame index frame after writing at least one bitstream frame in a video data file, where a writing position of an I-frame included in the at least one bitstream frame in the video data file and a writing position of a next I-frame index frame adjacent to the first I-frame index frame are recorded in the first I-frame index frame, and the writing position of the first I-frame index frame is determined according to a writing position of an I-frame recorded in a last I-frame index frame adjacent to the first I-frame index frame;
and the second writing unit is used for writing a second I frame index frame after writing the first I frame index frame and continuously writing at least one code stream frame and when reaching the writing position of the next I frame index frame recorded in the first I frame index frame, and the writing position of the I frame in the video data file and the writing position of the next I frame index frame adjacent to the second I frame index frame included in the at least one code stream frame which is continuously written are recorded in the second I frame index frame.
7. The apparatus of claim 6, wherein the first writing unit, when writing at least one bitstream frame between two adjacent I-frame index frames in the video data file, is specifically configured to:
writing N code stream frames between the writing positions of two adjacent I frame index frames if the length between the writing positions of two adjacent I frame index frames is equal to the length of the N code stream frames;
and if the length between the writing positions of two adjacent I frame index frames is greater than the length of the N-1 code stream frames and less than the length of the N code stream frames, writing the N-1 code stream frames between the writing positions of two adjacent I frame index frames, and writing a blank frame in a spare position, wherein the blank frame is an invalid frame.
8. The apparatus according to claim 6, wherein the first I frame index frame further records a frame length and a time stamp of an I frame included in the at least one bitstream frame.
9. The apparatus of claim 6, further comprising:
and a third writing unit, configured to write a header frame at a start position of the video data file before writing at least one bitstream frame in the video data file, where the header frame records a writing position of a first bitstream frame in the at least one bitstream frame in the video data file and a writing position of a first I frame index frame.
10. The apparatus of claim 6, further comprising:
a recording unit, configured to determine that the video data file is closed and record a write-in position of a last written code stream frame in a process of continuing to write in at least one code stream frame after the first I frame index frame;
a fourth writing unit, configured to write, after reopening the video data file, an empty frame after a writing position of a last recorded written code stream frame and before a writing position of a next I frame index frame recorded in the first I frame index frame, where the empty frame is an invalid frame; and writing a second I frame index frame when the writing position of the next I frame index frame recorded in the first I frame index frame is reached.
CN201810679732.6A 2018-06-27 2018-06-27 Video data storage method and device Active CN108833817B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810679732.6A CN108833817B (en) 2018-06-27 2018-06-27 Video data storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810679732.6A CN108833817B (en) 2018-06-27 2018-06-27 Video data storage method and device

Publications (2)

Publication Number Publication Date
CN108833817A CN108833817A (en) 2018-11-16
CN108833817B true CN108833817B (en) 2020-09-29

Family

ID=64139292

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810679732.6A Active CN108833817B (en) 2018-06-27 2018-06-27 Video data storage method and device

Country Status (1)

Country Link
CN (1) CN108833817B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112486910A (en) * 2020-11-23 2021-03-12 天津津航计算技术研究所 Method for rapidly analyzing mass data files
CN113672588A (en) * 2021-07-16 2021-11-19 浙江大华技术股份有限公司 Data storage method, data storage device, storage node and management node
CN114374875B (en) * 2021-12-31 2024-05-28 浙江大华技术股份有限公司 MP4 file recording method, device and readable storage medium
CN116033102A (en) * 2023-01-05 2023-04-28 广州广电运通金融电子股份有限公司 Video storage method and video playing method

Also Published As

Publication number Publication date
CN108833817A (en) 2018-11-16

Similar Documents

Publication Publication Date Title
CN108833817B (en) Video data storage method and device
US8806173B2 (en) Elimination of duplicate written records
CN103744800B (en) Caching method and device towards replay mechanism
CN110830838A (en) Security protection high-definition video reverse broadcasting method and device
US11750784B2 (en) Automatic video file repair method and system
JP6229067B2 (en) Data access method and apparatus
US10339970B2 (en) Video recording apparatus with pre-event circulation recording function
JP2006324848A5 (en)
CN104104895A (en) Method for carrying out video playback on video data and hard-disk video recorder
JP5932731B2 (en) Tape drive, method, and program for transferring multiple records including video data to and from host
CN104702874A (en) Storing method for file monitored by video
JP2006324848A (en) Apparatus and method for information processing
KR102135347B1 (en) Digital video recorder and operation method thereof
US8300701B2 (en) Offspeed playback in a video editing system of video data compressed using long groups of pictures
CN106101596B (en) Video storage method and device
US20150199980A1 (en) Tape apparatus and write processing method
JP4382012B2 (en) DATA RECORDING DEVICE AND ITS CONTROL METHOD, DATA RECORDING DEVICE CONTROL PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM
CN114257840B (en) Repairing method and system for Matroska format video
CN115396729B (en) Video target frame determining method, device, equipment and storage medium
CN113507625B (en) Self-adaptive video restoration method
US7912349B1 (en) Validating frame dependency information
US8780475B2 (en) Tape drive buffer utilization
CN105592281B (en) MPEG video processing method, device and system
EP2685456A1 (en) Index with offset to closest I-picture entry for random access in a bitstream.
CN102522088A (en) Decoding method and device of audio frequency

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