Method, device, terminal equipment and storage medium for repairing files

By automatically identifying and repairing abnormal files in audio and video data, it solves the problem that traditional methods require manual intervention and have poor results, achieving fast and efficient file repair.

CN115334350BActive Publication Date: 2024-10-22GUANGDONG LEAPFIVE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210884374.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-25
Publication Date
2024-10-22
Estimated Expiration
2042-07-25

AI Technical Summary

Technical Problem

The traditional method of repairing files requires manual intervention, is time-consuming and labor-intensive, and has poor repair effects. It cannot effectively solve the problem of file damage caused by abnormalities during the storage process of audio and video data.

Method used

By obtaining the normal video frames and the frames to be repaired in the abnormal file, the frame type is determined, the frame to be repaired is repaired according to the frame type, and the repaired file is generated. The entire process does not require manual intervention and decoding by a decoder.

Benefits of technology

It realizes the process of automatically repairing files, improves the speed and effect of repairing files, reduces manual intervention and dependence on decoders, and improves the efficiency of repairing files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115334350B_ABST
    Figure CN115334350B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of electronic data repair, and in particular, relates to a method, device, terminal device and storage medium for repairing files. The method includes: obtaining an abnormal file, which contains normal video frames and frames to be repaired; determining the frame type of the frame to be repaired according to the normal video frame; repairing the frame to be repaired according to the frame type to obtain the repaired frame; generating a repair file corresponding to the abnormal file according to the normal video frame, the repaired frame and a preset configuration file. During the entire repair process, automatic repair can be achieved without manual intervention or decoder decoding, which improves the speed and effect of repairing files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic data repair, and in particular to a method, apparatus, terminal device, and storage medium for repairing files. Background Art

[0002] With the development of technology, audio and video data is ubiquitous. For example, smartphones, dashcams, drones, law enforcement cameras, hard disk recorders, and other devices generate large amounts of audio and video data every day. This audio and video data is encapsulated into MP4 format files for storage.

[0003] Among them, MP4, the full name of MPEG-4 Part 14, is a common multimedia container format. Now most smartphones, driving recorders, drones, law enforcement recorders, hard disk recorders and other devices use MP4 as the packaging format.

[0004] If anomalies occur during file storage, the file will be damaged, resulting in the loss of important information. The traditional method of repairing files is to use a decoder, which requires manual intervention, is not only time-consuming and labor-intensive, but also has poor repair results. Summary of the Invention

[0005] In view of this, the embodiments of the present application provide a method, apparatus, terminal device and storage medium for repairing files to solve the technical problem that the traditional method of repairing files is to use a decoder for repair, which requires manual intervention, is not only time-consuming and labor-intensive, but also has poor repair effects.

[0006] A first aspect of an embodiment of the present application provides a method for repairing a file, which may include:

[0007] Obtaining an abnormal file, wherein the abnormal file contains normal video frames and frames to be repaired;

[0008] Determining the frame type of the frame to be repaired according to the normal video frame;

[0009] Repairing the frame to be repaired according to the frame type to obtain a repaired frame;

[0010] A repair file corresponding to the abnormal file is generated according to the normal video frame, the repair frame and a preset configuration file.

[0011] Optionally, in a possible implementation, there are multiple normal video frames and multiple frames to be repaired, the multiple normal video frames and the multiple frames to be repaired are alternately arranged, and there are one or more frames to be repaired between two normal video frames. Determining the frame type of the frame to be repaired based on the normal video frames includes:

[0012] For each normal video frame, detecting identification information in the normal video frame, the identification information including preset bytes, the number of the preset bytes indicating the number of audio frames in the to-be-repaired frame;

[0013] When the identification information is detected, it is determined that the frame type of the frame to be repaired is an audio frame type.

[0014] Optionally, in a possible implementation, after detecting identification information in each normal video frame, the method further includes:

[0015] When the identification information is not detected, determining whether a first frame to be repaired is similar to the normal video frame, the first frame to be repaired being the first frame to be repaired after the normal video frame;

[0016] When it is determined that the first frame to be repaired is not similar to the normal video frame, determining that the frame type of the first frame to be repaired is the audio frame type; or when it is determined that the first frame to be repaired is similar to the normal video frame, determining that the frame type of the first frame to be repaired is the video frame type;

[0017] It is determined whether a second frame to be repaired is similar to the normal video frame, and a frame type of the second frame to be repaired is determined according to the determination result, wherein the second frame to be repaired is a frame to be repaired adjacent to the first frame to be repaired.

[0018] Optionally, in a possible implementation, when the identification information is not detected, determining whether the first frame to be repaired is similar to the normal video frame includes:

[0019] When the identification information is not detected, obtaining a first target byte in the first frame to be repaired;

[0020] Generating a frame length of the first frame to be repaired according to the first target byte;

[0021] When the frame length is greater than or equal to a preset threshold, it is determined that the first frame to be repaired is not similar to the normal video frame.

[0022] Optionally, in a possible implementation manner, after generating the frame length of the first frame to be repaired according to the first target byte, the method further includes:

[0023] When the frame length is less than the preset threshold, obtaining a second target byte in the first frame to be repaired, where the second target byte is used to represent a value corresponding to the frame type of the first frame to be repaired;

[0024] If it is detected that the second target byte is within a preset value range, it is determined that the first frame to be repaired is similar to the normal video frame; or

[0025] If it is detected that the second target byte is not within the preset value range, it is determined that the first frame to be repaired is not similar to the normal video frame.

[0026] Optionally, in a possible implementation, the frame to be repaired includes media data, and repairing the frame to be repaired according to the frame type to obtain a repaired frame includes:

[0027] Obtaining the starting address of the frame to be repaired;

[0028] determining a target frame length of the frame to be repaired according to the frame type;

[0029] The repair frame is generated according to the start address, the target frame length and the media data.

[0030] Optionally, in a possible implementation, the method further includes:

[0031] When it is detected that the suffix of the abnormal file is a preset suffix, it is determined that the fault cause of generating the abnormal file is an abnormal interruption.

[0032] Optionally, in a possible implementation, before obtaining the abnormal file, the method further includes:

[0033] In a process of storing a normal file, determining a first video frame and a second video frame, wherein the second video frame is stored after the first video frame, and one or more audio frames are stored between the first video frame and the second video frame;

[0034] For each audio frame, determining whether the audio frame is similar to the first video frame;

[0035] If it is determined that the audio frame is similar to the first video frame, identification information is added to the first video frame.

[0036] A second aspect of an embodiment of the present application provides a device for repairing a file, which may include:

[0037] An acquisition unit, configured to acquire an abnormal file, wherein the abnormal file includes normal video frames and frames to be repaired;

[0038] a determining unit, configured to determine a frame type of the frame to be repaired based on the normal video frame;

[0039] a repairing unit, configured to repair the frame to be repaired according to the frame type to obtain a repaired frame;

[0040] A generating unit is used to generate a repair file corresponding to the abnormal file according to the normal video frame, the repair frame and a preset configuration file.

[0041] A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for repairing files provided in the first aspect are implemented.

[0042] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the method for repairing a file provided in the first aspect are implemented.

[0043] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the steps of the method for repairing a file provided in the first aspect.

[0044] The solution provided by this application obtains an abnormal file containing normal video frames and frames to be repaired; determines the frame type of the frame to be repaired based on the normal video frames; repairs the frame to be repaired based on the frame type to obtain a repaired frame; and generates a repair file corresponding to the abnormal file based on the normal video frames, the repaired frames, and a preset configuration file. The entire repair process is automated without the need for manual intervention or decoder decoding, improving the speed and effectiveness of file repair. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0046] Figure 1 This is a schematic diagram of a data storage format provided by an exemplary embodiment of the present application;

[0047] Figure 2 A flowchart of a method for repairing a file provided by an embodiment of the present application is shown;

[0048] Figure 3 This is a schematic diagram of the data storage format in an abnormal file provided by an exemplary embodiment of the present application;

[0049] Figure 4 is a specific flow chart of step S103 of a method for repairing a file shown in another exemplary embodiment of the present application;

[0050] Figure 5 This is a schematic diagram of a device for repairing files provided in one embodiment of the present application;

[0051] Figure 6 This is a schematic diagram of a terminal device provided in another embodiment of the present application. DETAILED DESCRIPTION

[0052] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0053] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0054] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0055] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0056] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0057] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0058] With the development of technology, audio and video data is ubiquitous. For example, smartphones, dashcams, drones, law enforcement cameras, hard disk recorders, and other devices generate large amounts of audio and video data every day. This audio and video data is encapsulated into MP4 format files for storage.

[0059] Among them, MP4, the full name of MPEG-4 Part 14, is a common multimedia container format. Now most smartphones, driving recorders, drones, law enforcement recorders, hard disk recorders and other devices use MP4 as the packaging format.

[0060] During the file storage process, if an abnormality occurs, the file will be damaged, which will result in the loss of important information in the file. For example, in the field of surveillance and security, if an abnormal power outage occurs, the file will be damaged and the important information in the file will be lost.

[0061] In the surveillance and security field, audio and video data (both audio and video) are stored in unique formats. For example, video data formats primarily include the digital video compression format (H.264) and the digital video compression format (H.265). H.264, also known as H.264, is also the tenth part of MPEG-4. It is a highly compressed digital video codec standard proposed by the Joint Video Team (JVT), a joint venture of the ITU-T Video Coding Experts Group (VCEG) and the ISO / IEC Moving Picture Experts Group (MPEG).

[0062] H.265, also known as H.265, is a new video coding standard developed by the ITU-T VCEG, following H.264. The H.265 standard builds upon the existing H.264 video coding standard, retaining some of its original technologies while improving others. This new technology utilizes advanced techniques to optimize the relationship between bitrate, encoding quality, latency, and algorithm complexity.

[0063] Audio data formats primarily use the Gxx series of audio coding formats, such as G711 and G726. G711, also known as G.711, is an audio coding method developed by the International Telecommunication Union (ITU-T) and is also referred to as ITU-T G.711. G726, also known as G.726, is an audio coding algorithm defined by the ITU-T.

[0064] When storing these audio and video data, the recorded audio and video data is usually first written to a file on a disk. After recording is completed, basic MP4 file information is added to the end of the file according to the MP4 protocol standard. The basic MP4 file information is also referred to as the media information header in this article. The media information header can include information related to the audio data and related information related to the video data. By searching and identifying the media information header of each MP4 file, the information required for decoding the file can be obtained.

[0065] The relevant information of the audio data may include the channel, sampling rate, length of each audio frame (i.e., length of each audio frame), storage location of each audio frame (storage location of each audio frame), etc. The storage location of each audio frame may include the starting address and ending address of each audio frame, i.e., the starting address and ending address of each audio frame.

[0066] The relevant information of the video data may include resolution, duration, length of each frame of video (length of each video frame), storage location of each frame of video (storage location of each video frame), etc. Among them, the storage location of each frame of video may include the starting address and ending address of each frame of video, that is, the starting address and ending address of each video frame.

[0067] The audio and video data is saved first, followed by the media header. This ensures that there are no interruptions during the entire file storage process. If an exception (such as an abnormal interruption) interrupts the recording process, the media header will not be saved correctly, and the player will eventually be unable to play the video.

[0068] See Figure 1 , Figure 1 This is a schematic diagram of a data storage format provided by an exemplary embodiment of the present application. Figure 1 As shown in the figure, video frames and audio frames are arranged alternately. The file starts with a file header and ends with an information header (i.e., a media information header). The file header contains basic information about the file format, such as the encoding format of the audio data, the encoding format of the video data, and the packaging format of the entire file.

[0069] Among them, the video frame is composed of a video frame synchronization code, a video frame NAL header and video raw stream data, while the audio frame has no header information and is only composed of audio raw stream data (such as audio RAW data). Figure 1 This is just an example; there may or may not be one or more audio frames between two video frames. If an exception (such as an interruption) interrupts the recording process, the media information header will not be correctly saved. As a result, the storage location and length of each audio and video frame will be unknown, and the file will not be able to play properly.

[0070] To avoid this situation, small file storage is often used. For example, when storing audio and video data, the data is segmented into several small files at fixed intervals (e.g., N seconds). This way, if an exception occurs, only N seconds of data is lost. However, in the field of surveillance and security, every second of data is crucial; even a single second of data can contain crucial information. To further reduce the risk of data loss, two common solutions are used.

[0071] The first type is pre-processing, which is performed before an exception occurs. This pre-processing process first writes the initial media information header. Then, after the audio and video data are written, the media information header is updated in real time and written back to disk. The initial media information header is similar to the media information header, except that for audio data, it does not include the length and storage location of each audio frame, and for video data, it does not include the length and storage location of each video frame. Updating the media information header adds this information that is not in the initial media information header.

[0072] The other type of processing is post-processing, performed after an anomaly occurs. This involves manually guessing the encoding format of the anomaly file based on other files on disk. This is then decoded using a decoder (such as an audio or video decoder). If decoding succeeds, the guess is correct, and the anomaly file has been repaired. If not, the guess is incorrect, and the anomaly file cannot be repaired.

[0073] Of these two solutions, the former requires a real-time update of the media header for each frame of audio or video data stored, which directly increases energy consumption. Furthermore, since exceptions are rare, real-time updates are often ineffective. Furthermore, the entire process requires frequent disk writes, which significantly damages the disk. The latter requires manual intervention and decoder repair, which is not only time-consuming and labor-intensive, but also has poor repair results.

[0074] In light of this, the present application provides a method for repairing files, comprising: obtaining an abnormal file containing normal video frames and frames to be repaired; determining the frame type of the frames to be repaired based on the normal video frames; repairing the frames to be repaired based on the frame type to obtain repaired frames; and generating a repair file corresponding to the abnormal file based on the normal video frames, the repaired frames, and a preset configuration file. The entire repair process is automated, requiring no human intervention or decoder processing, improving the speed and effectiveness of file repair.

[0075] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0076] See also Figure 2 , Figure 2 A flow chart of a method for repairing a file provided by an embodiment of the present application is shown. In a specific embodiment, the method for repairing a file can be executed by a terminal device with processing capabilities, and the terminal device can include a mobile terminal device (for example, a mobile phone, a personal digital assistant (PDA), a tablet computer (Tablet Personal Computer, Tablet PC), a laptop computer, a smart watch, a smart bracelet, etc.) and a fixed terminal device (for example, a desktop computer, an intelligent control panel, etc.). The terminal device can also include various types of servers. For example, the server can be an independent server or a cloud service that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0077] like Figure 2 As shown, the method for repairing a file may include steps S101 to S104.

[0078] S101: Acquire abnormal files.

[0079] In the embodiments of the present application, abnormal files may be abnormal files generated in the field of surveillance and security (such as video surveillance), such as abnormal files generated when abnormalities occur in devices such as smartphones, driving recorders, drones, law enforcement recorders, and hard disk recorders during the storage of audio and video data.

[0080] For example, the cause of the fault that generates the abnormal file is not limited. For example, the fault cause can be an abnormal interruption, equipment failure, network abnormality, etc. Among them, the abnormal interruption can include an abnormal power outage. In this example, the fault cause is an abnormal interruption as an example for explanation.

[0081] The abnormal file contains normal video frames and frames to be repaired. Normal video frames are those that can be quickly and accurately identified in the abnormal file. To facilitate the repair of abnormal files, when storing audio and video data, the first frame stored is usually guaranteed to be a video frame. Therefore, the first frame in the abnormal file can be directly determined to be a normal video frame.

[0082] Optionally, in a possible implementation, the abnormal file contains a normal video frame and a frame to be repaired. In this case, the first frame data in the abnormal file is the normal video frame, and the second frame data is the frame to be repaired.

[0083] Optionally, in a possible implementation, the abnormal file contains a normal video frame and multiple frames to be repaired. Figure 3 , Figure 3 This is a schematic diagram of the data storage format in an abnormal file provided by an exemplary embodiment of the present application. Figure 3 As shown, the first frame of data in the abnormal file is a normal video frame, and the remaining data are multiple frames to be repaired.

[0084] Optionally, in one possible implementation, the abnormal file contains multiple normal video frames and multiple frames to be repaired. In this implementation, in addition to determining the first frame of data in the abnormal file as a normal video frame, video frames obtained by repairing the frames to be repaired during the file repair process are also determined as normal video frames. This is merely an example and is not intended to be limiting.

[0085] S102: Determine the frame type of the frame to be repaired according to the normal video frame.

[0086] The frame type may include a video frame type and an audio frame type. If the frame type of the frame to be repaired is a video frame type, it is proved that the frame to be repaired is a video frame; if the frame type of the frame to be repaired is an audio frame type, it is proved that the frame to be repaired is an audio frame.

[0087] Optionally, in one possible implementation, a detection is performed to determine whether the normal video frame contains identification information. If the normal video frame contains identification information, the frame type of the frame to be repaired is determined to be an audio frame type. If the normal video frame does not contain identification information, a determination is made as to whether the frame to be repaired is similar to the normal video frame. If the frame to be repaired is determined to be similar to the normal video frame, the frame type of the frame to be repaired is determined to be a video frame type; if the frame to be repaired is determined to be not similar to the normal video frame, the frame type of the frame to be repaired is determined to be an audio frame type.

[0088] Alternatively, in one possible implementation, it may be possible to detect whether identification information is present after the normal video frame. If identification information is present after the normal video frame, the frame type of the frame to be repaired is determined to be an audio frame type. If identification information is not present after the normal video frame, it is determined whether the frame to be repaired is similar to the normal video frame. If the frame to be repaired is determined to be similar to the normal video frame, the frame type of the frame to be repaired is determined to be a video frame type; if the frame to be repaired is determined to be not similar to the normal video frame, the frame type of the frame to be repaired is determined to be an audio frame type.

[0089] For example, if the abnormal file contains a normal video frame and a frame to be repaired, and if it is detected that the normal video frame contains identification information, the frame type of the frame to be repaired is determined to be an audio frame type. If it is detected that the normal video frame does not contain identification information, it is determined whether the frame to be repaired is similar to the normal video frame. If it is determined that the frame to be repaired is similar to the normal video frame, the frame type of the frame to be repaired is determined to be a video frame type; if it is determined that the frame to be repaired is not similar to the normal video frame, the frame type of the frame to be repaired is determined to be an audio frame type. If the abnormal file contains a normal video frame and multiple frames to be repaired, the frame type of each frame to be repaired is determined in sequence using the above method.

[0090] S103: Repair the frame to be repaired according to the frame type to obtain a repaired frame.

[0091] For example, repairing the frame to be repaired essentially involves determining the target frame length and storage location of the frame to be repaired. The storage location includes the start address and end address of the frame to be repaired. It is understood that once the target frame length and start address of the frame to be repaired are determined, the end address of the frame to be repaired can be calculated.

[0092] When the frame type of the frame to be repaired is a video frame type, the frame to be repaired is repaired, and the repaired video frame is the repaired frame; when the frame type of the frame to be repaired is an audio frame type, the frame to be repaired is repaired, and the repaired audio frame is the repaired frame.

[0093] See Figure 4 , Figure 4 : is a specific flow chart of step S103 of a method for repairing a file shown in another exemplary embodiment of the present application; optionally, in some possible implementations of the present application, the above step S103 may include steps S1031 to S1033, which are specifically as follows:

[0094] S1031: Obtain the starting address of the frame to be repaired.

[0095] S1032: Determine the target frame length of the frame to be repaired according to the frame type.

[0096] S1033: Generate a repair frame according to the start address, target frame length, and media data.

[0097] This implementation fully utilizes the storage characteristics of audio and video data. For example, a video frame consists of a video frame synchronization code, a video frame NAL header, and raw video stream data. When storing a video frame, the video frame synchronization code is replaced with a frame length field. In this example, the first target byte represents the frame length field. In other words, if the frame type of the frame to be repaired is a video frame, obtaining the first target byte of the frame to be repaired can determine the target frame length of the frame to be repaired.

[0098] For example, an audio frame lacks header information and consists solely of raw audio data (e.g., raw audio data). However, audio frames are encoded with a fixed frame length, meaning the output length is fixed, such as a 32-byte fixed sampling interval. This means that if the frame type of the frame to be repaired is an audio frame, the target frame length can be directly determined.

[0099] For example, if the frame preceding the current frame to be repaired is a normal video frame, the starting address of the normal video frame is known. Obtaining the first target byte in the normal video frame can yield the normal video frame's frame length. The normal video frame's ending address can then be calculated using the normal video frame's starting address and frame length. Once the normal video frame's ending address is determined, the starting address of the frame to be repaired is obtained by offsetting the ending address by one bit.

[0100] If the frame type of the frame to be repaired is a video frame type, the first target byte of the frame to be repaired is obtained to obtain the target frame length of the frame to be repaired. If the frame type of the frame to be repaired is an audio frame type, the target frame length of the frame to be repaired can be directly determined based on the storage characteristics of audio and video data, such as 32 bytes.

[0101] The end address of the frame to be repaired is calculated using the start address and target frame length of the frame to be repaired. The start address of the next frame to be repaired is obtained by shifting the end address by one bit. This process is repeated to obtain the target frame length, start address, and end address of each frame to be repaired.

[0102] The frame to be repaired contains media data. When the frame type of the frame to be repaired is a video frame type, the media data is video raw stream data; when the frame type of the frame to be repaired is an audio frame type, the media data is audio raw stream data.

[0103] Optionally, in a possible implementation, a repair frame is generated based on the starting address, target frame length, and media data. After determining the starting address and target frame length of the frame to be repaired, the media data of the frame to be repaired is accurately extracted, and the obtained data is the repair frame. For example, two adjacent frames to be repaired are both audio frames. At this time, when these two frames to be repaired are stored in the file, two segments of audio raw stream data are stored next to each other. After determining the starting address and target frame length of each frame to be repaired, the audio raw stream data of each frame to be repaired can be accurately extracted. At the same time, the starting address and target frame length of each frame to be repaired are restored in the information header (i.e., the media information header) at the end of the file.

[0104] Alternatively, in one possible implementation, since repairing the frames to be repaired essentially involves determining the target frame length and storage location of the frames to be repaired, generating the repair frames based on the starting address, target frame length, and media data can directly restore the starting address and target frame length of each frame to be repaired from the information header (i.e., the media information header) at the end of the file. This is merely an example and is not intended to be limiting.

[0105] In this embodiment, the storage characteristics of audio and video data are fully utilized. According to the storage characteristics of video frames and audio frames, the starting address and target frame length of the frame to be repaired are quickly determined. Thus, each frame to be repaired can be automatically repaired without human intervention, thereby improving the speed and effect of repairing the file.

[0106] S104: Generate a repair file corresponding to the abnormal file according to the normal video frame, the repair frame and the preset configuration file.

[0107] For example, the preset configuration file can be stored during or before recording. The configuration file may include the encoding format of the audio data, the encoding format of the video data, the packaging format of the entire file, the channels and sampling rate of the audio data, the resolution and duration of the video data, etc.

[0108] In this embodiment, a small file storage method is used when storing files. For example, during the storage of audio and video data, the audio and video data is cut at fixed time intervals and divided into several small files, and the format of each small file is consistent. In this way, when repairing abnormal files, other information other than the length and storage location of the audio and video data can be directly restored through the configuration file. For example, the file header can be restored through the configuration file, the audio channel and sampling rate of the audio data in the information header (i.e., the media information header), and the resolution and duration of the video data can be restored.

[0109] For example, based on a preset configuration file, all information in the abnormal file, except the length and storage location of the audio and video data, is restored. When repairing frames to be repaired based on their frame types, the target frame lengths and storage locations of the audio and video frames are restored. The restored file header is added to the beginning of the abnormal file, and the information header (i.e., the media information header) is added to the end of the abnormal file to obtain a repaired file corresponding to the abnormal file.

[0110] Optionally, in a possible implementation, other information in the abnormal file, except for the length and storage location of the audio and video data, can be restored according to a preset configuration file. According to the storage location of the normal video frame and the repaired frame, each normal video frame and the repaired frame are stored in sequence to obtain a new file. The restored file header is added to the beginning of the new file, and the information header (i.e., the media information header) is added to the end of the new file to obtain the repair file corresponding to the abnormal file. This is only an exemplary description and is not limited to this.

[0111] In this embodiment, an abnormal file is obtained, which contains normal video frames and frames to be repaired. The frame type of the frame to be repaired is determined based on the normal video frames. The frame to be repaired is repaired based on the frame type to obtain a repaired frame. Then, a repair file corresponding to the abnormal file is generated based on the normal video frames, the repaired frames, and a preset configuration file. The entire repair process fully utilizes the storage characteristics of audio and video data. By determining whether the normal video frames and the frame to be repaired are similar, the frame type of the frame to be repaired is quickly determined. Then, based on the characteristics of different frame types, the starting address and target frame length of the frame to be repaired are quickly determined. This automatically repairs each frame to be repaired without manual intervention or decoder decoding. The repair file is generated based on the normal video frames, the repaired frames, and the preset configuration file, improving the speed and effectiveness of the file repair process.

[0112] Optionally, in some possible implementations of the present application, the number of normal video frames and frames to be repaired are both multiple, multiple normal video frames and multiple frames to be repaired are arranged alternately, and there are one or more frames to be repaired between two normal video frames. In this implementation, in addition to determining the first frame of data in the abnormal file as a normal video frame, the video frame obtained by repairing the frame to be repaired during the file repair process is also determined to be a normal video frame. Each data determined to be a normal video frame can be used to determine whether the frame to be repaired after the normal video frame is an audio frame or a video frame. It can be understood that each data determined to be a normal video frame can be used to repair the frame to be repaired after the normal video frame.

[0113] For example, since it is guaranteed that the first frame of data stored is a video frame during the file storage process, the first frame of data in the abnormal file is directly determined to be a normal video frame. Based on the normal video frame, it can be determined whether the frame to be repaired (the second frame of data) after the normal video frame is an audio frame or a video frame. If it is determined that the frame to be repaired is an audio frame, continue to determine whether the frame to be repaired (the third frame of data) after the normal video frame is an audio frame or a video frame based on the normal video frame. If it is determined that the frame to be repaired is a video frame, the video frame is determined to be a normal video frame. At this time, the normal video frame is the third frame of data. Based on the normal video frame (the third frame of data), it is determined whether the subsequent frame to be repaired (the fourth frame of data) is an audio frame or a video frame, and so on, until the abnormal file is processed.

[0114] The above step S102 may include steps S1021 to S1022, which are specifically as follows:

[0115] S1021: For each normal video frame, detect identification information in the normal video frame.

[0116] S1022: When the identification information is detected, determine that the frame type of the frame to be repaired is an audio frame type.

[0117] Exemplarily, the identification information is used to identify whether an audio frame follows the normal video frame. For example, if the identification information is present in the normal video frame, it indicates that an audio frame follows the normal video frame. It is worth noting that if the identification information is absent in the normal video frame, it does not necessarily mean that no audio frame follows the normal video frame. In other words, if the identification information is absent in the normal video frame, the normal video frame may or may not follow an audio frame.

[0118] The identification information may include preset bytes. The number of preset bytes indicates the number of audio frames in the frame to be repaired. The preset bytes are set and adjusted by the user based on actual conditions. To prevent the preset bytes from affecting decoding, the preset bytes can be set to 0 bytes. 0 bytes are redundant bytes for video frames and do not affect decoding. The number of zero bytes indicates the number of audio frames following the normal video frame.

[0119] For example, if a 0 byte is detected in a normal video frame, the frame to be repaired following the normal video frame is first determined to be an audio frame, i.e., the frame type of the frame to be repaired following the normal video frame is determined to be an audio frame type. If three 0 bytes are detected, it is determined that there are three audio frames following the normal video frame, i.e., the frame types of the three frames to be repaired following the normal video frame are all determined to be audio frames. This is merely an example and is not intended to be limiting.

[0120] In this embodiment, if identification information is detected in a normal video frame, the frame type of the frame to be repaired following the normal video frame can be quickly determined to be an audio frame. After determining the frame type, the target frame length of the audio frame can be quickly determined based on the storage characteristics of the audio and video data, thereby improving the speed of file repair.

[0121] Optionally, in some possible implementations of the present application, step S1021 may further include steps S1023 to S1025, as follows:

[0122] S1023: When no identification information is detected, determine whether the first frame to be repaired is similar to a normal video frame.

[0123] The first frame to be repaired is the first frame to be repaired after the normal video frame.

[0124] For example, if no identification information is detected in a normal video frame, it does not necessarily mean that there is no audio frame after the normal video frame. In this case, it is necessary to determine whether the first frame to be repaired is similar to the normal video frame, that is, to determine whether the first frame to be repaired after the normal video frame is similar to the normal video frame.

[0125] S1024: When it is determined that the first frame to be repaired is not similar to the normal video frame, determine that the frame type of the first frame to be repaired is an audio frame type; or when it is determined that the first frame to be repaired is similar to the normal video frame, determine that the frame type of the first frame to be repaired is a video frame type.

[0126] For example, a normal video frame is a video frame. If the determination result is that the first frame to be repaired is not similar to the normal video frame, indicating that the first frame to be repaired and the video frame differ significantly, the frame type of the first frame to be repaired is determined to be an audio frame type, i.e., the first frame to be repaired is determined to be an audio frame. If the determination result is that the first frame to be repaired is similar to the normal video frame, indicating that the first frame to be repaired and the video frame differ slightly, the frame type of the first frame to be repaired is determined to be a video frame type, i.e., the first frame to be repaired is determined to be a video frame.

[0127] S1025: Determine whether the second frame to be repaired is similar to the normal video frame, and determine the frame type of the second frame to be repaired according to the determination result, wherein the second frame to be repaired is a frame to be repaired adjacent to the first frame to be repaired.

[0128] The second frame to be repaired is the second frame to be repaired after the normal video frame and is also the frame to be repaired adjacent to the first frame to be repaired. When the first frame to be repaired is an audio frame, the second frame to be repaired is similar to the normal video frame. If the determination result is that the second frame to be repaired is not similar to the normal video frame, indicating that the second frame to be repaired and the video frame are significantly different, the frame type of the second frame to be repaired is determined to be an audio frame type, that is, the second frame to be repaired is determined to be an audio frame. If the determination result is that the second frame to be repaired is similar to the normal video frame, indicating that the second frame to be repaired and the video frame are slightly different, the frame type of the second frame to be repaired is determined to be a video frame type, that is, the second frame to be repaired is determined to be a video frame.

[0129] It is worth noting that when the first frame to be repaired is a video frame, it is determined to be a normal video frame. At this time, the judgment of the second frame to be repaired should be based on the newly determined normal video frame. That is, it is determined whether the second frame to be repaired is similar to the newly determined normal video frame. If so, the frame type of the second frame to be repaired is determined to be a video frame type, that is, the second frame to be repaired is determined to be a video frame. If not, the frame type of the second frame to be repaired is determined to be an audio frame type, that is, the second frame to be repaired is determined to be an audio frame.

[0130] Similarly, the above process is performed on each frame to be repaired to obtain the frame type of each frame to be repaired. This is only an exemplary description and is not intended to limit this.

[0131] In this embodiment, if the absence of identification information in a normal video frame is detected, the system further determines whether the frame to be repaired is similar to the normal video frame. Based on this determination, the frame type of the frame to be repaired is determined to be an audio frame or a video frame. This determines whether the frame to be repaired is an audio frame or a video frame. After determining the frame type, the target frame lengths for audio and video frames can be quickly determined based on the storage characteristics of the audio and video data, thereby improving the speed of file repair.

[0132] Optionally, in some possible implementations of the present application, step S1023 may include steps S10231 to S10233, which are specifically as follows:

[0133] S10231: When no identification information is detected, obtain the first target byte in the first frame to be repaired.

[0134] S10232: Generate a frame length of the first frame to be repaired according to the first target byte.

[0135] S10233: When the frame length is greater than or equal to a preset threshold, determine that the first frame to be repaired is not similar to a normal video frame.

[0136] For example, the first target byte represents a frame length field. In this embodiment, the first target byte may be the first four bytes of the first frame to be repaired. If the first frame to be repaired is ultimately determined to be a video frame, the first target byte represents the target frame length of the video frame.

[0137] The preset threshold is user-defined based on actual conditions. The threshold setting can be dependent on the image's height, width, and format (e.g., YUV420 or YUV422). For example, the threshold can be set to the original length of a single frame of RAW image data. For example, if the format is YUV420, the threshold is set to 2 / 3 the height * width of the RAW image data. This ensures that if the frame to be repaired is a video frame, the resulting frame length, after video compression processing, is always less than the original frame length.

[0138] Exemplarily, when no identification information is detected, the first four bytes of the first frame to be repaired are obtained, and a frame length is formed based on the obtained first four bytes. This frame length is used to represent the frame length of the first frame to be repaired. This frame length is compared with a preset threshold, and based on the comparison result, a determination is made as to whether the first frame to be repaired is similar to a normal video frame. If the frame length is greater than or equal to the preset threshold, the similarity between the frame to be repaired and the normal video frame is zero, and the first frame to be repaired is determined to be dissimilar to the normal video frame. In this case, the frame type of the first frame to be repaired is determined to be an audio frame type, i.e., the first frame to be repaired is determined to be an audio frame.

[0139] In this embodiment, the frame length of the frame to be repaired is compared with a preset threshold to determine the similarity between the frame to be repaired and a normal video frame, thereby determining whether the frame to be repaired is similar to the normal video frame. Because the preset threshold is set based on relevant image data, the comparison with the preset threshold can accurately determine whether the frame to be repaired is similar to the normal video frame, which facilitates the subsequent accurate determination of the frame type of the frame to be repaired.

[0140] Optionally, in some possible implementations of the present application, the above step S10232 may further include steps S10234 to S10236, as follows:

[0141] S10234: When the frame length is less than a preset threshold, obtain the second target byte in the first frame to be repaired.

[0142] S10235: If it is detected that the second target byte is within the preset value range, it is determined that the first frame to be repaired is similar to the normal video frame.

[0143] S10236: If it is detected that the second target byte is not within the preset value range, it is determined that the first frame to be repaired is not similar to the normal video frame.

[0144] Exemplarily, the frame length is compared with a preset threshold. To ensure the accuracy of the final determination of whether the first frame to be repaired is similar or dissimilar to a normal video frame, when the frame length is less than the preset threshold, a second target byte is obtained from the first frame to be repaired. The second target byte is used to represent the value corresponding to the frame type of the first frame to be repaired. In this embodiment, the second target byte can be the fifth byte of the first frame to be repaired. In layman's terms, the second target byte can be used to determine whether the first frame to be repaired contains a reasonable frame type.

[0145] The preset value range is set by the user based on actual conditions. A check is performed to see if the second target byte is within the preset value range. If so, the similarity between the first frame to be repaired and the normal video frame is 1, and the first frame to be repaired is determined to be similar to the normal video frame. If the second target byte is not within the preset value range, the similarity between the first frame to be repaired and the normal video frame is 0, and the first frame to be repaired is determined to be dissimilar to the normal video frame.

[0146] Optionally, in a possible implementation, the fifth byte may be operated on to detect whether the operation result is within a preset value range. If it is detected that the operation result is within the preset value range, it indicates that the first frame to be repaired contains a reasonable frame type, and the similarity between the first frame to be repaired and the normal video frame is 1. In this case, it is determined that the first frame to be repaired is similar to the normal video frame. If it is detected that the operation result is not within the preset value range, it indicates that the first frame to be repaired does not contain a reasonable frame type, and the similarity between the first frame to be repaired and the normal video frame is 0. In this case, it is determined that the first frame to be repaired is not similar to the normal video frame.

[0147] For example, assuming that the fifth byte is A, for the H264 code stream, the value corresponding to the frame type is A&0x1f. According to the H264 code stream standard, the preset value range is that the result of the operation is greater than 0 and less than 13. Among them, 0x1f represents 0001 1111, and A&0x1f represents A and 0001 1111 performed in phase. For the H265 code stream, the value corresponding to the frame type is (A&0x7E)>>1. According to the H265 code stream standard, the preset value range is that the result of the operation is greater than or equal to 0 and less than or equal to 40. This is only an exemplary description and is not limited to this.

[0148] In this embodiment, on the basis of using a preset threshold to determine whether the frame to be repaired is similar to the normal video frame, it is further determined whether the frame to be repaired contains a reasonable frame type. According to the judgment result, it is accurately determined whether the frame to be repaired is similar to the normal video frame, which improves the accuracy and is conducive to the subsequent accurate determination of the frame type of the frame to be repaired.

[0149] Optionally, in some possible implementations of the present application, the present application also provides a method for storing files, which can be Figure 2 The corresponding embodiment is performed before. Specifically, during the process of storing a normal file, a first video frame and a second video frame are determined, the second video frame is stored after the first video frame, and one or more audio frames are stored between the first video frame and the second video frame; for each audio frame, whether the audio frame is similar to the first video frame is determined; if the audio frame is determined to be similar to the first video frame, identification information is added to the first video frame.

[0150] For example, during the storage of a normal file, the first frame of the file is ensured to be a video frame, and this video frame is determined as the first video frame. The audio and video data is then stored, and during the storage of the audio and video data, it is possible to determine whether the next frame of data stored is a video frame or an audio frame. If it is detected that a certain frame of stored data is a video frame, and one or more audio frames are stored between this video frame and the first video frame, this video frame is determined to be the second video frame.

[0151] For each audio frame stored between the first video frame and the second video frame, the audio frame is compared with the first video frame for similarity, thereby determining whether the audio frame is similar to the first video frame. It is worth noting that the process of determining whether the audio frame is similar to the first video frame is similar to the process of determining whether the first frame to be repaired is similar to the normal video frame.

[0152] For example, the first four bytes of the audio frame are obtained, and the frame length is formed based on the obtained first four bytes. The frame length is compared with a preset threshold, and the similarity between the audio frame and the first video frame is determined based on the comparison result. If the frame length is greater than or equal to the preset threshold, the similarity between the audio frame and the first video frame is 0, and the audio frame is determined to be dissimilar to the first video frame. This proves that even if an anomaly occurs in the file later, this similarity determination method can directly determine that the frame is an audio frame.

[0153] If the frame length is less than a preset threshold, the fifth byte of the audio frame is obtained and an operation is performed on the fifth byte to check whether the operation result is within the preset value range. If the operation result is not within the preset value range, it indicates that the audio frame does not contain a reasonable frame type, and the similarity between the audio frame and the first video frame is 0. In this case, the audio frame is determined to be dissimilar to the first video frame. This proves that even if an anomaly occurs in the file later, this judgment method can still determine that the frame is an audio frame.

[0154] If it is detected that the operation result is within the preset value range, it means that the audio frame contains a reasonable frame type, and the similarity between the audio frame and the first video frame is 1. At this time, it is determined that the audio frame is similar to the first video frame. Since the audio frame is extremely similar to the first video frame, that is to say, if an abnormality occurs in the file later, it is not easy to determine that the frame is an audio frame. At this time, identification information is added to the first video frame, such as adding preset bytes (such as 0 bytes), or identification information is added after the first video frame. One 0 byte represents an audio frame. If there are multiple audio frames, the same number of 0 bytes are added. This is only an exemplary description and is not limited to this.

[0155] It's worth noting that storing audio and video data is an ongoing process, and the determination of the first and second video frames changes accordingly. For example, in the example above, after processing the audio frames preceding the first and second video frames, the second video frame is determined to be the new first video frame, and the video frame following the second video frame is determined to be the new second video frame. The above-described similarity determination and identification information addition processes are repeated until the entire storage process is complete.

[0156] In this embodiment, when a normal file is stored and an audio frame is detected to be similar to a video frame, identification information is added to the video frame. Even if an anomaly subsequently occurs, turning the normal file into an abnormal file, the identification information can be used to quickly determine that the frame type of the frame to be repaired is an audio frame. This ensures file repair and improves the speed of file repair. Furthermore, when storing normal files, frequent write operations to the disk are not required, effectively reducing disk wear and tear.

[0157] For ease of understanding, the following scenario is used as an example. For example, before storing a normal file, a global configuration file can be pre-set. The configuration file can include the encoding format of the audio data, the encoding format of the video data, the packaging format of the entire file, the channels and sampling rate of the audio data, the resolution and duration of the video data, etc.

[0158] During normal file storage, check for changes to storage settings, such as encoding, packaging format, and storage address. If so, update the configuration file based on the changed settings. If not, create a temporary media data file and set a default suffix, such as .media.tmp.

[0159] Audio and video data is obtained from a network port, a Universal Serial Bus (USB) port, a software or hardware encoder, etc., and enters a data structure queue (e.g., a FIFO queue). At this point, a determination is made as to whether the FIFO queue contains two video frames. If the FIFO queue contains two video frames, a determination is made as to whether an audio frame is contained between the two video frames.

[0160] If there is an audio frame between two video frames, each audio frame between the two video frames is compared with the first video frame in the two video frames for similarity. If the similarity between each audio frame and the first video frame is 0, all audio and video data before the second video frame in the FIFO queue are written into the storage system according to the FIFO queue principle. Determine whether the storage process is completed. If so, store all remaining data in the FIFO queue. Change the suffix of the temporary media data file to .mp4 to complete the entire storage process. During storage, for video frames, replace the video frame synchronization code with the frame length field.

[0161] If the similarity between the audio frame and the first video frame is 1, calculate the number of audio frames in the FIFO queue and fill the first video frame or the first video frame with the same number of zero bytes. All audio and video data before the second video frame in the FIFO queue is written to the storage system according to the FIFO queue principle. Determine whether the storage process is complete. If so, store all remaining data in the FIFO queue. Change the temporary media data file's suffix to .mp4 to complete the storage process.

[0162] Optionally, in some possible implementations of the present application, the cause of the abnormal file failure can be determined by detecting the suffix of the abnormal file. Specifically, when the suffix of the abnormal file is detected to be a preset suffix, the cause of the abnormal file failure is determined to be an abnormal interruption.

[0163] For example, the preset suffix is ​​a suffix that a user sets for a temporary media data file during normal file storage. When an exception occurs, the suffix is ​​not changed in time, and the file being stored becomes an abnormal file due to the exception. The preset suffix is ​​retained in the abnormal file. Therefore, by detecting the preset suffix, the cause of the abnormal file failure can be determined.

[0164] For example, check whether the suffix of the abnormal file is .media.tmp. If the suffix of the abnormal file is .media.tmp, it proves that the fault cause of the abnormal file is abnormal interruption.

[0165] Optionally, in some possible implementations of the present application, it is also possible to search in the storage system whether there is a file with the suffix .media.tmp. If there is a file with the suffix .media.tmp, it means that the last step of file storage is not completed, proving that there is an abnormal interruption. Otherwise, there is no abnormal interruption.

[0166] In this embodiment, the cause of the abnormal file can be quickly determined by detecting the suffix name, thereby improving the speed of determining the cause of the fault.

[0167] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0168] See Figure 5 , Figure 5 This is a schematic diagram of a device for repairing files provided by an embodiment of the present application. The device for repairing files includes units for performing Figure 1 、 Figure 4 For details, please refer to the steps in the corresponding embodiment. Figure 1 、 Figure 4 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 5 ,include:

[0169] An acquisition unit 210 is configured to acquire an abnormal file, wherein the abnormal file includes normal video frames and frames to be repaired;

[0170] a determination unit 220, configured to determine a frame type of a frame to be repaired based on a normal video frame;

[0171] A repairing unit 230 is configured to repair the frame to be repaired according to the frame type to obtain a repaired frame;

[0172] The generating unit 240 is configured to generate a repair file corresponding to the abnormal file according to the normal video frame, the repair frame and a preset configuration file.

[0173] Optionally, in a possible implementation, the number of normal video frames and frames to be repaired are both multiple, and the multiple normal video frames and the multiple frames to be repaired are arranged alternately, and there are one or more frames to be repaired between two normal video frames. The determination unit 220 is specifically used to: for each normal video frame, detect identification information in the normal video frame, the identification information includes preset bytes, and the number of preset bytes indicates that the frames to be repaired are audio frames; when the identification information is detected, determine that the frame type of the frame to be repaired is an audio frame type.

[0174] Optionally, in a possible implementation, the device further includes a detection unit, which is used to: when no identification information is detected, determine whether the first frame to be repaired is similar to the normal video frame, and the first frame to be repaired is the first frame to be repaired after the normal video frame; when it is determined that the first frame to be repaired is not similar to the normal video frame, determine that the frame type of the first frame to be repaired is an audio frame type; or, when it is determined that the first frame to be repaired is similar to the normal video frame, determine that the frame type of the first frame to be repaired is a video frame type; determine whether the second frame to be repaired is similar to the normal video frame, and determine the frame type of the second frame to be repaired based on the judgment result, and the second frame to be repaired is the frame to be repaired adjacent to the first frame to be repaired.

[0175] Optionally, in a possible implementation, the detection unit is further used to: obtain the first target byte in the first frame to be repaired when no identification information is detected; generate the frame length of the first frame to be repaired based on the first target byte; and when the frame length is greater than or equal to a preset threshold, determine that the first frame to be repaired is not similar to a normal video frame.

[0176] Optionally, in a possible implementation, the detection unit is further used to: when the frame length is less than a preset threshold, obtain a second target byte in the first frame to be repaired, the second target byte being used to represent the value corresponding to the frame type of the first frame to be repaired; if the second target byte is detected to be within a preset value range, it is determined that the first frame to be repaired is similar to a normal video frame; or, if the second target byte is detected not to be within the preset value range, it is determined that the first frame to be repaired is not similar to a normal video frame.

[0177] Optionally, in one possible implementation, the frame to be repaired includes media data, and the repair unit 230 is specifically used to: obtain the starting address of the frame to be repaired; determine the target frame length of the frame to be repaired according to the frame type; and generate a repair frame according to the starting address, target frame length and media data.

[0178] Optionally, in a possible implementation, the device further includes a fault determination unit, configured to determine that a fault cause of generating the abnormal file is an abnormal interruption when detecting that the suffix of the abnormal file is a preset suffix.

[0179] Optionally, in a possible implementation, the device further includes a storage unit, which is used to: in the process of storing a normal file, determine a first video frame and a second video frame, the second video frame is stored after the first video frame, and one or more audio frames are stored between the first video frame and the second video frame; for each audio frame, determine whether the audio frame is similar to the first video frame; if it is determined that the audio frame is similar to the first video frame, add identification information to the first video frame.

[0180] See Figure 6 , Figure 6 This is a schematic diagram of a terminal device provided by another embodiment of the present application. Figure 6 As shown, the terminal device 3 of this embodiment includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30. When the processor 30 executes the computer program 32, the steps in the above-mentioned various file repair method embodiments are implemented, such as Figure 1 Alternatively, when the processor 30 executes the computer program 32, the functions of the units in the above embodiments are realized, for example, Figure 5 The functions of units 210 to 240 are shown.

[0181] Exemplarily, the computer program 32 may be divided into one or more units, which are stored in the memory 31 and executed by the processor 30 to implement the present application. The one or more units may be a series of computer instruction segments capable of performing specific functions, which describe the execution process of the computer program 32 in the terminal device 3. For example, the computer program 32 may be divided into an acquisition unit, a determination unit, a repair unit, and a generation unit, with the specific functions of each unit being as described above.

[0182] The terminal device may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will understand that Figure 6 It is only an example of terminal device 3 and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0183] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0184] The memory 31 may be an internal storage unit of the terminal device, such as a hard disk or memory of the device. The memory 31 may also be an external storage terminal of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Furthermore, the memory 31 may include both an internal storage unit of the device and an external storage terminal. The memory 31 is used to store the computer instructions and other programs and data required by the terminal. The memory 31 may also be used to temporarily store data that has been output or is about to be output.

[0185] An embodiment of the present application further provides a computer storage medium, which may be non-volatile or volatile. The computer storage medium stores a computer program, which, when executed by a processor, implements the steps in the above-mentioned various file repair method embodiments.

[0186] The present application also provides a computer program product. When the computer program product is run on a device, the device is caused to execute the steps in the above-mentioned various file repair method embodiments.

[0187] An embodiment of the present application further provides a chip or integrated circuit, which includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip or integrated circuit executes the steps in the above-mentioned various file repair method embodiments.

[0188] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0189] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0190] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0191] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A method for repairing a file, characterized in that: include: Acquire an abnormal file, wherein the abnormal file contains a normal video frame and a frame to be repaired; According to the normal video frame, the frame type of the frame to be repaired is determined; the number of the normal video frame and the number of the frame to be repaired are both multiple, the multiple normal video frames and the multiple frames to be repaired are arranged alternately, and there are one or more frames to be repaired between two normal video frames, and the frame type of the frame to be repaired is determined according to the normal video frame, including: for each normal video frame, detecting identification information in the normal video frame, the identification information includes preset bytes, and the number of the preset bytes indicates that the frame to be repaired is the number of audio frames; when the identification information is detected, determining that the frame type of the frame to be repaired is an audio frame type; or, When the identification information is not detected, determining whether the first frame to be repaired is similar to the normal video frame, the first frame to be repaired being the first frame to be repaired after the normal video frame; when it is determined that the first frame to be repaired is not similar to the normal video frame, determining that the frame type of the first frame to be repaired is the audio frame type; When it is determined that the first frame to be repaired is similar to the normal video frame, determining that the frame type of the first frame to be repaired is a video frame type; determining whether the second frame to be repaired is similar to the normal video frame, and determining the frame type of the second frame to be repaired according to the determination result, wherein the second frame to be repaired is a frame to be repaired adjacent to the first frame to be repaired; Repairing the frame to be repaired according to the frame type to obtain a repaired frame; the frame to be repaired includes media data, and repairing the frame to be repaired according to the frame type to obtain a repaired frame includes: obtaining a starting address of the frame to be repaired; determining a target frame length of the frame to be repaired according to the frame type; generating the repaired frame according to the starting address, the target frame length and the media data; A repair file corresponding to the abnormal file is generated according to the normal video frame, the repair frame and a preset configuration file.

2. The method according to claim 1, characterized in that: When the identification information is not detected, determining whether the first frame to be repaired is similar to the normal video frame includes: When the identification information is not detected, obtaining a first target byte in the first frame to be repaired; Generating a frame length of the first frame to be repaired according to the first target byte; When the frame length is greater than or equal to a preset threshold, it is determined that the first frame to be repaired is not similar to the normal video frame.

3. The method according to claim 2, characterized in that After generating the frame length of the first frame to be repaired according to the first target byte, the method further includes: When the frame length is less than the preset threshold, obtaining a second target byte in the first frame to be repaired, where the second target byte is used to represent a value corresponding to the frame type of the first frame to be repaired; If it is detected that the second target byte is within a preset value range, it is determined that the first frame to be repaired is similar to the normal video frame; or, If it is detected that the second target byte is not within the preset value range, it is determined that the first frame to be repaired is not similar to the normal video frame.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: When it is detected that the suffix of the abnormal file is a preset suffix, it is determined that the fault cause of generating the abnormal file is an abnormal interruption.

5. The method according to claim 1, characterized in that Before obtaining the abnormal file, the method further includes: In a process of storing a normal file, determining a first video frame and a second video frame, wherein the second video frame is stored after the first video frame, and one or more audio frames are stored between the first video frame and the second video frame; For each audio frame, determining whether the audio frame is similar to the first video frame; If it is determined that the audio frame is similar to the first video frame, identification information is added to the first video frame.

6. A device for repairing a file, characterized in that: include: An acquisition unit, used for acquiring an abnormal file, wherein the abnormal file includes a normal video frame and a frame to be repaired; A determination unit is used to determine the frame type of the frame to be repaired according to the normal video frame; the number of the normal video frame and the number of the frame to be repaired are both multiple, the multiple normal video frames and the multiple frames to be repaired are arranged alternately, and there are one or more frames to be repaired between two normal video frames, and the frame type of the frame to be repaired according to the normal video frame is determined, including: for each normal video frame, detecting identification information in the normal video frame, the identification information includes preset bytes, and the number of the preset bytes indicates that the frame to be repaired is the number of audio frames; when the identification information is detected, determining that the frame type of the frame to be repaired is an audio frame type; or, When the identification information is not detected, determining whether the first frame to be repaired is similar to the normal video frame, the first frame to be repaired being the first frame to be repaired after the normal video frame; when it is determined that the first frame to be repaired is not similar to the normal video frame, determining that the frame type of the first frame to be repaired is the audio frame type; When it is determined that the first frame to be repaired is similar to the normal video frame, determining that the frame type of the first frame to be repaired is a video frame type; determining whether the second frame to be repaired is similar to the normal video frame, and determining the frame type of the second frame to be repaired according to the determination result, wherein the second frame to be repaired is a frame to be repaired adjacent to the first frame to be repaired; A repair unit, configured to repair the frame to be repaired according to the frame type to obtain a repaired frame; the frame to be repaired includes media data, and the repairing the frame to be repaired according to the frame type to obtain the repaired frame includes: obtaining a starting address of the frame to be repaired; determining a target frame length of the frame to be repaired according to the frame type; and generating the repaired frame according to the starting address, the target frame length and the media data; A generating unit is used to generate a repair file corresponding to the abnormal file according to the normal video frame, the repair frame and a preset configuration file.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for repairing a file according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for repairing a file according to any one of claims 1 to 5 are implemented.