Efficient Mp4 file repairing method, terminal equipment and storage medium

By extracting and verifying the key box and media stream information in the Mp4 file, repairing the index Trak and re-encapsulating the Mp4 file, solving the file corruption problem in the dash recorder due to device failure or storage media corruption, and achieving efficient video files repair.

CN119316613APending Publication Date: 2025-01-14YIREN (SHANGHAI) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411347226.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The existing technology is difficult to recover efficiently due to battery failure, equipment failure or storage media damage in the driving recorder.

Method used

By reading the sample Mp4 file, extracting and verifying its Fypt and moov, inputting the corrupt file and reading by bytes, extracting and verifying the mdata of the sample Mp4 file, and extracting the mdata of the corrupt file at the same time, encoding and repairing the index Trak, Fypt and moov of the sample file parses the mdata of the corrupt files one by box and corrects the moov of the corrupt files, and finally encapsulates the Mp4 file back.

Benefits of technology

It effectively solves the problem of Mp4 file corruption caused by abnormal power outage or system downtime, improves the repair efficiency and effect of video files, and ensures the playability of video files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119316613A_ABST
    Figure CN119316613A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of computer data recovery, and particularly relates to an efficient Mp4 file recovery method, terminal equipment and a storage medium. Acquiring a normal video by reading a sample Mp4 file; extracting and verifying the Fapt and the moov of the sample Mp4 file; inputting a corrupted file and reading the corrupted file according to bytes; extracting and verifying the mdata of the sample Mp4 file, and extracting the mdata of the damaged file at the same time; encoding and repairing the index Trak, and performing box analysis on mdata of the damaged file one by one by applying the Fapt and moov of the sample file; after the analysis is completed, the moov of the damaged file is corrected; and packaging and recharging the Mp4, and rewriting the analyzed mdat, moov and Fyt into the file. The damaged file is associated and processed by using the sample file, so that the repair efficiency of the Mp4 file is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer data recovery, and in particular relates to an efficient MP4 file repair method, terminal equipment and storage medium. Background Art

[0002] With the popularization of new energy vehicles in China, the continuous iteration of driverless technology, and the increasing variety of sensors installed in new energy vehicles, the vehicle's ability to perceive the surrounding environment has been greatly improved. In this context, the dash cam has evolved from being purchased and installed by car owners to a standard device equipped when the car leaves the factory (MP4 format is the industry standard video format). A dash cam is a device that can record video and audio information during the driving process of a vehicle. It is usually used to record traffic accidents, violations, etc. during the driving of the vehicle to provide evidence and monitoring. However, due to various reasons, such as battery failure, equipment failure, storage medium damage, etc., the video files recorded by the dash cam are sometimes damaged or cannot be played. Therefore, a solution is urgently needed to recover damaged video files, and improving the efficiency and effect of recovery is also a key task. Summary of the invention

[0003] In view of the above-mentioned defects of the prior art, the purpose of the present invention is to provide an efficient MP4 file repair method, terminal device and storage medium, by using sample files to associate and process damaged files to improve the MP4 file repair efficiency.

[0004] To achieve the above object, the present invention provides the following technical solutions:

[0005] An efficient MP4 file repair method, the method comprising:

[0006] Read the sample MP4 file and get the normal video;

[0007] Extract and verify Fypt and moov of sample MP4 files;

[0008] Input corrupted file and read it byte by byte;

[0009] Extract and verify the mdata of the sample Mp4 file, and also extract the mdata of the damaged file;

[0010] Encode the repair index Trak and use the sample file's Fypt and moov to parse the damaged file's mdata box by box. After parsing, correct the damaged file's moov;

[0011] Encapsulate and re-inject MP4, and re-write the parsed mdat, moov, and Fypt into the file.

[0012] Furthermore, the extraction and verification of the Fypt and moov of the sample MP4 file is specifically as follows:

[0013] Extract the sample Mp4 file to temporarily store Fypt bytes and mvhdbox in cache moov;

[0014] Extract all media stream information trakbox from the sample MP4 file;

[0015] According to the ISO / IEC 14496-12MP4 PART12 standard, the Fypt and Moov protocol fields are parsed and verified for temporary storage.

[0016] Create a new encoder using the index and metadata structure of the sample file;

[0017] The damaged file's mdat is decoded packet by packet according to the index. If it cannot be parsed, it is considered unrepairable and bytes or boxes are skipped until all bytes of mdate are processed, and then moov is corrected.

[0018] An MP4 file repair terminal device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the MP4 file repair method are implemented.

[0019] A computer storage medium stores a computer program, which implements the steps of the above-mentioned repair method when executed by a processor.

[0020] Beneficial effect: The MP4 file repair method provided by the application proposes an MP4 file repair solution by associating and processing damaged files using sample files. It solves the problem of MP4 file damage / unplayable caused by real-time video recording interruption due to abnormal power outages, system abnormalities, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is the packaging format of Mp4;

[0022] Figure 2 This is the flow chart of the Mp4 repair method for this application;

[0023] Figure 3 Fix IndexTrak flow chart for encoding;

[0024] Figure 4 To simulate the physical picture of the data abnormal terminal;

[0025] Figure 5 The file to be repaired;

[0026] Figure 6 This is the repair file after running according to the logic of this application. DETAILED DESCRIPTION

[0027] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, a person of ordinary skill in the art should be able to understand other possible implementations and advantages of the present invention. The components in the figure are not drawn to scale, and similar component symbols are generally used to represent similar components.

[0028] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.

[0029] For ease of understanding, this application first explains the data format, read and write logic, etc. of the MP4 standard.

[0030] Taking the MP4 video generated by the vehicle recorder device as an example, the MP4 file parsing method is guided by ISO / IEC 14496-14.

[0031] MP4 files are composed of boxes, each box is divided into Header and Data. The Header part contains the type and size of the box, and the Data part contains sub-boxes or data. Boxes can nest sub-boxes. MP4 is mainly composed of three boxes: fytp, moov, and mdata. Figure 1 The MP4 file encapsulation format is disclosed. The MP4 encapsulation format is a packaging format that encapsulates and packages existing data in a certain format. MP4 data encapsulation uses boxes (blocks) as units in a container manner, where:

[0032] fytp: File Type Box, located at the beginning of the file, describes the file version, compatible protocol, etc.

[0033] moov: Movie Box, contains the macro description information of all media data in this file and the specific information of each media track, such as creation time, modification time, time measurement scale, file duration, etc.; video codec type, resolution, etc.; audio channels, sampling rate, etc. The codec information of audio and video is usually stored in their respective trak blocks, where mvhd: movie header indicates the overall information of the file, such as duration, creation time, etc., and trak: trak container indicates the container for storing audio and video stream information. mdat: Media Data Box, stores specific media data.

[0034] During the MP4 writing process, multi-track (video, audio) data is encoded and persisted to disk media, and moov is cached in memory until the writing is completed and encapsulated into the MP4 file. During this process, if there is a power outage, system crash, or storage medium damage, the moovbox in the memory will be lost, but the specific media data of mdat has been retained, so repairing moov can repair the video file.

[0035] Therefore, the present application discloses an efficient method for repairing MP4 files, such as Figure 2 As shown, the following steps are included:

[0036] Read the sample MP4 file and get the normal video;

[0037] Extract and verify Fypt and moov of sample MP4 files;

[0038] Input corrupted file and read it byte by byte;

[0039] Extract and verify the mdata of the sample Mp4 file, and also extract the mdata of the damaged file;

[0040] Encode the repair index Trak and use the sample file's Fypt and moov to parse the damaged file's mdata box by box. After parsing, correct the damaged file's moov;

[0041] Encapsulate and re-inject MP4, and re-write the parsed mdat, moov, and Fypt into the file.

[0042] In this implementation, since the loss of moov cannot be repaired, it is necessary to select the video file recorded normally by the original device as input (the recording parameters are consistent with the file to be repaired). The vehicle-mounted terminal device records the video in a loop according to fixed parameters. Even if the device is damaged and cannot be restored, the video data is stored in an independent storage medium (such as an SD memory card), and the encoded media data can be extracted from it; if both the terminal device and the storage medium are damaged, the same specification device can be purchased for data recording to obtain normal video.

[0043] In this implementation, the Fypt and moov of the sample MP4 file are extracted and verified as follows:

[0044] Extract the sample MP4 file according to the MP4 standard byte temporary storage Fypt bytes and cache mvhdbox in moov. Fypt (File Type Box) is usually at the beginning of the file, describing the version and compatible protocol of the file. The key field is major_brand, which indicates which format of decoder is most suitable for parsing the current file. It is the key field for restoring the file later. moov (Movie Box) stores the metadata of MP4. Figure 1 As shown, extract the mvhdbox in the cache moov and ignore the udtabox.

[0045] Extract all media stream information trakbox from the sample MP4 file; generally there are two indexes: one for video stream and one for audio stream.

[0046] According to the ISO / IEC 14496-12MP4 PART12 standard, the Fypt and Moov protocol fields are parsed and verified for temporary storage.

[0047] In this embodiment, if Figure 3 As shown, the encoding repair index Trak is specifically:

[0048] Create a new encoder using the sample file's index and metadata structure; create a new encoder (audio and video) using the sample MP4 file index / metadata structure (Fypt, Moov), and decode the damaged file's mdat (media data) box by box according to the index; if it cannot be parsed, it is considered unreadable, and bytes or boxes are skipped until all bytes of mdate are processed, and then moov is corrected.

[0049] Experimental test verification

[0050] Experimental test preparation: Car dashcam equipment: a commercial hardware product that generates MP4 videos, including damaged and real videos.

[0051] Personal PC: storage medium for videos, execution environment for software repair programs.

[0052] Repair procedure: Logical implementation of the repair process.

[0053] Experimental process:

[0054] 1. Data collection: Start the vehicle-mounted equipment and run it normally for 30 minutes, then simulate an abnormal interruption (in this experiment, by powering off). Figure 4 As shown;

[0055] 2. Remove the SD card from the device, insert it into the card reader, copy the data (1 MP4 file to be repaired and 1 complete MP4 file) to the personal PC and save them in the same directory, such as Figure 5 shown.

[0056] 3. Start the software repair program and wait for the program to complete. Figure 6As shown: fixmp4.exe VID_193903_175.mp4 VID_194204_688.mp4; VID_194204_688.mp4.mp4_fixed.mp4 is the repaired file. It can be seen that the operating system successfully reads the repaired MP4 file information and preloads the video thumbnail.

[0057] On the other hand, the present invention also provides an MP4 file repair terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned MP4 file repair method when executing the program.

[0058] Further, as an executable solution, the MP4 repair terminal device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The MP4 repair terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the composition structure of the above-mentioned MP4 repair terminal device is only an example of the MP4 repair terminal device and does not constitute a limitation on the MP4 repair terminal device. It may include more or less components than the above-mentioned components, or a combination of certain components, or different components. For example, the MP4 repair terminal device may also include input and output devices, network access devices, buses, etc., which are not limited in the embodiments of the present invention.

[0059] Further, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), or field-programmable gate arrays (FPGA), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the MP4 repair terminal device, and uses various interfaces and lines to connect various parts of the entire MP4 repair terminal device.

[0060] The memory can be used to store the computer program or module, and the processor realizes various functions of the MP4 repair terminal device by running or executing the computer program or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store audio and video data before and after MP4 repair, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card) or other volatile solid-state storage devices.

[0061] The present invention also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned repair method are implemented.

[0062] If the module / unit integrated in the MP4 repair terminal device 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 this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.

[0063] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

Claims

1. An efficient MP4 file repair method, characterized in that: The method comprises: Read the sample MP4 file and get the normal video; Extract and verify Fypt and moov of sample MP4 files; Input corrupted file and read it byte by byte; Extract and verify the mdata of the sample Mp4 file, and also extract the mdata of the damaged file; Encode the repair index Trak and use the sample file's Fypt and moov to parse the damaged file's mdata box by box. After parsing, correct the damaged file's moov; Encapsulate and re-inject MP4, and re-write the parsed mdat, moov, and Fypt into the file.

2. The repair method according to claim 1, characterized in that: The Fypt and moov of the sample MP4 file extracted and verified are specifically: Extract the sample Mp4 file to temporarily store Fypt bytes and mvhdbox in cache moov; Extract all media stream information trakbox from the sample MP4 file; According to the ISO / IEC 14496-12MP4 PART12 standard, the Fypt and Moov protocol fields are parsed and verified for temporary storage.

3. The repair method according to claim 1, characterized in that: The encoding repair index Trak is specifically: Create a new encoder using the index and metadata structure of the sample file; The damaged file's mdat is decoded packet by packet according to the index. If it cannot be parsed, it is considered unrepairable and bytes or boxes are skipped until all bytes of mdate are processed, and then moov is corrected.

4. An MP4 repair 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 program, the steps of the MP4 file repair method as described in any one of claims 1 to 3 are implemented.

5. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the MP4 file repair method as described in any one of claims 1 to 3 are implemented.