Method, apparatus, and readable storage medium for storing video data
By judging whether to write a new I-frame index information set when storing video data, writing of empty frames is avoided, the problem of increasing storage space of video data files is solved, and accurate positioning of video data files and saving of storage space is achieved.
Patent Information
- Application Number
- CN202111169753.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-08
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-10-08
AI Technical Summary
In the prior art, in order to quickly playback and position, empty frames need to be written, resulting in an increase in the storage space of the video data file.
By writing code stream frames in the current code stream data set and determining whether to write a new I-frame index information set, writing of empty frames is avoided. The specific method is to determine whether to write a new I-frame index information set based on the code stream length and the preset code stream length of the current code stream data set, and combined with the code stream length of the code stream frame to be written.
It realizes accurate positioning of video data files and avoids writing of empty frames, thus saving storage space.
Smart Images

Figure CN114003763B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video storage, and particularly to a method, device, and readable storage medium for storing video data. Background Art
[0002] The core function of a network video recorder (NVR) is to store the video data files collected by the front-end encoder. Video data is in the form of bitstream frames, which are composed of I-frames, P-frames, and B-frames. Among them, an I-frame can be independently decoded into a complete image without relying on other frames, while P-frames and B-frames both need to rely on adjacent I-frames to decode a complete image.
[0003] During the process of storing video data files onto the hard disk, in addition to writing bitstream frames, for fast playback positioning, it is also necessary to write all the I-frame index information in the bitstream frames, that is, the I-frame index information set. Among them, the I-frame index information records the specific position of the corresponding I-frame in the bitstream frame, the bitstream length of the I-frame, and the time information of the I-frame.
[0004] During video playback, when a user needs to locate the video at a certain time point, the video data at that time point can be conveniently found according to the I-frame index information in the I-frame index information set, without having to search by traversing the entire video data file. Therefore, a video data file is composed based on bitstream frames and I-frame index information.
[0005] In the prior art, the I-frame index information set records the I-frame index information of the I-frames in the subsequent bitstream data set, as well as the writing position of the next I-frame index information set. Therefore, the position of the I-frame index information set in the video data file is determined. When the bitstream length of the to-be-written bitstream frame exceeds the remaining space between the current bitstream data set and the next I-frame index information set, the to-be-written I-frame cannot be written, and an empty frame with the same size as the remaining space is inserted. The insertion of the empty frame can ensure that the video data file is not interrupted. However, the existence of the empty frame increases the bitstream length of the video data file, resulting in an increase in the storage space occupied by the video data file. Summary of the Invention
[0006] This invention application provides a method, device, and readable storage medium for storing video data, which can accurately locate during video data file playback and avoid writing empty frames.
[0007] In a first aspect, to solve the above technical problems, this invention application provides a method for storing video data, including:
[0008] Writing a bitstream frame into the current bitstream data set and determining the bitstream length of the current bitstream data set; wherein, the current bitstream data set includes at least one bitstream frame;
[0009] Based on the stream length of the current stream data set and the preset stream length, and combining with the stream length of the stream frame to be written, determine whether to write a new I-frame index information set;
[0010] If so, generate and write the new I-frame index information set based on the position information of the previously written I-frame index information set and the I-frames in the current stream data set, where the I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding stream data set and the position information of the adjacent previous I-frame index information set;
[0011] If not, write the stream frame to be written.
[0012] According to the above method, the stream frames in the video data file can be accurately located, and at the same time, the insertion of invalid empty frames is avoided, so as to ensure that the video data file will not occupy too much storage space due to writing invalid data.
[0013] A possible implementation, the determining whether to write a new I-frame index information set based on the stream length of the current stream data set and the preset stream length, and combining with the stream length of the stream frame to be written, includes:
[0014] When the sum of the stream length of the current stream data set and the stream length of the stream frame to be written is greater than or equal to the preset stream length, determine the absolute value of the difference between the stream length of the current stream data set and the preset stream length as the first difference;
[0015] Determine the absolute value of the difference between the sum of the stream length of the current stream data set and the stream length of the stream frame to be written and the preset stream length as the second difference;
[0016] Judge whether to write a new I-frame index information set according to whether the first difference is less than or equal to the second difference.
[0017] A possible implementation, the position information of the adjacent previous I-frame index information set is the stream length of all the stream data sets before the adjacent previous I-frame index information set; if the new I-frame index information set is the first I-frame index information set in the video data file, the position information of the adjacent previous I-frame index information set of this I-frame index information set is 0.
[0018] A possible implementation, after writing the stream to be written, includes:
[0019] When reprocessing an abnormally closed video data file, parse the current stream data set, and continue to write the unwritten stream frames and the corresponding I-frame index information set at the end of the current stream data set.
[0020] A possible implementation manner. After generating and writing the new I-frame index information set based on the position information of the previous written I-frame index information set and the I-frames in the current bitstream dataset, it includes:
[0021] When playing back the video data file, read each I-frame index information set sequentially forward from the end of the video data file.
[0022] Locate and play back the video data file according to all the I-frame index information in the video data file.
[0023] In a second aspect, the present invention application provides a device for storing video data. The device includes:
[0024] A determination unit: used for writing a bitstream frame in the current bitstream dataset and determining the bitstream length of the current bitstream dataset; wherein, the current bitstream dataset includes at least one bitstream frame.
[0025] A judgment unit: used for judging whether to write a new I-frame index information set based on the bitstream length of the current bitstream dataset and a preset bitstream length, in combination with the bitstream length of the bitstream frame to be written.
[0026] A writing unit: when it is judged to write a new I-frame index information set, generate and write the new I-frame index information set based on the position information of the previous written I-frame index information set and the I-frames in the current bitstream dataset, wherein the I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding bitstream dataset and the position information of the adjacent previous I-frame index information set; when it is judged not to write a new I-frame index information set, write the bitstream frame to be written.
[0027] A possible implementation manner. The device further includes:
[0028] A repair unit: used for parsing the current bitstream dataset when reprocessing an abnormally closed video data file, and continuing to write the unwritten bitstream frames and the corresponding I-frame index information sets at the end of the current bitstream dataset.
[0029] A possible implementation manner. The device further includes:
[0030] A reading unit: when playing back the video data file, read each I-frame index information set sequentially forward from the end of the video data file; locate and play back the video data file according to all the I-frame index information in the video data file.
[0031] A possible implementation manner, the determining unit is specifically configured to determine, when the sum of the bitstream length of the current bitstream data set and the bitstream length of the to-be-written bitstream frame is greater than or equal to a preset bitstream length, the absolute value of the difference between the bitstream length of the current bitstream data set and the preset bitstream length as a first difference;
[0032] Determine the absolute value of the difference between the sum of the bitstream length of the current bitstream data set and the bitstream length of the to-be-written bitstream frame and the preset bitstream length as a second difference;
[0033] According to whether the first difference is less than or equal to the second difference, determine whether to write a new I-frame index information set.
[0034] In a third aspect, the present invention application provides a readable storage medium, which includes:
[0035] A memory,
[0036] The memory is used to store instructions, and when the instructions are executed by a processor, the device including the readable storage medium completes the method as described in the first aspect and any one of the implementation manners. Description of the Drawings
[0037] Figure 1 It is a schematic structural diagram of a video data file in the prior art;
[0038] Figure 2 It is a schematic structural diagram of a video data file provided by the present application;
[0039] Figure 3 It is a schematic diagram of a method for storing video data provided by the present application;
[0040] Figure 4 It is a schematic structural diagram of an abnormally closed video data file provided by the present application;
[0041] Figure 5 It is a schematic structural diagram of a device for storing video data files provided by the present application. Detailed Embodiments
[0042] Figure 1 It is a schematic structural diagram of a video data file in the prior art. As Figure 1As shown in the figure, in a video data file structure, a certain amount of space is allocated in the file header space as the file header. There is only one file header in the entire video data file, which records the writing position of the first bitstream dataset in the video data file and the writing position of the first I-frame index information set. Each I-frame index information set records the writing positions, time information, and frame lengths of all I-frames in the corresponding bitstream dataset in the video data file, and also records the position information of the adjacent next I-frame index information set, forming a unidirectional circular linked list structure. When there is no I-frame in the bitstream dataset to be recorded, the I-frame index information set records 0 I-frame index information; when the bitstream dataset to be recorded contains at least one I-frame, the I-frame index information set records at least one I-frame index information. Figure 1 The empty frame shown in Figure 1 is an invalid frame. When the bitstream length of the bitstream frame to be written exceeds the remaining space between the current bitstream dataset and the next I-frame index information set, the I-frame to be written cannot be written, and an empty frame with the same size as the remaining space is inserted.
[0043] In the current method of storing video data files, the existence of empty frames affects the length of the video data file, resulting in unnecessary storage space occupied by the video data file.
[0044] To solve the above problems, an embodiment of the present application provides a method for storing video data files. In this method, the preset bitstream length is combined with the bitstream length of the bitstream frame to be written, and the writing position of the I-frame index information set in the video data file is flexibly adjusted, thereby avoiding the appearance of empty frames in the video data file and saving the storage space occupied by the video file.
[0045] To make the purpose, technical solution, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0046] Figure 2 This is a schematic diagram of a video data file structure provided by an embodiment of the present invention.
[0047] In the video data file structure provided by the embodiment of the present invention, a certain amount of space is allocated at the beginning of the video data file to write the file header. The file header is a non-essential file and can be used to record the coding format of the video data file. For example, the file header can record H.264, H.265, etc. After the file header, the bitstream frames and the I-frame index information sets are written in sequence. Between the file header and the I-frame index information set 1, or between two adjacent I-frame index information sets, there is a bitstream dataset, where the bitstream dataset contains at least 1 bitstream frame. As Figure 2As shown, the bitstream data set 1, bitstream data set 2, and bitstream data set n may contain one or more bitstream frames.
[0048] Based on the above video data file structure, when writing a bitstream frame into the video data file, it is necessary to determine whether to write the I-frame index information set. The specific determination process refers to Figure 3 , including:
[0049] Step 301: Write the bitstream frame into the current bitstream data set, and determine the bitstream length of the current bitstream data set;
[0050] The current bitstream data set indicates the set of all bitstream frames from the end of the previous I-frame index information set to the last written bitstream frame in the video data file.
[0051] After each bitstream frame is written, it is necessary to determine whether the bitstream frame is an I-frame. If the bitstream frame is an I-frame, cache the I-frame index information of the I-frame. The I-frame index information includes: the specific position, length, and time information of the I-frame in the video data file.
[0052] In particular, for the case where the file header has been written in the video data file but the I-frame index information set has not been written, the file header needs to be regarded as part of the current bitstream data set. That is, before writing the first I-frame index information set, the current bitstream data set includes the file header and the bitstream frames written after the file header, and the length of the current bitstream data set is the sum of the lengths of the file header and the bitstream frames written after the file header.
[0053] Step 302: Based on the bitstream length of the current bitstream data set and the preset bitstream length, combined with the bitstream length of the bitstream frame to be written, determine whether to write a new I-frame index information set.
[0054] Compare the sum of the bitstream length of the current bitstream data set and the bitstream length of the bitstream frame to be written with the preset bitstream length.
[0055] When the sum of the current bitstream data set and the length of the bitstream frame to be written is less than the preset bitstream length, it is determined not to write a new I-frame index information set, and step 304 is executed.
[0056] For example, in a certain video data file, the preset bitstream length is 100MB, the length of the current bitstream data set is 95MB. If the bitstream frame to be written is 4MB, the sum of the current bitstream data set and the length of the bitstream frame to be written is 95 + 4 = 99MB, which is less than the preset bitstream length of 100MB. It is determined not to write a new I-frame index information set, and step 304 is executed.
[0057] When the sum of the bitstream length of the current bitstream data set and the bitstream length of the bitstream frame to be written is greater than or equal to the preset bitstream length, determine the absolute value of the difference between the bitstream length of the current bitstream data set and the preset bitstream length as the first difference.
[0058] Determine the absolute value of the difference between the sum of the bitstream length of the current bitstream data set and the bitstream length of the bitstream frame to be written, and the preset bitstream length as the second difference.
[0059] Judge whether to write a new I-frame index information set according to whether the first difference is less than or equal to the second difference.
[0060] When the first difference is less than or equal to the second difference, execute step 303; when the first difference is less than or equal to the second difference, execute step 304.
[0061] For example, in a certain video data file, the preset bitstream length is 100MB, and the length of the current bitstream data set is 95MB, then the first difference is 5.
[0062] If the bitstream length of the bitstream frame to be written is 11MB, the sum of the bitstream length of the current bitstream data set and the bitstream length of the bitstream frame to be written is 95 + 11 = 106, and the second difference is 6, then the first difference is less than the second difference, and execute step 303.
[0063] If the bitstream length of the bitstream frame to be written is 8MB, the sum of the bitstream length of the current bitstream data set and the bitstream length of the bitstream frame to be written is 95 + 8 = 103, and the second difference is 3, then the first difference is greater than the second difference, and execute step 304.
[0064] Step 303: Generate the new I-frame index information set based on the position information of the previous written I-frame index information set and the I-frames in the current bitstream data set, and write it;
[0065] The I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding bitstream data set, as well as the position information of the adjacent previous I-frame index information set.
[0066] Pack the I-frame index information of all I-frames in the corresponding bitstream data set to generate an I-frame index information set, and save the position information of the previous I-frame index information set in this I-frame index information set. The position information of the previous I-frame index information set is the bitstream length of all the bitstream data sets before the previous I-frame index information set.
[0067] The bitstream data set corresponding to each I-frame index information set refers to the bitstream data set before this I-frame index information set and up to the adjacent previous I-frame index information set. When the bitstream data set corresponding to the I-frame index information set does not contain an I-frame, 0 I-frame index information is recorded in the I-frame index information set. When the bitstream data set to be recorded contains at least one I-frame, at least one I-frame index information is recorded in the I-frame index information set. Among them, the I-frame index information includes the writing position, time information, and file length of the I-frame in the video data file.
[0068] For example, Figure 2 If the bitstream data set corresponding to the I-frame index information set 2 is the bitstream data set 2, then the I-frame index information set 2 records the I-frame index information of all I-frames in the bitstream data set 2 and the position information of the I-frame index information set 1.
[0069] In particular, for the first I-frame index frame in the video data file, the position information of its previous I-frame index frame can be set to 0.
[0070] The writing of the I-frame index information set can ensure that when playing back the video recording, after opening the video recording file, first read the last I-frame index information set from the end of the file, obtain all the I-frame positions in the bitstream data corresponding to the I-frame index information set, and the position of the previous I-frame index information set, and so on, so as to read all the I-frame index information sets in the video data file, and then obtain all the I-frame index information in the video data file.
[0071] Step 304: Write the bitstream frame to be written.
[0072] It should be noted that the above steps can be executed cyclically to complete the storage of all bitstream frames and the corresponding I-frame index information sets. Specifically, after executing step 303, if there are still bitstream frames not written, go to step 301 to execute; after executing step 304, go to step 302 to execute.
[0073] In the embodiment of the present application, by adding a judgment step to determine whether to write a new I-frame index information set, the writing position of the I-frame index information set in the video data file becomes flexible, which can avoid the insertion of invalid empty frames, thereby ensuring that the video data file will not occupy too much storage space due to the writing of invalid data.
[0074] Further, after writing all bitstream frames and the corresponding I-frame index information set, when playing back the video data file, it is necessary to first locate the positions of the I-frame index information set in sequence according to the I-frame index information set at the end of the video data file, and then, based on the information in the I-frame index information set, the position information and time information of all I-frames in the video data file can be located. After that, video playback can be performed as needed. For example, if the user only needs to watch a video for a certain period of time, the video can be located and played back according to the I-frame index information set.
[0075] In particular, during the process of storing video data, due to power failure, device restart, etc., the video data file is abnormally closed, which causes the I-frames included in the bitstream data set already written into the file before the video data file is closed not to be recorded in the I-frame index information set, and the unrecorded I-frames cannot be found in a timely and accurate manner according to the index information during file reading and video playback. As Figure 4 shown is a schematic structural diagram of an abnormally closed video data file provided by an embodiment of the present application.
[0076] For the above-mentioned abnormally closed video data file, when reprocessing, it is necessary to parse the current bitstream data set to determine the bitstream length of the current bitstream data set and the I-frames and I-frame index information in the current bitstream data set; and continue to write the unwritten bitstream frames and the corresponding I-frame index information set at the end of the current bitstream data set to complete the repair of the video data file.
[0077] Based on the same inventive concept, an embodiment of the present application provides a device for storing video data. This device corresponds to the Figure 3 shown method for storing video data. The specific implementation manner of this device can refer to the description in the method embodiment part above, and the repeated parts will not be elaborated. Refer to Figure 5 ; this device includes:
[0078] Determination unit 501: used to write bitstream frames in the current bitstream data set and determine the bitstream length of the current bitstream data set.
[0079] Wherein, the current bitstream data set includes at least one bitstream frame.
[0080] Judgment unit 502: used to judge whether to write a new I-frame index information set based on the bitstream length of the current bitstream data set and a preset bitstream length, in combination with the bitstream length of the bitstream frame to be written.
[0081] Specifically, when the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written is greater than or equal to a preset bitstream length, the absolute value of the difference between the bitstream length of the current bitstream dataset and the preset bitstream length is determined as the first difference. The absolute value of the difference between the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written, and the preset bitstream length is determined as the second difference.
[0082] According to whether the first difference is less than or equal to the second difference, it is determined whether to write a new I-frame index information set.
[0083] Writing unit 503: When it is determined to write a new I-frame index information set, based on the position information of the previous written I-frame index information set and the I-frames in the current bitstream dataset, the new I-frame index information set is generated and written, where the I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding bitstream dataset, and the position information of the adjacent previous I-frame index information set; when it is determined not to write a new I-frame index information set, the bitstream frame to be written is written.
[0084] The device for storing video data further includes a repair unit: When reprocessing an abnormally closed video data file, it parses the current bitstream dataset and continues to write the unwritten bitstream frames and the corresponding I-frame index information sets at the end of the current bitstream dataset.
[0085] The device for storing video data further includes a reading unit: When playing back a video data file, it sequentially reads each I-frame index information set forward from the end of the video data file; locates and plays back the video data file according to all the I-frame index information in the video data file.
[0086] Based on the same inventive concept, an embodiment of the present application further provides a readable storage medium, including:
[0087] A memory,
[0088] The memory is used to store instructions, and when the instructions are executed by a processor, the device including the readable storage medium completes the method for storing video data as described above.
[0089] Those skilled in the art can clearly understand that for the convenience and conciseness of description, only the above division of each functional module is used as an example for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.
[0090] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0091] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0092] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0093] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media that can store program codes such as Universal Serial Bus flash disks, mobile hard disks, Read-Only Memory (ROM), Random Access Memory (RAM), magnetic disks, or optical discs.
[0094] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
Claims
1. A method for storing video data, characterized in that, Including: Writing a bitstream frame into the current bitstream dataset and determining the bitstream length of the current bitstream dataset; wherein, the current bitstream dataset includes at least one bitstream frame; Based on the bitstream length of the current bitstream dataset and a preset bitstream length, and in combination with the bitstream length of the bitstream frame to be written, determining whether to write a new I-frame index information set; If so, generating and writing the new I-frame index information set based on the position information of the previously written I-frame index information set and the I-frames in the current bitstream dataset, wherein the I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding bitstream dataset and the position information of the adjacent previous I-frame index information set; If not, writing the bitstream frame to be written; Wherein, the determining whether to write a new I-frame index information set based on the bitstream length of the current bitstream dataset and a preset bitstream length, and in combination with the bitstream length of the bitstream frame to be written, includes: When the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written is greater than or equal to the preset bitstream length, determining the absolute value of the difference between the bitstream length of the current bitstream dataset and the preset bitstream length as a first difference; Determining the absolute value of the difference between the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written and the preset bitstream length as a second difference; Judging whether to write a new I-frame index information set according to whether the first difference is less than or equal to the second difference.
2. The method according to claim 1, characterized in that, The position information of the adjacent previous I-frame index information set is the bitstream length of all bitstream datasets before the adjacent previous I-frame index information set; if the new I-frame index information set is the first I-frame index information set in the video data file, the position information of the adjacent previous I-frame index information set of this I-frame index information set is 0.
3. The method according to claim 1, wherein After writing the bitstream to be written, including: When reprocessing an abnormally closed video data file, parsing the current bitstream dataset and continuing to write the unwritten bitstream frames and the corresponding I-frame index information sets at the end of the current bitstream dataset.
4. The method according to claim 1, wherein After generating and writing the new I-frame index information set based on the position information of the previously written I-frame index information set and the I-frames in the current bitstream dataset, including: When playing back the video data file, sequentially reading each I-frame index information set forward from the end of the video data file; Performing positioning playback on the video data file according to all the I-frame index information in the video data file.
5. A device for storing video data, characterized in that, Including: A determining unit, configured to write a bitstream frame into the current bitstream dataset and determine the bitstream length of the current bitstream dataset; wherein, the current bitstream dataset includes at least one bitstream frame; A judging unit, configured to judge whether to write a new I-frame index information set based on the bitstream length of the current bitstream dataset and a preset bitstream length, and in combination with the bitstream length of the bitstream frame to be written; A writing unit, configured to generate and write a new I-frame index information set based on the position information of the previous written I-frame index information set and the I-frames in the current bitstream dataset when it is determined to write a new I-frame index information set, where the I-frame index information set is used to record the I-frame index information of all I-frames in the corresponding bitstream dataset, and the position information of the adjacent previous I-frame index information set; and when it is determined not to write a new I-frame index information set, write the bitstream frame to be written. Wherein, the determining unit is specifically configured to, when the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written is greater than or equal to a preset bitstream length, determine the absolute value of the difference between the bitstream length of the current bitstream dataset and the preset bitstream length as a first difference; determine the absolute value of the difference between the sum of the bitstream length of the current bitstream dataset and the bitstream length of the bitstream frame to be written and the preset bitstream length as a second difference; and determine whether to write a new I-frame index information set according to whether the first difference is less than or equal to the second difference.
6. The device according to claim 5, characterized in that, The apparatus further includes: A repair unit, configured to parse the current bitstream dataset and continue to write the unwritten bitstream frames and the corresponding I-frame index information sets at the end of the current bitstream dataset when reprocessing an abnormally closed video data file.
7. The device according to claim 5, characterized in that, The apparatus further includes: A reading unit, configured to, when playing back a video data file, sequentially read each I-frame index information set forward from the end of the video data file; and perform positioning playback on the video data file according to all the I-frame index information in the video data file.
8. A readable storage medium, characterized in that, Comprising: A memory, The memory is used to store instructions, and when the instructions are executed by a processor, the apparatus including the readable storage medium completes the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Video data processing method and video data read-write equipment
CN102945679A
Video data storage method and device
CN108833817A