Method, system, device and storage medium for repairing m4a audio files

By identifying audio frame entry points through memory mapping and byte-by-byte detection, and summarizing and converting audio frame data, the playback problem caused by corrupted metadata in m4a audio files was solved, and file repair was achieved.

CN116821066BActive Publication Date: 2026-04-21AFIRSTSOFT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AFIRSTSOFT CO LTD
Filing Date
2023-06-30
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing technologies lack effective methods to repair audio frames when metadata parsing of m4a audio files is abnormal, resulting in the files being unable to play normally.

Method used

The m4a audio file data is obtained by memory mapping. Two bytes are extracted step by step for legality detection to identify suspected audio frame entries. The suspected audio frame data is summarized and then converted to PCM format before being converted to m4a format.

Benefits of technology

It enables accurate extraction of valid audio frames when metadata is corrupted, thus repairing m4a audio files that cannot be played normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821066B_ABST
    Figure CN116821066B_ABST
Patent Text Reader

Abstract

This invention provides a method, system, device, and storage medium for repairing m4a audio files. After obtaining the m4a audio file data to be repaired, the invention extracts two bytes of data sequentially from the beginning to the end of the file data for validity checks. The method involves determining whether the data at each detection point in the two bytes of data corresponds to its respective feature data to find suspected audio frame entries and summarizing all suspected audio frame entries. Then, based on all suspected audio frame entries, all suspected audio frame data in the m4a audio file data is obtained. Finally, all suspected audio frame data is first converted to PCM data format and then to m4a data format to obtain the repaired m4a audio file. This invention achieves accurate extraction of valid audio frames from m4a audio files when the metadata is corrupted, and repairs unplayable m4a audio files through a certain format conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of audio file repair technology, and in particular to a method, system, device and storage medium for repairing m4a audio files. Background Technology

[0002] M4A files are encapsulated using the MPEG-4 protocol and consist of two main parts. The first part contains the metadata of the audio frames, including information such as the sampling rate, number of channels, bit depth, and position offset. The second part is the raw audio frame data after compression using the AAC algorithm, with the header removed. When the metadata of the audio frame cannot be parsed, the audio cannot be played normally. However, it is still possible to repair the M4A file by judging whether it is a valid audio frame using the remaining information of the audio frame. Current technology lacks a solution that can extract valid audio frames from the remaining information of the audio frame to complete the repair of M4A files.

[0003] Therefore, existing technologies still need to be improved and developed. Summary of the Invention

[0004] The main objective of this invention is to provide a method, system, device, and storage medium for repairing m4a audio files when metadata parsing is abnormal.

[0005] The first aspect of this invention provides a method for repairing m4a audio files, comprising:

[0006] The data of the m4a audio file to be repaired is obtained using memory mapping.

[0007] Following the order from the beginning to the end of the m4a audio file data, two bytes of data are extracted from the m4a audio file data each time for subsequent legality checks;

[0008] Determine whether the data at each detection site in the two bytes of data is its corresponding feature data;

[0009] If the data of each detection site in the two bytes of data is the corresponding feature data, then the first byte of the two bytes of data is taken as the suspected audio frame entry point;

[0010] Obtain all the suspected audio frame entries in the m4a audio file data;

[0011] For any of the suspected audio frame entries, the current suspected audio frame entry is taken as the start of each suspected audio frame segment, and the byte preceding the next suspected audio frame entry is taken as the end of each suspected audio frame segment, thereby obtaining all the suspected audio frame data in the m4a audio file data.

[0012] All the suspected audio frame data are first converted into PCM data format and then into M4A data format to obtain the repaired M4A audio file.

[0013] In an optional embodiment of the first aspect of the present invention, the step of extracting two bytes of data from the m4a audio file data each time for subsequent legality detection, in the order from the beginning to the end of the m4a audio file data, includes:

[0014] Construct a sliding window with a length of 2 bytes;

[0015] The first two bytes of data are extracted from the header of the m4a audio file using the sliding window for a validity check.

[0016] When extracting the next two bytes of data, determine whether the suspected audio frame entry exists in the current two bytes of data;

[0017] If the suspected audio frame entry exists in the current two bytes of data, then the sliding window is shifted backward by two bytes to capture the next two bytes of data;

[0018] If the suspected audio frame entry is not present in the current two bytes of data, the sliding window is shifted backward by one byte to capture the next two bytes of data.

[0019] In an optional embodiment of the first aspect of the present invention, determining whether the data of each detection site in the 2 bytes of data is its corresponding feature data includes:

[0020] Determine whether the data in bits 1-3 of the two bytes of data is syntax element data;

[0021] Determine whether the data in bits 4-7 of the two bytes of data is tag data;

[0022] Determine whether the 8th bit of the 2 bytes of data is the window number data;

[0023] Determine whether the 10th and 11th bits of the two bytes of data are window sequence data;

[0024] Determine whether the 12th bit of the two bytes of data is window shape data.

[0025] In an optional embodiment of the first aspect of the present invention, obtaining the m4a audio file data to be repaired by using memory mapping also includes obtaining the total number of bytes of the m4a audio file data;

[0026] The process of extracting 2 bytes of data from the m4a audio file each time for subsequent legality checks also includes recording the number of bytes that have been checked in the m4a audio file data.

[0027] In an optional embodiment of the first aspect of the present invention, after determining whether the data of each detection site in the 2 bytes of data is its corresponding feature data, the method further includes:

[0028] If the data at each detection point in the two bytes of data is not its corresponding feature data, then it is further determined whether any box tag of the m4a audio file exists in the two bytes of data;

[0029] If any box tag of the m4a audio file is present in the two bytes of data, the detection of the m4a audio file data is considered to be completed, and the extraction of two bytes of data from the m4a audio file data for legality detection is terminated.

[0030] The position of the first box tag in the two bytes of data is determined by reversing the order by four bytes to determine the end of the last suspected audio frame.

[0031] In an optional embodiment of the first aspect of the present invention, if the data at each detection point in the two bytes of data is not its corresponding feature data, then after further determining whether any box tag of the m4a audio file exists in the two bytes of data, the method further includes:

[0032] If the box tag is not present in the two bytes of data, before performing the next extraction of two bytes from the m4a audio file data for legality detection, it is determined whether the number of bytes already detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data.

[0033] If the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data, then the extraction of 2 bytes from the m4a audio file data for legality detection is terminated, and the end of the m4a audio file data is taken as the end of the last suspected audio frame.

[0034] In an optional embodiment of the first aspect of the present invention, the step of first converting all the suspected audio frame data into PCM data format and then into M4A data format to obtain the repaired M4A audio file includes:

[0035] All the suspected audio frame data were converted into PCM format data using the API interface of the ffmpeg tool and saved in the temp.pcm file;

[0036] Then, use the API interface of the ffmpeg tool to convert the temp.pcm file into an m4a audio file.

[0037] A second aspect of the present invention provides a system for repairing m4a audio files, the system comprising:

[0038] The m4a audio file data acquisition module is used to obtain the m4a audio file data to be repaired using memory mapping.

[0039] The byte extraction module is used to extract 2 bytes of data from the m4a audio file data each time, in the order from the beginning to the end, for subsequent legality detection.

[0040] The byte judgment module is used to determine whether the data of each detection site in the two bytes of data is its corresponding feature data;

[0041] The suspected audio frame entry acquisition module is used to take the first byte of the two bytes of data as the suspected audio frame entry if the data of each detection site in the two bytes of data is the corresponding feature data.

[0042] The suspected audio frame entry aggregation module is used to obtain all the suspected audio frame entries in the m4a audio file data;

[0043] The suspected audio frame data acquisition module is used to, for any suspected audio frame entry, take the current suspected audio frame entry as the start of each suspected audio frame segment and the byte before the next suspected audio frame entry as the end of each suspected audio frame segment, and obtain all suspected audio frame data in the m4a audio file data.

[0044] The format conversion module is used to convert all the suspected audio frame data into PCM data format and then into M4A data format to obtain the repaired M4A audio file.

[0045] A fourth aspect of the present invention provides an m4a audio file repair device, the m4a audio file repair device comprising: a memory and at least one processor, the memory storing instructions, and the memory and the at least one processor being interconnected via a circuit;

[0046] The at least one processor invokes the instructions in the memory to cause the m4a audio file repair device to perform the m4a audio file repair method as described in any of the preceding claims.

[0047] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for repairing m4a audio files as described in any of the preceding claims.

[0048] Beneficial Effects: This invention provides a method, system, device, and storage medium for repairing M4A audio files. After obtaining the M4A audio file data to be repaired, the invention extracts two bytes of data at a time from beginning to end for validity checks. The method involves determining whether the data at each detection point in the two bytes corresponds to its respective feature data to find suspected audio frame entries, and then summarizing all suspected audio frame entries. Based on all suspected audio frame entries, all suspected audio frame data in the M4A audio file data is obtained. Finally, all suspected audio frame data is first converted to PCM data format and then to M4A data format to obtain the repaired M4A audio file. This invention achieves accurate extraction of valid audio frames from M4A audio files when the metadata is corrupted, and repairs unplayable M4A audio files through a specific format conversion. Attached Figure Description

[0049] Figure 1 This is a schematic diagram of an embodiment of a method for repairing m4a audio files according to the present invention;

[0050] Figure 2 This is a schematic diagram of an embodiment of the m4a audio file repair system of the present invention;

[0051] Figure 3 This is a schematic diagram of an embodiment of a device for repairing m4a audio files according to the present invention. Detailed Implementation

[0052] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” or “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0053] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1The first aspect of this invention provides a method for repairing m4a audio files, comprising:

[0054] S100. Obtain the m4a audio file data to be repaired using memory mapping. In step S100, in order to facilitate the subsequent detection of the m4a audio file data (binary data) to be repaired, it is necessary to determine whether all bytes in the m4a audio file data have been detected. Obtaining the m4a audio file data to be repaired using memory mapping also includes obtaining the total number of bytes of the m4a audio file data.

[0055] S200. Following the order from beginning to end of the m4a audio file data, extract 2 bytes of data from the m4a audio file data each time for subsequent legality detection; correspondingly, in order to determine how many bytes of the m4a audio file data have been detected, in step S200, extracting 2 bytes of data from the m4a audio file data each time for subsequent legality detection also includes recording the number of bytes detected in the m4a audio file data.

[0056] In an optional embodiment of step S200, the step of extracting 2 bytes of data from the m4a audio file data each time for subsequent legality detection, in the order from the beginning to the end of the m4a audio file data, includes: constructing a sliding window of length 2 bytes; extracting 2 bytes of data from the beginning of the m4a audio file data for legality detection using the sliding window; when extracting the next 2 bytes of data, determining whether the suspected audio frame entry exists in the current 2 bytes of data; if the suspected audio frame entry exists in the current 2 bytes of data, controlling the sliding window to shift backward by 2 bytes to extract the next 2 bytes of data; if the suspected audio frame entry does not exist in the current 2 bytes of data, controlling the sliding window to shift backward by 1 byte to extract the next 2 bytes of data. Specifically, the movement of the sliding window in this invention is determined based on whether the suspected audio frame entry exists in the two bytes of data detected each time. For example, in the first instance, if the suspected audio frame entry exists in the first and second bytes of the m4a audio file data, then the next sliding window will capture the third and fourth bytes of the m4a audio file data; if the suspected audio frame entry does not exist in the first and second bytes of the m4a audio file data, then the next sliding window will capture the second and third bytes of the m4a audio file data.

[0057] S300. Determine whether the data at each detection point in the two bytes of data is its corresponding feature data. In step S300, the legality detection of the present invention mainly detects the syntax elements, tags, window numbers, window sequences, and window shapes in the two bytes of data. That is, in the present invention, determining whether the data at each detection point in the two bytes of data is its corresponding feature data includes: determining whether the data in the first 1-3 bits of the two bytes of data is syntax element data; determining whether the data in the fourth 4-7 bits of the two bytes of data is tag data; determining whether the data in the eighth bit of the two bytes of data is window number data; determining whether the data in the tenth and eleventh bits of the two bytes of data is window sequence data; and determining whether the data in the twelfth bit of the two bytes of data is window shape data.

[0058] More specifically, syntax elements occupy 3 bits of data (bits 1-3), where "000" indicates mono and "001" indicates stereo; tags occupy 4 bits of data (bits 4-7), fixed at "0000"; window numbers occupy 1 bit of data (bit 8), fixed at 1; window sequences occupy 2 bits of data (bits 10-11), where "00" indicates a long window of length 1024, used to encode the middle part of the audio signal, "01" indicates a long window of length 1024, used to encode the beginning part of the audio signal, "02" indicates a short window of length 128, used to encode a short duration of the audio signal, and "03" indicates a long window of length 1024, used to encode the end part of the audio signal; and window shapes occupy 1 bit of data (bit 12), where "0" indicates a Sin Window and "1" indicates a KBD Window.

[0059] S400. If the data of each detection point in the two bytes of data is the corresponding feature data, then the first byte of the two bytes of data is taken as the suspected audio frame entry. In this invention, step S400 is to determine whether the data of the first to third bits in the two bytes of data is "000" or "001"; whether the data of the fourth to seventh bits is "0000"; whether the data of the eighth bit is "1", and so on, until finally determining whether the data of the twelfth bit is "0" or "1".

[0060] S500. Obtain all the suspected audio frame entries in the m4a audio file data; In an optional embodiment of the present invention, when performing the legality detection of the two bytes of data, if each of the two bytes of data contains a suspected audio frame entry, then the suspected audio frame data is obtained together with the subsequent byte detection starting from the suspected audio frame entry until the next suspected audio frame entry is detected, and then the previous suspected audio frame entry and its corresponding suspected audio frame data are packaged into a suspected audio frame.

[0061] S600. For any of the suspected audio frame entries, take the current suspected audio frame entry as the start of each suspected audio frame segment, and take the byte preceding the next suspected audio frame entry as the end of each suspected audio frame segment, to obtain all the suspected audio frame data in the m4a audio file data; In the embodiment of S600 of the present invention, this method is to obtain the suspected audio frame data corresponding to each suspected audio frame entry after obtaining all the suspected audio frame entries in the m4a audio file data.

[0062] S700: First, convert all the suspected audio frame data into PCM data format, then into M4A data format, to obtain a repaired M4A audio file. In step S700, converting all the suspected audio frame data into PCM data format and then into M4A data format to obtain a repaired M4A audio file includes: using the ffmpeg tool's API interface to convert all the suspected audio frame data into PCM format data and saving it in the temp.pcm file; then using the ffmpeg tool's API interface to convert the temp.pcm file into an M4A audio file (the name can be, for example, the original name .m4a).

[0063] In an optional embodiment of the first aspect of the present invention, after determining whether the data at each detection point in the two bytes of data is its corresponding feature data, the method further includes: if the data at each detection point in the two bytes of data is not its corresponding feature data, then further determining whether any box tag of the m4a audio file exists in the two bytes of data; if any box tag of the m4a audio file exists in the two bytes of data, then determining that the detection of the m4a audio file data is completed, and terminating the extraction of two bytes of data from the m4a audio file data for legality detection; and defining the position of the first box tag in the two bytes of data by deducing four bytes backward as the end of the last segment of the suspected audio frame.

[0064] In an optional embodiment of the first aspect of the present invention, after further determining whether any box tag of the m4a audio file exists in the two bytes of data if the data of each detection site in the two bytes of data is not its corresponding feature data, the method further includes: if the box tag does not exist in the two bytes of data, before performing the next extraction of two bytes of data from the m4a audio file data for legality detection, determining whether the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data; if the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data, terminating the extraction of two bytes of data from the m4a audio file data for legality detection, and using the end of the m4a audio file data as the end of the last suspected audio frame.

[0065] In this invention, when performing byte validity checks on the m4a audio file data, there are two different methods for determining when the entire m4a audio file data has been checked, depending on the file situation. One method is when no box tags of the m4a audio file are encountered during the detection of two bytes of data. In this case, the m4a audio file detection is determined by whether the number of detected bytes is the same as the total number of bytes. The other method is when a box tag is found in two bytes of data during the detection of two bytes of data. In this case, the subsequent bytes of the m4a audio file do not need to be detected, and the audio can be directly restored using the previously found valid audio frame data.

[0066] To facilitate understanding of the technical solution of this invention, the overall recovery process of this invention can be understood as follows:

[0067] S1: Obtain the .m4a file data and its total number of bytes (t) using memory mapping, and extract 2 bytes from the first byte position for validity checks, saving the number of bytes searched (n) during the verification. There are several checkpoints: syntax elements, tags, window numbers, window sequences, and window shapes.

[0068] S2: Syntax elements occupy 3 bits of data (bits 1-3), "000" indicates mono, "001" indicates stereo; tag occupies 4 bits of data (bits 4-7), fixed at "0000"; window number occupies 1 bit of data (bit 8), fixed at 1; window sequence occupies 2 bits of data (bits 10-11), "00" indicates a long window of length 1024, used to encode the middle part of the audio signal, "01" indicates a long window of length 1024, used to encode the beginning part of the audio signal, "02" indicates a short window of length 128, used to encode a short duration of the audio signal, "03" indicates a long window of length 1024, used to encode the end part of the audio signal; window shape occupies 1 bit of data (bit 12), "0" indicates Sin Window, "1" indicates KBD Window;

[0069] S3: The first byte of the 2 bytes that satisfies all the conditions of S2 is taken as the suspected audio frame entry, and then S4 is executed; otherwise, the conditions of S2 are re-checked by offsetting 1 byte.

[0070] S4: Starting from the position 2 bytes offset from the suspected audio frame entry point, continue searching for the next suspected audio frame entry point according to the conditions in S2. After finding it, take the previous byte of the next suspected audio frame entry point as the end of the previous suspected audio frame and calculate the frame size of the previous suspected audio frame.

[0071] S5: If any MPEG-4 box tag (such as STSZ, STCO, etc.) is encountered while searching for the next audio frame, it means that all audio frame data has been searched. Therefore, the first 4 bytes of the box tag are taken as the end of the previous suspected audio frame, and the search for suspected audio frames stops. If the end of the file is encountered while searching for the next audio frame (i.e., when t=n), then the end of the file is the end of this audio frame, and the search for suspected audio frames stops.

[0072] S6: Convert the saved audio frames into PCM format data using ffmpeg's API and save them in the temp.pcm file.

[0073] S7: Use the ffmpeg.exe tool to convert the temp.pcm file into a "original name .m4a" file, and you will get a repaired and playable m4a file.

[0074] This invention finds the legal feature values ​​that match the m4a audio frame by matching byte by byte. The first byte of the legal byte segment is used as the audio frame entry point. Then, the byte before the next audio frame entry point is used as the end of the previous audio frame to obtain a complete suspected audio frame. The suspected audio frame is then checked for format conversion. Successful audio frames are saved. Finally, all audio frames are encapsulated in MPEG-4 to obtain a repaired m4a file.

[0075] See Figure 2 The second aspect of the present invention provides a system for repairing m4a audio files, the system comprising:

[0076] The m4a audio file data acquisition module 10 is used to obtain the m4a audio file data to be repaired by using memory mapping.

[0077] The byte extraction module 20 is used to extract 2 bytes of data from the m4a audio file data each time, in the order from the beginning to the end, for subsequent legality detection.

[0078] The byte judgment module 30 is used to determine whether the data of each detection site in the two bytes of data is its corresponding feature data;

[0079] The suspected audio frame entry acquisition module 40 is used to take the first byte of the two bytes of data as the suspected audio frame entry if the data of each detection site in the two bytes of data is the corresponding feature data.

[0080] The suspected audio frame entry aggregation module 50 is used to obtain all the suspected audio frame entries in the m4a audio file data;

[0081] The suspected audio frame data acquisition module 60 is used to, for any suspected audio frame entry, take the current suspected audio frame entry as the start of each suspected audio frame segment and the byte before the next suspected audio frame entry as the end of each suspected audio frame segment, and obtain all suspected audio frame data in the m4a audio file data.

[0082] The format conversion module 70 is used to convert all the suspected audio frame data into PCM data format and then into M4A data format to obtain the repaired M4A audio file.

[0083] In an optional embodiment of the second aspect of the present invention, the byte truncation module includes:

[0084] A window building unit, used to build a sliding window with a length of 2 bytes;

[0085] The first byte extraction unit is used to extract two bytes of data from the beginning of the m4a audio file data through the sliding window for legality detection.

[0086] The window movement determination unit is used to determine whether the suspected audio frame entry exists in the current two bytes of data when intercepting the next two bytes of data; if the suspected audio frame entry exists in the current two bytes of data, the sliding window is controlled to shift backward by two bytes to intercept the next two bytes of data; if the suspected audio frame entry does not exist in the current two bytes of data, the sliding window is controlled to shift backward by one byte to intercept the next two bytes of data.

[0087] In an optional embodiment of the second aspect of the present invention, the byte determination module includes:

[0088] The syntax element data determination unit determines whether the data in the first 3 bits of the 2 bytes of data is syntax element data;

[0089] The tag data determination unit is used to determine whether the data in bits 4-7 of the two bytes of data is tag data;

[0090] The window number data judgment unit is used to determine whether the data in the 8th bit of the 2 bytes of data is window number data;

[0091] A window sequence data determination unit is used to determine whether the data in the 10th and 11th bits of the two bytes of data is window sequence data;

[0092] The window shape data determination unit is used to determine whether the 12th bit of the two bytes of data is window shape data.

[0093] In an optional embodiment of the second aspect of the present invention, obtaining the m4a audio file data to be repaired by using memory mapping also includes obtaining the total number of bytes of the m4a audio file data;

[0094] The process of extracting 2 bytes of data from the m4a audio file each time for subsequent legality checks also includes recording the number of bytes that have been checked in the m4a audio file data.

[0095] In an optional embodiment of the second aspect of the present invention, the m4a audio file repair system further includes:

[0096] The termination judgment module is used to further determine whether any box tag of the m4a audio file exists in the two bytes of data if the data of each detection site in the two bytes of data is not its corresponding feature data.

[0097] And if any box tag of the m4a audio file exists in the two bytes of data, then the detection of the m4a audio file data is determined to be over, and the extraction of two bytes of data from the m4a audio file data for legality detection is terminated;

[0098] And the position of the first box tag in the two bytes of data is determined by reversing four bytes to mark the end of the last suspected audio frame.

[0099] In an optional embodiment of the second aspect of the present invention, the end judgment module is further configured to determine whether the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data before performing the next legality check on the two bytes of data extracted from the m4a audio file data if the box tag is not present in the two bytes of data.

[0100] And if the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data, then the extraction of 2 bytes from the m4a audio file data for legality detection is terminated, and the end of the m4a audio file data is taken as the end of the last suspected audio frame.

[0101] In an optional embodiment of the second aspect of the present invention, the format conversion module includes:

[0102] The PCM format conversion unit is used to convert all the suspected audio frame data into PCM format data using the API interface of the ffmpeg tool and save it in the temp.pcm file;

[0103] The m4a format conversion unit is used to convert the temp.pcm file into an m4a audio file using the API interface of the ffmpeg tool.

[0104] Figure 3This is a schematic diagram of a device for repairing m4a audio files according to an embodiment of the present invention. This device can vary significantly depending on its configuration or performance, and may include one or more processors 80 (central processing units, CPUs) (e.g., one or more processors) and memory 90, and one or more storage media 100 (e.g., one or more mass storage devices) for storing applications or data. The memory and storage media can be temporary or persistent storage. The program stored on the storage media may include one or more modules (not shown in the diagram), each module including a series of instruction operations on a device used to disable the Find My Phone function. Furthermore, the processor may be configured to communicate with the storage media and execute the series of instruction operations on the storage media on the device used to disable the Find My Phone function.

[0105] The m4a audio file repair device of the present invention may further include one or more power supplies 110, one or more wired or wireless network interfaces 120, one or more input / output interfaces 130, and / or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 3 The illustrated structure of the m4a audio file repair device does not constitute a specific limitation on the m4a audio file repair device of the present invention. It may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.

[0106] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the method for repairing the m4a audio file.

[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system, device, or unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0108] If the integrated unit is implemented as 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 technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0109] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for repairing m4a audio files, characterized in that, include: The data of the m4a audio file to be repaired is obtained using memory mapping. Following the order from the beginning to the end of the m4a audio file data, two bytes of data are extracted from the m4a audio file data each time for subsequent legality detection. The subsequent legality detection includes determining whether the data at each detection point in the two bytes of data is its corresponding feature data. If the data of each detection site in the two bytes of data is the corresponding feature data, then the first byte of the two bytes of data is taken as the suspected audio frame entry point; Obtain all the suspected audio frame entries in the m4a audio file data; For any of the suspected audio frame entries, the current suspected audio frame entry is taken as the start of each suspected audio frame segment, and the byte preceding the next suspected audio frame entry is taken as the end of each suspected audio frame segment, thereby obtaining all the suspected audio frame data in the m4a audio file data. All the suspected audio frame data are first converted into PCM data format and then into M4A data format to obtain the repaired M4A audio file; The step of extracting 2 bytes of data from the m4a audio file data each time for subsequent legality checks, in order from the beginning to the end of the m4a audio file data, includes: Construct a sliding window with a length of 2 bytes; Two bytes of data are initially extracted from the header of the m4a audio file using the sliding window for legality detection. When extracting the next two bytes of data, determine whether the suspected audio frame entry exists in the current two bytes of data; If the suspected audio frame entry exists in the current two bytes of data, then the sliding window is shifted backward by two bytes to capture the next two bytes of data; If the suspected audio frame entry is not present in the current two bytes of data, the sliding window is shifted backward by one byte to capture the next two bytes of data. The step of determining whether the data at each detection site in the two bytes of data is its corresponding feature data includes: Determine whether the data in bits 1-3 of the two bytes of data is syntax element data; Determine whether the data in bits 4-7 of the two bytes of data is tag data; Determine whether the 8th bit of the 2 bytes of data is the window number data; Determine whether the 10th and 11th bits of the two bytes of data are window sequence data; Determine whether the 12th bit of the two bytes of data is window shape data.

2. The method for repairing m4a audio files according to claim 1, characterized in that, The method of obtaining the m4a audio file data to be repaired using memory mapping also includes obtaining the total number of bytes of the m4a audio file data; The process of extracting 2 bytes of data from the m4a audio file each time for subsequent legality checks also includes recording the number of bytes that have been checked in the m4a audio file data.

3. The method for repairing m4a audio files according to claim 2, characterized in that, The step of determining whether the data at each detection site in the two bytes of data is its corresponding feature data also includes: If the data at each detection point in the two bytes of data is not its corresponding feature data, then it is further determined whether any box tag of the m4a audio file exists in the two bytes of data; If any box tag of the m4a audio file is present in the two bytes of data, the detection of the m4a audio file data is considered to be completed, and the extraction of two bytes of data from the m4a audio file data for legality detection is terminated. The position of the first box tag in the two bytes of data is determined by reversing the order by four bytes to determine the end of the last suspected audio frame.

4. The method for repairing m4a audio files according to claim 3, characterized in that, If the data at each detection point in the two bytes of data is not its corresponding feature data, then after further determining whether any box tag of the m4a audio file exists in the two bytes of data, the process further includes: If the box tag is not present in the two bytes of data, before performing the next extraction of two bytes from the m4a audio file data for legality detection, it is determined whether the number of bytes already detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data. If the number of bytes detected in the currently recorded m4a audio file data is equal to the total number of bytes in the m4a audio file data, then the extraction of 2 bytes from the m4a audio file data for legality detection is terminated, and the end of the m4a audio file data is taken as the end of the last suspected audio frame.

5. The method for repairing m4a audio files according to claim 1, characterized in that, The process involves first converting all the suspected audio frame data into PCM data format and then into M4A data format to obtain the repaired M4A audio file, which includes: All the suspected audio frame data were converted into PCM format data using the API interface of the ffmpeg tool and saved in the temp.pcm file; Then, use the API interface of the ffmpeg tool to convert the temp.pcm file into an m4a audio file.

6. A system for repairing m4a audio files, characterized in that, The m4a audio file repair system includes: The m4a audio file data acquisition module is used to obtain the m4a audio file data to be repaired using memory mapping. The byte extraction module is used to extract two bytes of data from the m4a audio file data each time in the order from the beginning to the end for subsequent legality detection. The subsequent legality detection includes determining whether the data at each detection point in the two bytes of data is its corresponding feature data. The byte judgment module is used to determine whether the data of each detection site in the two bytes of data is its corresponding feature data; The suspected audio frame entry acquisition module is used to take the first byte of the two bytes of data as the suspected audio frame entry if the data of each detection site in the two bytes of data is the corresponding feature data. The suspected audio frame entry aggregation module is used to obtain all the suspected audio frame entries in the m4a audio file data; The suspected audio frame data acquisition module is used to, for any suspected audio frame entry, take the current suspected audio frame entry as the start of each suspected audio frame segment and the byte before the next suspected audio frame entry as the end of each suspected audio frame segment, and obtain all suspected audio frame data in the m4a audio file data. The format conversion module is used to first convert all the suspected audio frame data into PCM data format and then into M4A data format to obtain the repaired M4A audio file; The byte truncation module includes: A window building unit, used to build a sliding window with a length of 2 bytes; The first byte extraction unit is used to extract two bytes of data from the beginning of the m4a audio file data through the sliding window for legality detection. The window movement determination unit is used to determine whether the suspected audio frame entry exists in the current two bytes of data when intercepting the next two bytes of data; if the suspected audio frame entry exists in the current two bytes of data, the sliding window is controlled to shift backward by two bytes to intercept the next two bytes of data; if the suspected audio frame entry does not exist in the current two bytes of data, the sliding window is controlled to shift backward by one byte to intercept the next two bytes of data. The byte determination module includes: The syntax element data determination unit determines whether the data in the first three bits of the two bytes of data is syntax element data. The tag data determination unit is used to determine whether the data in bits 4-7 of the 2 bytes of data is tag data; The window number data judgment unit is used to determine whether the data in the 8th bit of the 2 bytes of data is window number data; A window sequence data determination unit is used to determine whether the data in the 10th and 11th bits of the two bytes of data is window sequence data; The window shape data determination unit is used to determine whether the 12th bit of the two bytes of data is window shape data.

7. A device for repairing m4a audio files, characterized in that, The device for repairing m4a audio files includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor invokes the instructions in the memory to cause the m4a audio file repair device to perform the m4a audio file repair method as described in any one of claims 1-5.

8. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the method for repairing m4a audio files as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Method for restoring audio files of mobile phone

    CN105630633A

  • Repair method for MP4 corrupted file and storage medium

    CN108093299A