CN108093299A - MP4 damages the restorative procedure and storage medium of file - Google Patents

MP4 damages the restorative procedure and storage medium of file Download PDF

Info

Publication number
CN108093299A
CN108093299A CN201711404796.7A CN201711404796A CN108093299A CN 108093299 A CN108093299 A CN 108093299A CN 201711404796 A CN201711404796 A CN 201711404796A CN 108093299 A CN108093299 A CN 108093299A
Authority
CN
China
Prior art keywords
video
frame
file
box
audio frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201711404796.7A
Other languages
Chinese (zh)
Other versions
CN108093299B (en
Inventor
唐淮灿
范玮
吴少华
沈长达
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Meiya Pico Information Co Ltd
Original Assignee
Xiamen Meiya Pico Information Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Meiya Pico Information Co Ltd filed Critical Xiamen Meiya Pico Information Co Ltd
Priority to CN201711404796.7A priority Critical patent/CN108093299B/en
Publication of CN108093299A publication Critical patent/CN108093299A/en
Application granted granted Critical
Publication of CN108093299B publication Critical patent/CN108093299B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/85Assembly of content; Generation of multimedia applications
    • H04N21/854Content authoring
    • H04N21/85406Content authoring involving a specific file format, e.g. MP4 format
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/439Processing of audio elementary streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/81Monomedia components thereof
    • H04N21/8106Monomedia components thereof involving special audio data, e.g. different tracks for different languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

The invention discloses the restorative procedure and storage medium of a kind of MP4 damage files, method includes:It obtains with reference to video;Obtain the sequence parameter set with reference to video;According to the sequence parameter set, the slice header in damage file is decoded, obtains the frame number of type of strip and video frame;If the value of the type of strip is in default scope and frame number is continuous, it is legal video frame to judge the corresponding video frame of the slice header;Video frame legal in damage file is obtained, obtains sets of video frames;The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, obtains video and audio frame set;According to described with reference to video and the video and audio frame set, obtain repairing file.The present invention can integrally improve the repairing effect of MP4 damage files and repair supporting rate.

Description

MP4 damages the restorative procedure and storage medium of file
Technical field
The present invention relates to recovery technique field more particularly to the restorative procedures and storage medium of a kind of MP4 damage files.
Background technology
With the popularization of smart mobile phone and recorder device, video data is seen everywhere.Such as mobile phone, automobile data recorder, hold Method recorder etc. is all large batch of daily to produce video data, these video datas largely use MP4 encapsulation format.
MP4 full name MPEG-4Part 14, is a kind of common multimedia container formats, currently the majority smart mobile phone, nothing The video recording equipments such as man-machine, automobile data recorder are all using MP4 as video encapsulation form.MP4 is marked at " ISO/IEC 14496-14 " Defined in quasi- file, belong to a part of MPEG-4.MP4 encapsulation format is packaged form, existing data according to certain Form be packaged packing.MP4 data are encapsulated in units of box, and Fig. 1 forms figure for MP4 encapsulation format box.
Regrettably these valuable video datas meet with various accidents sometimes, and having plenty of equipment fault causes video to be recorded System is interrupted, and the video for recording out can not play, some be then by artificial deletion file, can be with although there is data to recover software Recover video data, but since MP4 video encapsulations form is higher to the integrity demands of file, the data recovered are sometimes It is not complete data, there are sub-fraction data to be capped, causes video damage that can not play, but be not covered with Data may just have key message, these incomplete videos can be repaiied by this time needing video recovery technique It is multiple, replay damage video.
There are the softwares that several moneys are repaired specifically for damage MP4 video files on internal and international.For damage MP4 Following scheme is usually taken in the reparation of video file:
There is provided one with reference to video (with reference to video invitation be the recording of same equipment can normal play video file) lead to It crosses and audio/video frames extraction is carried out to disk with reference to the information that video provides, then the audio/video frames extracted are sealed according to normal video Dress form is packaged into MP4.
But existing scheme has the following disadvantages:
1st, the reparation of partial video sound is not supported, it is low that audio repairs supporting rate.
2nd, partial video recovery effects are bad, although can play, picture has flower screen.
The content of the invention
The technical problems to be solved by the invention are:A kind of restorative procedure and storage medium of MP4 damages file are provided, it can Repairing effect and the audio reparation supporting rate for improving MP4 damage files are low.
In order to solve the above-mentioned technical problem, the technical solution adopted by the present invention is:A kind of reparation side of MP4 damages file Method, including:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains type of strip and video frame Frame number;
If the value of the type of strip is in default scope and frame number is continuous, the corresponding video of the slice header is judged Frame is legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, is obtained Video and audio frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
The invention further relates to a kind of computer readable storage mediums, are stored thereon with computer program, and described program is located Reason device realizes following steps when performing:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains type of strip and video frame Frame number;
If the value of the type of strip is in default scope and frame number is continuous, the corresponding video of the slice header is judged Frame is legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, is obtained Video and audio frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
The beneficial effects of the present invention are:It, can to the integrality of video frame and effectively by using defective frame recognizer Performance makes differentiation, by only obtaining legal video frame, so as to greatly improve video repairing effect, avoids existing after repairing The situation of Hua Ping;Interlocked differential data extracting method by video and audio, will two-by-two the frame between video frame as audio frame into Row obtains, and effectively the voice data in video can be repaired, and greatly improves audio repairing effect with repairing supporting rate.This hair It is bright integrally to improve the repairing effect of MP4 damage files and reparation supporting rate.
Description of the drawings
Fig. 1 is MP4 encapsulation format schematic diagrames;
Fig. 2 is the flow chart for the restorative procedure that a kind of MP4 of the present invention damages file;
Fig. 3 is the method flow diagram of the embodiment of the present invention one.
Specific embodiment
For the technology contents that the present invention will be described in detail, the objects and the effects, below in conjunction with embodiment and coordinate attached Figure is explained in detail.
The design of most critical of the present invention is:The completeness and efficiency of video frame is made using defective frame recognizer Differentiate;Differential data extracting method is interlocked using video and audio to carry out the extraction of audio frame.
Referring to Fig. 2, a kind of restorative procedure of MP4 damages file, including:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains type of strip and video frame Frame number;
If the value of the type of strip is in default scope and frame number is continuous, the corresponding video of the slice header is judged Frame is legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, is obtained Video and audio frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
As can be seen from the above description, the beneficial effects of the present invention are:Can integrally improve MP4 damage file repairing effect and Repair supporting rate.
Further, described " obtaining the sequence parameter set with reference to video " is specially:
The network abstraction layer unit that types value is 7 in the reference video is decoded, obtains sequence parameter set.
Seen from the above description, NAL TYPE are that 7 NAL unit is sequence parameter set.
Further, it is described " according to the sequence parameter set, the slice header in damage file to be decoded, obtains item The frame number of belt type and video frame " is specially:
Using the first character section damaged in file as current byte;
Obtain the byte data that the length using current byte as starting point is eight bytes;
It is decoded according to byte data described in the sequential parameter set pair;
If decoding failure, using next byte of current byte as current byte, the acquisition is continued to execute with current The step of byte is the byte data that the length of starting point is eight bytes;
If successfully decoded, using the byte data as slice header, obtained according to preceding four bytes of the slice header The corresponding video frame of the slice header, and the frame number of type of strip and video frame is obtained according to decoding result.
Further, it is described " if the value of the type of strip is in default scope and frame number is continuous, to judge the item Corresponding video frame is taken the lead as legal video frame " after, further comprise:
Using next byte of current byte as current byte, length of the acquisition using current byte as starting point is continued to execute The step of spending the byte data for eight bytes.
Seen from the above description, the slice header Slice for obtaining including video frame frame head is traveled through in file is damaged Header so as to get video frame according to the frame originating point information of video frame, and can obtain type of strip by parsing slice header The frame number frame_num of Slice type and video frame, for judging whether video frame is legal.
Further, described " according to described with reference to video and the video and audio frame set, obtaining repairing file " is specially:
It creates and repairs file;
If repairing file there are ftyp box, from described with reference to obtaining ftyp data in video, and by the ftyp numbers In the ftyp box that file is repaired according to write-in;
The total length of the video and audio frame in the video and audio frame set is calculated, and mdat box are obtained according to the total length Header information;
File is repaired into video and audio frame write-in in the header information of the mdat box and the video and audio frame set In mdat box;
Time scale is obtained in mvhd box from reference to video;
The single frames duration of video frame is obtained from reference to the stts box in video;
According to the totalframes of video frame in the single frames duration of the video frame and the video and audio frame set, obtain Duration;
The time scale and duration write-in are repaired in the mvhd box of file;
The length write-in of each video frame in the video and audio frame set is repaired to the stsz box that video frame is corresponded in file In;
The length write-in of each audio frame in the video and audio frame set is repaired to the stsz box that audio frame is corresponded in file In;
According to the size of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set and Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of mdat box In offset address;
According to offset address, each video frame and each audio frame are grouped respectively;
The offset address write-in of each video frame packet is repaired in the stco box that video frame is corresponded in file;
The offset address write-in of each audio frame packets is repaired in the stco box that audio frame is corresponded in file;
Grouping information is write in the stsc box for repairing file;
By type in video and audio frame set for can frame number of the video frame in sets of video frames of random read take frame write In the stss box for repairing file;
By with reference to video tkhd box, stsd box, the data in stts box are respectively written into and repair the tkhd of file In box, stsd box, stts box.
Seen from the above description, according to the format information of the video and audio frame with reference to video and coding/decoding information and from damage The video and audio frame extracted in file, establishment obtain repairing file.
The present invention also proposes a kind of computer readable storage medium, is stored thereon with computer program, described program is located Reason device realizes following steps when performing:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains type of strip and video frame Frame number;
If the value of the type of strip is in default scope and frame number is continuous, the corresponding video of the slice header is judged Frame is legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, is obtained Video and audio frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
Further, described " obtaining the sequence parameter set with reference to video " is specially:
The network abstraction layer unit that types value is 7 in the reference video is decoded, obtains sequence parameter set.
Further, it is described " according to the sequence parameter set, the slice header in damage file to be decoded, obtains item The frame number of belt type and video frame " is specially:
Using the first character section damaged in file as current byte;
Obtain the byte data that the length using current byte as starting point is eight bytes;
It is decoded according to byte data described in the sequential parameter set pair;
If decoding failure, using next byte of current byte as current byte, the acquisition is continued to execute with current The step of byte is the byte data that the length of starting point is eight bytes;
If successfully decoded, using the byte data as slice header, obtained according to preceding four bytes of the slice header The corresponding video frame of the slice header, and the frame number of type of strip and video frame is obtained according to decoding result.
Further, it is described " if the value of the type of strip is in default scope and frame number is continuous, to judge the item Corresponding video frame is taken the lead as legal video frame " after, further comprise:
Using next byte of current byte as current byte, length of the acquisition using current byte as starting point is continued to execute The step of spending the byte data for eight bytes.
Further, described " according to described with reference to video and the video and audio frame set, obtaining repairing file " is specially:
It creates and repairs file;
If repairing file there are ftyp box, from described with reference to obtaining ftyp data in video, and by the ftyp numbers In the ftyp box that file is repaired according to write-in;
The total length of the video and audio frame in the video and audio frame set is calculated, and mdat box are obtained according to the total length Header information;
File is repaired into video and audio frame write-in in the header information of the mdat box and the video and audio frame set In mdat box;
Time scale is obtained in mvhd box from reference to video;
The single frames duration of video frame is obtained from reference to the stts box in video;
According to the totalframes of video frame in the single frames duration of the video frame and the video and audio frame set, obtain Duration;
The time scale and duration write-in are repaired in the mvhd box of file;
The length write-in of each video frame in the video and audio frame set is repaired to the stsz box that video frame is corresponded in file In;
The length write-in of each audio frame in the video and audio frame set is repaired to the stsz box that audio frame is corresponded in file In;
According to the size of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set and Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of mdat box In offset address;
According to offset address, each video frame and each audio frame are grouped respectively;
The offset address write-in of each video frame packet is repaired in the stco box that video frame is corresponded in file;
The offset address write-in of each audio frame packets is repaired in the stco box that audio frame is corresponded in file;
Grouping information is write in the stsc box for repairing file;
By type in video and audio frame set for can frame number of the video frame in sets of video frames of random read take frame write In the stss box for repairing file;
By with reference to video tkhd box, stsd box, the data in stts box are respectively written into and repair the tkhd of file In box, stsd box, stts box.
Embodiment one
Fig. 3 is refer to, the embodiment of the present invention one is:A kind of restorative procedure of MP4 damages file, includes the following steps:
S1:It obtains with reference to video;Obtain that same equipment records can normal play video file.
S2:Obtain the sequence parameter set with reference to video;Specifically, it is 7 to decode types value in the reference video Network abstraction layer unit obtains sequence parameter set, that is, obtains the NAL unit that NAL TYPE are 7.
S3:Using n-th of the byte damaged in file as current byte;The initial value of n is 1.
S4:Judge whether n+8 is more than the total bytes of damage file, if so, represent that damage file has traveled through, video Frame, which has extracted, to be finished, and step S11 is performed, if it is not, then performing step S5.
S5:Obtain the byte data that the length using current byte as starting point is eight bytes;
S6:It is decoded according to byte data described in the sequential parameter set pair, i.e., the letter provided according to sequence parameter set Breath is decoded byte data, judges whether successfully decoded, if so, step S8 is performed, if it is not, then performing step S7.
S7:N=n+1 is made, performs step S3;
S8:The byte data is judged for slice header (Slice Header), according to preceding four bytes of the slice header The corresponding video frame of the slice header is obtained, and the frame of type of strip (slice_type) and video frame is obtained according to decoding result Number (frame_num).
Since a frame video image can be encoded to one or several bands (Slice), above-mentioned steps are i.e. in damage text Traversal finds the Slice of the frame head comprising video frame in part, due to the length of four byte representation video frame of frame head, Can corresponding video frame be got according to preceding four bytes of the Slice, then obtain the video frame from the Slice Slice_type and frame_num.
S9:Judge whether the video frame is legal video frame, if so, step S10 is performed, if it is not, then abandoning institute Video frame is stated, search damage file is then proceeded to, that is, performs step S7.Specifically, if the value of the slice_type is in 0-9 And frame number is continuous, then it is legal video frame to judge the corresponding video frame of the slice header.
Until signified frame number in the step continuously refers to current video frame, the frame number of the video frame in same period It is continuous and complete.
The frame_num of video frame is loop cycle, per second to have 30 videos by taking frame per second is 30 video as an example Frame, then frame_num loop cycles in 0-29, that is to say, that frame_num represents the video frame for the of the second (cycle) Frame_num+1 video frame.
Therefore, the signified frame number in the step continuously specifically refer to be in the same second with the video frame and frame number be less than The frame number of the video frame of the frame number of the video frame is the continuous complete and frame number of the video frame and the frame number of a upper video frame Continuously, that is to say, that if within the current frame number cycle, the frame number before the frame number be it is continuous complete, and the frame number with it is upper One frame number is also continuous, then it is assumed that frame number is continuous.If frame number is discontinuous, then it represents that has tomography.
For example, it is assumed that the frame_num for getting the frame of a certain second is followed successively by 0,1,2,3,5,6,7 ... 28,29, then can incite somebody to action The frame that frame_num is 5-29 all abandons.Discarding scope only limits the data in 1 second, and the frame of next second will rejudge it continuously Property.
S10:The legal video frame is added in sets of video frames;Search damage file is then proceeded to, that is, performs step Rapid S7.Further, in the step S7 returned herein, the total bytes of video frame legal described in n=n+ can be made, perform step S3, first character section that will be after the video frame can improve traversal speed, so as to improve remediation efficiency as current byte.
S11:The audio frame in damage file is obtained, obtains audio frame set;According to the storage rule of video and audio frame, usually To store an audio frame behind a key frame, audio frame and video frame are staggeredly stored, therefore will two-by-two be regarded in damage file Frame between frequency frame is obtained as audio frame, that is to say, that by all video frame extractions it is complete after, remaining data are sound Frequency evidence.Further, obtain audio frame to be afterwards decoded it, audio frame set is added in if successfully decoded, if decoding Failure then abandons.
S12:Audio frame in video frame in the sets of video frames and audio frame set is ranked up according to offset, Obtain video and audio frame set;For each elements A in sets of video frames VS and audio frame set ASiAnd Vi, comprising two categories Property, it is respectively list item offset ENTRYOFFSET and list item size ENTRYSIZE, wherein, list item offset ENTRYOFFSET is Compared with the offset of damage file initial address.
S13:According to described with reference to video and the video and audio frame set, obtain repairing file.
Specifically, first create and repair file;For ftyp box, if file is repaired there are ftyp box, from the ginseng It is write according to acquisition ftyp data in video, and by the ftyp data in the ftyp box for repairing file.
For mdat box, for storing video and audio frame;The header information of mdat box includes the length and " mdat of mdat Four characters of box " therefore, calculate the total length of the video and audio frame in the video and audio frame set, as the length of mdat, so It is the header information that can obtain mdat box plus " mdat box " four characters afterwards;Then the head of the mdat box is believed Video and audio frame write-in in breath and the video and audio frame set is repaired in the mdat box of file.
For the mvhd box in moov box, for resting period scale (timescale) and duration (duration), the value that duration divided by time scale obtain is the total duration of video, and unit is the second;Time scale can be with It is extracted in mvhd box from reference to video;And for duration, it first obtains and regards in the stts box from reference to video Then the totalframes of video frame in video and audio frame set is multiplied by the single frames duration, i.e., by the single frames duration of frequency frame The duration of video frame is can obtain, in the present embodiment, using the duration of video frame as the duration of video file;Most The time scale and duration write-in are repaired in the mvhd box of file afterwards.
For the tkhd box in moov box, emphasis update video resolution information, resolution ratio sets mistake that can cause Play flower screen.If directly obtaining resolution information from the tkhd box with reference to video using the resolution ratio with reference to video, And it writes in the tkhd box for repairing file.If being reset to resolution ratio, it is preferable that be arranged to 1080P or 720P。
For the stsd box in moov box, which includes decoding necessary information, and decoding can errors excepted be caused to be lost It loses, is write from reference to video dubbing.
For the stts box in moov box, for storing video and audio frame duration, write from reference to video dubbing.
For the stsz box in moov box, for storing the length of video and audio frame;In moov box, there are two Stsz box, the length for being used to store video frame, another is used to store the length of audio frame;Therefore, described sound will be regarded The length write-in of each video frame is repaired in the stsz box that video frame is corresponded in file in frequency frame set;By the video and audio frame collection The length write-in of each audio frame is repaired in the stsz box that audio frame is corresponded in file in conjunction.
For the stco box in moov box, for storing the offset address of video and audio frame, in moov box, exist Two stco box, an offset address for being used to store video frame, another is used to store the offset address of audio frame.
According to the size of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set and Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of mdat box In offset address;Specific calculating process is as follows:
Assuming that HS={ H1,H2,H3,....,HnRepresent video and audio frame set, i.e. HS=AS ∪ US, wherein HnIt presses ENTRYOFFSET is ranked up from small to large;Assuming that CS={ C1,C2,C3,....,CnRepresent to repair video and audio frame in file Set, each Elements CiENTRYOFFSET and list item size ENTRYSIZE is deviated comprising list item;Assuming that C1o……CnoIt represents The ENTRYOFFSET of element, C in set CS1s……CnsRepresent that the ENTRYSIZE of element in set CS, i.e. subscript o are represented ENTRYOFFSET, subscript s represent ENTRYSIZE;Assuming that the size of ftyp box is F, the head size of mdat box is M;Knot Close assumed above, the calculation formula for obtaining video and audio vertical shift address is as follows:
Further, the calculation formula of the length of video and audio frame is as follows:
Cns=Hns
After the offset address of each video frame and each audio frame is calculated, it is grouped further according to offset address, it will be inclined It moves the continuous video frame in address and is divided into one group, the continuous audio frame of offset address is divided into one group;Then by each video frame packet Offset address write-in repair and correspond in file in the stco box of video frame, the offset address of each audio frame packets is write and is repaiied In the stco box that audio frame is corresponded in multiple file.
For the stsc box in moov box, then above-mentioned grouping information write-in is repaired in the stsc box of file;
For the stss box in moov box, the type (NAL TYPE) of video frame in video and audio frame set is obtained, such as Fruit video frame be can random read take frame, then by the video frame in sets of video frames frame number write-in repair file stss In box.
The present embodiment can make differentiation by using defective frame recognizer to the completeness and efficiency of video frame, By only obtaining legal video frame, so as to greatly improve video repairing effect, avoid the presence of flower screen after repairing;It is logical It crosses video and audio to interlock differential data extracting method, frame that will be two-by-two between video frame is obtained as audio frame, can be effective Voice data in video is repaired, greatly improves audio repairing effect with repairing supporting rate.
Embodiment two
The present embodiment is a kind of computer readable storage medium of corresponding above-described embodiment, is stored thereon with computer journey Sequence realizes following steps when described program is executed by processor:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains type of strip and video frame Frame number;
If the value of the type of strip is in default scope and frame number is continuous, the corresponding video of the slice header is judged Frame is legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, is obtained Video and audio frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
Further, described " obtaining the sequence parameter set with reference to video " is specially:
The network abstraction layer unit that types value is 7 in the reference video is decoded, obtains sequence parameter set.
Further, it is described " according to the sequence parameter set, the slice header in damage file to be decoded, obtains item The frame number of belt type and video frame " is specially:
Using the first character section damaged in file as current byte;
Obtain the byte data that the length using current byte as starting point is eight bytes;
It is decoded according to byte data described in the sequential parameter set pair;
If decoding failure, using next byte of current byte as current byte, the acquisition is continued to execute with current The step of byte is the byte data that the length of starting point is eight bytes;
If successfully decoded, using the byte data as slice header, obtained according to preceding four bytes of the slice header The corresponding video frame of the slice header, and the frame number of type of strip and video frame is obtained according to decoding result.
Further, it is described " if the value of the type of strip is in default scope and frame number is continuous, to judge the item Corresponding video frame is taken the lead as legal video frame " after, further comprise:
Using next byte of current byte as current byte, length of the acquisition using current byte as starting point is continued to execute The step of spending the byte data for eight bytes.
Further, described " according to described with reference to video and the video and audio frame set, obtaining repairing file " is specially:
It creates and repairs file;
If repairing file there are ftyp box, from described with reference to obtaining ftyp data in video, and by the ftyp numbers In the ftyp box that file is repaired according to write-in;
The total length of the video and audio frame in the video and audio frame set is calculated, and mdat box are obtained according to the total length Header information;
File is repaired into video and audio frame write-in in the header information of the mdat box and the video and audio frame set In mdat box;
Time scale is obtained in mvhd box from reference to video;
The single frames duration of video frame is obtained from reference to the stts box in video;
According to the totalframes of video frame in the single frames duration of the video frame and the video and audio frame set, obtain Duration;
The time scale and duration write-in are repaired in the mvhd box of file;
The length write-in of each video frame in the video and audio frame set is repaired to the stsz box that video frame is corresponded in file In;
The length write-in of each audio frame in the video and audio frame set is repaired to the stsz box that audio frame is corresponded in file In;
According to the size of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set and Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of mdat box In offset address;
According to offset address, each video frame and each audio frame are grouped respectively;
The offset address write-in of each video frame packet is repaired in the stco box that video frame is corresponded in file;
The offset address write-in of each audio frame packets is repaired in the stco box that audio frame is corresponded in file;
Grouping information is write in the stsc box for repairing file;
By type in video and audio frame set for can frame number of the video frame in sets of video frames of random read take frame write In the stss box for repairing file;
By with reference to video tkhd box, stsd box, the data in stts box are respectively written into and repair the tkhd of file In box, stsd box, stts box.
In conclusion the restorative procedure and storage medium of a kind of MP4 damages file provided by the invention, by using defect Frame recognizer can make differentiation to the completeness and efficiency of video frame, by only obtaining legal video frame, so as to big Width improves video repairing effect, avoids the presence of flower screen after repairing;Interlocked differential data extracting method by video and audio, Frame that will be two-by-two between video frame is obtained as audio frame, effectively the voice data in video can be repaired, greatly Width improves audio repairing effect with repairing supporting rate.The present invention can integrally improve the repairing effect of MP4 damage files and repair branch Holdup.
The foregoing is merely the embodiment of the present invention, are not intended to limit the scope of the invention, every to utilize this hair The equivalents that bright specification and accompanying drawing content are made directly or indirectly are used in relevant technical field, similarly include In the scope of patent protection of the present invention.

Claims (10)

1. a kind of restorative procedure of MP4 damages file, which is characterized in that including:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains the frame of type of strip and video frame Number;
If the value of the type of strip is in default scope and frame number is continuous, judge that the corresponding video frame of the slice header is Legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, obtains regarding sound Frequency frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
2. the restorative procedure of MP4 damages file according to claim 1, which is characterized in that described " to obtain the reference to regard The sequence parameter set of frequency " is specially:
The network abstraction layer unit that types value is 7 in the reference video is decoded, obtains sequence parameter set.
3. the restorative procedure of MP4 damages file according to claim 1, which is characterized in that described " to be joined according to the sequence Manifold is decoded the slice header in damage file, obtains the frame number of type of strip and video frame " be specially:
Using the first character section damaged in file as current byte;
Obtain the byte data that the length using current byte as starting point is eight bytes;
It is decoded according to byte data described in the sequential parameter set pair;
If decoding failure, using next byte of current byte as current byte, the acquisition is continued to execute with current byte The step of length for starting point is the byte data of eight bytes;
If successfully decoded, using the byte data as slice header, according to obtaining preceding four bytes of the slice header The corresponding video frame of slice header, and the frame number of type of strip and video frame is obtained according to decoding result.
4. the restorative procedure of MP4 damages file according to claim 3, which is characterized in that described " if the type of strip Value is in default scope and frame number is continuous, then judge the corresponding video frame of the slice header be legal video frame " after, Further comprise:
Using next byte of current byte as current byte, continuing to execute length of the acquisition using current byte as starting point is The step of byte data of eight bytes.
5. the restorative procedure of MP4 damages file according to claim 1, which is characterized in that described " to be regarded according to the reference Frequency and the video and audio frame set obtain repairing file " be specially:
It creates and repairs file;
If repairing file there are ftyp box, from described with reference to acquisition ftyp data in video, and the ftyp data are write In the ftyp box for entering to repair file;
The total length of the video and audio frame in the video and audio frame set is calculated, and the head of mdat box is obtained according to the total length Portion's information;
Video and audio frame write-in in the header information of the mdat box and the video and audio frame set is repaired to the mdat of file In box;
Time scale is obtained in mvhd box from reference to video;
The single frames duration of video frame is obtained from reference to the stts box in video;
According to the totalframes of video frame in the single frames duration of the video frame and the video and audio frame set, continued Duration;
The time scale and duration write-in are repaired in the mvhd box of file;
The length write-in of each video frame in the video and audio frame set is repaired in the stsz box that video frame is corresponded in file;
The length write-in of each audio frame in the video and audio frame set is repaired in the stsz box that audio frame is corresponded in file;
According to the size and mdat of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of box Offset address;
According to offset address, each video frame and each audio frame are grouped respectively;
The offset address write-in of each video frame packet is repaired in the stco box that video frame is corresponded in file;
The offset address write-in of each audio frame packets is repaired in the stco box that audio frame is corresponded in file;
Grouping information is write in the stsc box for repairing file;
By type in video and audio frame set for can frame number of the video frame in sets of video frames of random read take frame write and repair In the stss box of file;
By with reference to video tkhd box, stsd box, the data in stts box be respectively written into repair file tkhd box, In stsd box, stts box.
6. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that described program is by processor Following steps are realized during execution:
It obtains with reference to video;
Obtain the sequence parameter set with reference to video;
According to the sequence parameter set, the slice header in damage file is decoded, obtains the frame of type of strip and video frame Number;
If the value of the type of strip is in default scope and frame number is continuous, judge that the corresponding video frame of the slice header is Legal video frame;
Video frame legal in damage file is obtained, obtains sets of video frames;
The frame between video frame two-by-two is obtained in damage file, obtains audio frame set;
Audio frame in video frame in the sets of video frames and audio frame set according to offset is ranked up, obtains regarding sound Frequency frame set;
According to described with reference to video and the video and audio frame set, obtain repairing file.
7. computer readable storage medium according to claim 6, which is characterized in that described " to obtain described with reference to video Sequence parameter set " be specially:
The network abstraction layer unit that types value is 7 in the reference video is decoded, obtains sequence parameter set.
8. computer readable storage medium according to claim 6, which is characterized in that described " according to the sequential parameter Collection is decoded the slice header in damage file, obtains the frame number of type of strip and video frame " be specially:
Using the first character section damaged in file as current byte;
Obtain the byte data that the length using current byte as starting point is eight bytes;
It is decoded according to byte data described in the sequential parameter set pair;
If decoding failure, using next byte of current byte as current byte, the acquisition is continued to execute with current byte The step of length for starting point is the byte data of eight bytes;
If successfully decoded, using the byte data as slice header, according to obtaining preceding four bytes of the slice header The corresponding video frame of slice header, and the frame number of type of strip and video frame is obtained according to decoding result.
9. computer readable storage medium according to claim 8, which is characterized in that described " if the type of strip Value is in default scope and frame number is continuous, then it is legal video frame to judge the corresponding video frame of the slice header " after, into One step includes:
Using next byte of current byte as current byte, continuing to execute length of the acquisition using current byte as starting point is The step of byte data of eight bytes.
10. computer readable storage medium according to claim 6, which is characterized in that described " according to described with reference to video With the video and audio frame set, obtain repairing file " be specially:
It creates and repairs file;
If repairing file there are ftyp box, from described with reference to acquisition ftyp data in video, and the ftyp data are write In the ftyp box for entering to repair file;
The total length of the video and audio frame in the video and audio frame set is calculated, and the head of mdat box is obtained according to the total length Portion's information;
Video and audio frame write-in in the header information of the mdat box and the video and audio frame set is repaired to the mdat of file In box;
Time scale is obtained in mvhd box from reference to video;
The single frames duration of video frame is obtained from reference to the stts box in video;
According to the totalframes of video frame in the single frames duration of the video frame and the video and audio frame set, continued Duration;
The time scale and duration write-in are repaired in the mvhd box of file;
The length write-in of each video frame in the video and audio frame set is repaired in the stsz box that video frame is corresponded in file;
The length write-in of each audio frame in the video and audio frame set is repaired in the stsz box that audio frame is corresponded in file;
According to the size and mdat of the offset of each video frame and each audio frame and ftyp box in the video and audio frame set Each video frame and each audio frame is calculated in the video and audio frame set in the reparation file in the head size of box Offset address;
According to offset address, each video frame and each audio frame are grouped respectively;
The offset address write-in of each video frame packet is repaired in the stco box that video frame is corresponded in file;
The offset address write-in of each audio frame packets is repaired in the stco box that audio frame is corresponded in file;
Grouping information is write in the stsc box for repairing file;
By type in video and audio frame set for can frame number of the video frame in sets of video frames of random read take frame write and repair In the stss box of file;
By with reference to video tkhd box, stsd box, the data in stts box be respectively written into repair file tkhd box, In stsd box, stts box.
CN201711404796.7A 2017-12-22 2017-12-22 Method for repairing damaged MP4 file and storage medium Active CN108093299B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711404796.7A CN108093299B (en) 2017-12-22 2017-12-22 Method for repairing damaged MP4 file and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711404796.7A CN108093299B (en) 2017-12-22 2017-12-22 Method for repairing damaged MP4 file and storage medium

Publications (2)

Publication Number Publication Date
CN108093299A true CN108093299A (en) 2018-05-29
CN108093299B CN108093299B (en) 2020-08-04

Family

ID=62178602

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711404796.7A Active CN108093299B (en) 2017-12-22 2017-12-22 Method for repairing damaged MP4 file and storage medium

Country Status (1)

Country Link
CN (1) CN108093299B (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108961193A (en) * 2018-08-10 2018-12-07 厦门市美亚柏科信息股份有限公司 A kind of image repair method, device and storage medium
CN110662084A (en) * 2019-10-15 2020-01-07 北京齐尔布莱特科技有限公司 MP4 file stream live broadcasting method, mobile terminal and storage medium
CN110740391A (en) * 2019-10-31 2020-01-31 四川效率源信息安全技术股份有限公司 method for repairing MP4 damaged files
CN110781037A (en) * 2020-01-02 2020-02-11 成都易我科技开发有限责任公司 Method and system for recovering video file in storage medium and readable storage medium
CN111063380A (en) * 2020-01-02 2020-04-24 南京美乐威电子科技有限公司 MP4 file generation method, processing device, equipment and storage medium
WO2020192012A1 (en) * 2019-03-28 2020-10-01 腾讯音乐娱乐科技(深圳)有限公司 Data processing method and apparatus, and storage medium
CN112732180A (en) * 2020-12-29 2021-04-30 哈尔滨海能达科技有限公司 Information processing method, processing device, electronic equipment and storage medium
CN113362233A (en) * 2020-03-03 2021-09-07 浙江宇视科技有限公司 Picture processing method, device, equipment, system and storage medium
CN113382189A (en) * 2021-05-24 2021-09-10 深圳市爱为物联科技有限公司 Electronic equipment damaged file repairing method
CN113507625A (en) * 2021-06-22 2021-10-15 西安理工大学 Self-adaptive video restoration method
CN113660442A (en) * 2021-08-31 2021-11-16 广州盈可视电子科技有限公司 Video repairing method and device, electronic equipment and readable medium
CN114007112A (en) * 2021-11-30 2022-02-01 四川效率源信息安全技术股份有限公司 Method for repairing mdat box data error in MP4 video file
CN114257840A (en) * 2021-11-26 2022-03-29 厦门市美亚柏科信息股份有限公司 Method and system for repairing Matroska format video
CN114446330A (en) * 2021-12-30 2022-05-06 厦门市美亚柏科信息股份有限公司 Method, device and storage medium for repairing MP4 file
CN117544738A (en) * 2023-11-10 2024-02-09 深圳麦风科技有限公司 Method, device and storage medium for repairing playing of RSV file

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020152440A1 (en) * 2000-10-27 2002-10-17 Ilan Yona Apparatus and method for improving the quality of video communication over a packet-based network
US20050089102A1 (en) * 2002-02-21 2005-04-28 Roberto Alvarez Arevalo Video processing
CN103327362A (en) * 2013-05-24 2013-09-25 武汉东信同邦信息技术有限公司 High reliability streaming medium memory system and method thereof
CN104598328A (en) * 2015-02-04 2015-05-06 南车株洲电力机车研究所有限公司 File system repair method, device and system
CN104768025A (en) * 2015-04-02 2015-07-08 无锡天脉聚源传媒科技有限公司 Method and device for repairing bad frames in video
CN105426262A (en) * 2014-09-11 2016-03-23 哈曼国际工业有限公司 Methods And Systems For Avb Networks
CN107273244A (en) * 2017-06-08 2017-10-20 深圳市普天宜通技术股份有限公司 The fault tolerant control method and system of a kind of media file storage

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020152440A1 (en) * 2000-10-27 2002-10-17 Ilan Yona Apparatus and method for improving the quality of video communication over a packet-based network
US20050089102A1 (en) * 2002-02-21 2005-04-28 Roberto Alvarez Arevalo Video processing
CN103327362A (en) * 2013-05-24 2013-09-25 武汉东信同邦信息技术有限公司 High reliability streaming medium memory system and method thereof
CN105426262A (en) * 2014-09-11 2016-03-23 哈曼国际工业有限公司 Methods And Systems For Avb Networks
CN104598328A (en) * 2015-02-04 2015-05-06 南车株洲电力机车研究所有限公司 File system repair method, device and system
CN104768025A (en) * 2015-04-02 2015-07-08 无锡天脉聚源传媒科技有限公司 Method and device for repairing bad frames in video
CN107273244A (en) * 2017-06-08 2017-10-20 深圳市普天宜通技术股份有限公司 The fault tolerant control method and system of a kind of media file storage

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108961193A (en) * 2018-08-10 2018-12-07 厦门市美亚柏科信息股份有限公司 A kind of image repair method, device and storage medium
CN108961193B (en) * 2018-08-10 2021-04-02 厦门市美亚柏科信息股份有限公司 Image restoration method, device and storage medium
WO2020192012A1 (en) * 2019-03-28 2020-10-01 腾讯音乐娱乐科技(深圳)有限公司 Data processing method and apparatus, and storage medium
CN110662084B (en) * 2019-10-15 2021-07-09 北京齐尔布莱特科技有限公司 MP4 file stream live broadcasting method, mobile terminal and storage medium
CN110662084A (en) * 2019-10-15 2020-01-07 北京齐尔布莱特科技有限公司 MP4 file stream live broadcasting method, mobile terminal and storage medium
CN110740391A (en) * 2019-10-31 2020-01-31 四川效率源信息安全技术股份有限公司 method for repairing MP4 damaged files
CN110740391B (en) * 2019-10-31 2021-10-26 四川效率源信息安全技术股份有限公司 Method for repairing MP4 damaged file
CN110781037A (en) * 2020-01-02 2020-02-11 成都易我科技开发有限责任公司 Method and system for recovering video file in storage medium and readable storage medium
CN111063380A (en) * 2020-01-02 2020-04-24 南京美乐威电子科技有限公司 MP4 file generation method, processing device, equipment and storage medium
CN113362233A (en) * 2020-03-03 2021-09-07 浙江宇视科技有限公司 Picture processing method, device, equipment, system and storage medium
CN113362233B (en) * 2020-03-03 2023-08-29 浙江宇视科技有限公司 Picture processing method, device, equipment, system and storage medium
CN112732180A (en) * 2020-12-29 2021-04-30 哈尔滨海能达科技有限公司 Information processing method, processing device, electronic equipment and storage medium
CN112732180B (en) * 2020-12-29 2023-04-14 哈尔滨海能达科技有限公司 Information processing method, processing device, electronic equipment and storage medium
CN113382189A (en) * 2021-05-24 2021-09-10 深圳市爱为物联科技有限公司 Electronic equipment damaged file repairing method
CN113507625A (en) * 2021-06-22 2021-10-15 西安理工大学 Self-adaptive video restoration method
CN113660442A (en) * 2021-08-31 2021-11-16 广州盈可视电子科技有限公司 Video repairing method and device, electronic equipment and readable medium
CN113660442B (en) * 2021-08-31 2024-03-19 广州盈可视电子科技有限公司 Video restoration method and device, electronic equipment and readable medium
CN114257840A (en) * 2021-11-26 2022-03-29 厦门市美亚柏科信息股份有限公司 Method and system for repairing Matroska format video
CN114257840B (en) * 2021-11-26 2024-03-19 厦门市美亚柏科信息股份有限公司 Repairing method and system for Matroska format video
CN114007112A (en) * 2021-11-30 2022-02-01 四川效率源信息安全技术股份有限公司 Method for repairing mdat box data error in MP4 video file
CN114446330A (en) * 2021-12-30 2022-05-06 厦门市美亚柏科信息股份有限公司 Method, device and storage medium for repairing MP4 file
CN114446330B (en) * 2021-12-30 2024-04-16 厦门市美亚柏科信息股份有限公司 Method, device and storage medium for repairing MP4 file
CN117544738A (en) * 2023-11-10 2024-02-09 深圳麦风科技有限公司 Method, device and storage medium for repairing playing of RSV file

Also Published As

Publication number Publication date
CN108093299B (en) 2020-08-04

Similar Documents

Publication Publication Date Title
CN108093299A (en) MP4 damages the restorative procedure and storage medium of file
CN104063447B (en) A kind of monitor video Ile repair method
CN109618235A (en) Generating device and method, processing equipment and method and storage medium
CN108322808A (en) A kind of video record processing method and processing device, computer installation, storage medium
CN111063376A (en) Method, terminal equipment and storage medium for audio and video synchronization in MP4 repairing
CN104602105B (en) The player method and user equipment of video file
CN102026017B (en) Efficient test method for video decoding
CN110740391B (en) Method for repairing MP4 damaged file
CN104837031B (en) A kind of method of high-speed adaptive extraction key frame of video
CN107690074A (en) Video coding and restoring method, audio/video player system and relevant device
CA2701311C (en) Multi dvr video packaging for incident forensics
CN102970556B (en) 3DV (Three-Dimensional Video) encapsulation and playing method and 3DV encapsulating and playing system
CN101937695B (en) Rich media business example playing method and file player
CN104919812B (en) Handle the apparatus and method of video
CN108985244A (en) A kind of television program type recognition methods and device
CN110781037B (en) Method and system for recovering video file in storage medium and readable storage medium
CN102930040A (en) Media multi-dimensional content expressing method
CN109101832A (en) A kind of testament electronic data management method based on block chain
CN100544413C (en) Video processing circuits, multimedia play system and decoding sub-image data method thereof
CN113660442B (en) Video restoration method and device, electronic equipment and readable medium
CN102169706B (en) Method and device for storing and playing YUV file
CN106534748A (en) Media file recording and playing method and terminal
CN105303050B (en) The fault message storage method and system of a kind of Medical Devices
JP2012049956A (en) Semiconductor integrated circuit loadable to drive recorder and method of operating the same
CN112929686A (en) Method and device for playing back recorded video in real time on line

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant