CN113660442B - Video restoration method and device, electronic equipment and readable medium - Google Patents

Video restoration method and device, electronic equipment and readable medium Download PDF

Info

Publication number
CN113660442B
CN113660442B CN202111023494.1A CN202111023494A CN113660442B CN 113660442 B CN113660442 B CN 113660442B CN 202111023494 A CN202111023494 A CN 202111023494A CN 113660442 B CN113660442 B CN 113660442B
Authority
CN
China
Prior art keywords
video
data frame
audio data
information
video file
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.)
Active
Application number
CN202111023494.1A
Other languages
Chinese (zh)
Other versions
CN113660442A (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.)
Guangzhou Ncast Electronics Co ltd
Original Assignee
Guangzhou Ncast Electronics 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 Guangzhou Ncast Electronics Co ltd filed Critical Guangzhou Ncast Electronics Co ltd
Priority to CN202111023494.1A priority Critical patent/CN113660442B/en
Publication of CN113660442A publication Critical patent/CN113660442A/en
Application granted granted Critical
Publication of CN113660442B publication Critical patent/CN113660442B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • H04N5/91Television signal processing therefor
    • H04N5/93Regeneration of the television signal or of selected parts thereof
    • H04N5/931Regeneration of the television signal or of selected parts thereof for restoring the level of the reproduced signal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • H04N5/91Television signal processing therefor
    • H04N5/93Regeneration of the television signal or of selected parts thereof

Abstract

The embodiment of the invention provides a video restoration method, a video restoration device, electronic equipment and a computer readable storage medium, comprising the following steps: obtaining a damaged video file and a reference video file for repairing the damaged video file, extracting identification information and first coding and decoding information from the reference video file, wherein the identification information is used for representing the type of the video file; extracting audio data frames and video data frames from the corrupted video file; encoding the audio data frame and the video data frame according to the first encoding and decoding information; and the acquired second coding and decoding information of the encoded audio data frame and the video data frame encapsulates the identification information, the encoded audio data frame, the video data frame and the second coding and decoding information into a new video file. By applying the embodiment of the invention, the audio data frame and the video data frame of the damaged file are encoded by referring to the first encoding and decoding information in the video file, and are packaged into a new video file, so that the damaged video file is repaired.

Description

Video restoration method and device, electronic equipment and readable medium
Technical Field
The present invention relates to the field of data repair technology, and in particular, to a video repair method, a video repair apparatus, an electronic device, and a computer readable medium.
Background
MP4 is a common multimedia container format, and is realized based on MPEG-4part 6 or related specifications, and at present, video equipment such as monitoring equipment, a vehicle event data recorder, a smart phone and the like widely apply MP4 as a video packaging format.
In the process of recording MP4 files, uncontrollable factors such as power failure of video equipment are encountered, so that the MP4 files being recorded are not normally stopped, and the recorded MP4 files cannot be normally played.
Disclosure of Invention
The embodiment of the invention provides a video repairing method, a video repairing device, electronic equipment and a computer readable storage medium, which are used for solving the problem that recorded MP4 files cannot be played normally due to the fact that recorded MP4 files are not stopped normally due to uncontrollable factors such as power-off of video equipment.
The embodiment of the invention discloses a video restoration method, which comprises the following steps:
obtaining a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters;
extracting identification information and first codec information from the reference video file; wherein the identification information is used for representing the type of the video file;
extracting an audio data frame and a video data frame from the damaged video file;
encoding the audio data frame and the video data frame according to the first encoding and decoding information;
the obtained second coding and decoding information of the audio data frame and the video data frame after coding;
and packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file.
Optionally, the encoding the audio data frame and the video data frame according to the first codec information includes:
and respectively storing the audio data frame and the video data frame in the audio data block and the video data block according to the first coding and decoding information.
Optionally, the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the acquired second codec information of the encoded audio data frame and the video data frame includes:
acquiring offset of the audio data frame and the video data relative to the initial position of the new video file, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
determining duration information of the new video file according to the total frame number of the audio data frames and the audio sampling rate or the total frame number of the video data frames and the video frame rate;
generating the second encoding and decoding information according to the first encoding and decoding information, byte sizes and offset of the audio data frame and the video data, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block, offset of the audio data block and the video data block, and key frames in the audio data frame and the video data frame, and the duration information of the new video file.
Optionally, the determining the duration information of the new video file according to the total frame number of the audio data frames and the audio sampling rate, or the total frame number of the video data frames and the video frame rate includes:
determining duration information of each single audio data frame according to the audio sampling rate;
summing the time length information of each single audio data frame to obtain the time length information of the new video file; or,
determining duration information of each single video data frame according to the video frame rate;
and summing the time length information of each single video data frame to obtain the time length information of the new video file.
Optionally, the first codec information further includes at least one of video width, video height, video coding format, and audio coding format.
Optionally, before the obtaining the damaged video file and the reference video file for repairing the damaged video file, the method further includes:
detecting whether an audio data frame and a video data frame in a damaged video file are complete;
if the audio data frame and the video data frame are missing, determining that the damaged video file cannot be repaired, and ending the current video repair flow.
The embodiment of the invention discloses a video restoration device, which comprises:
the file acquisition module is used for acquiring a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters;
the information extraction module is used for extracting identification information and first coding and decoding information from the reference video file; wherein the identification information is used for representing the type of the video file;
the data extraction module is used for extracting audio data frames and video data frames from the damaged video file;
a data encoding module for encoding the audio data frame and the video data frame according to the first encoding and decoding information;
the information acquisition module is used for acquiring second coding and decoding information of the encoded audio data frames and the video data frames;
and the information packaging module is used for packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file.
Optionally, the data encoding module includes:
and the data storage module is used for respectively storing the audio data frame and the video data frame in the audio data block and the video data block according to the first coding and decoding information.
Optionally, the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the information acquisition module includes:
the information acquisition sub-module is used for acquiring the offset of the audio data frame and the video data relative to the initial position of the new video file, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
an information determining sub-module, configured to determine duration information of the new video file according to a total frame number of the audio data frames and the audio sampling rate, or a total frame number of the video data frames and the video frame rate;
and the information generation sub-module is used for generating the second coding and decoding information according to the first coding and decoding information, the byte sizes and the offset of the audio data frame and the video data, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block and the key frames in the audio data frame and the video data frame, and the duration information of the new video file.
Optionally, the information determining submodule includes:
a first information determining unit, configured to determine duration information of each single audio data frame according to the audio sampling rate;
the first information summation unit is used for summing the duration information of each single audio data frame to obtain the duration information of the new video file; or,
a second information determining unit, configured to determine duration information of each single video data frame according to the video frame rate;
and the second information summation unit is used for summing the duration information of each single video data frame to obtain the duration information of the new video file.
Optionally, the first codec information further includes at least one of video width, video height, video coding format, and audio coding format.
Optionally, the method further comprises:
the video detection module is used for detecting whether the audio data frame and the video data frame in the damaged video file are complete or not;
and the video judging module is used for determining that the damaged video file cannot be repaired if the audio data frame and the video data frame are missing, and ending the current video repairing flow.
The embodiment of the invention also discloses electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method according to the embodiment of the present invention when executing the program stored in the memory.
Embodiments of the invention also disclose one or more computer-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the methods described in the embodiments of the invention.
The embodiment of the invention has the following advantages: obtaining a damaged video file and a reference video file for repairing the damaged video file, wherein the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters, identification information and first coding and decoding information are extracted from the reference video file, the identification information is used for representing the type of the video file, and an audio data frame and a video data frame are extracted from the damaged video file; and encoding the audio data frame and the video data frame according to the first encoding and decoding information, and packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file by acquiring second encoding and decoding information of the encoded audio data frame and the encoded video data frame. By adopting the embodiment of the invention, the audio data frame and the video data frame of the damaged file are encoded by referring to the first encoding and decoding information in the video file, the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information are packaged into the new video file, and the damaged video file is further repaired, so that the problem that the recorded MP4 file cannot be played normally due to the fact that the recorded MP4 file is not stopped normally caused by uncontrollable factors such as power-off of video equipment is solved. Meanwhile, ji Yin video data can be re-encoded in the encoding process, so that the problem of audio and video synchronization is solved in the repairing process.
Drawings
FIG. 1 is a schematic diagram of an MP4 package type structure provided in an embodiment of the present invention;
FIG. 2 is a flow chart of steps of a video restoration method according to an embodiment of the present invention;
FIG. 3 is a flow chart of steps of another video restoration method provided in an embodiment of the present invention;
FIG. 4 is a block diagram of a video repair device according to an embodiment of the present invention;
FIG. 5 is a block diagram of an electronic device provided in an embodiment of the invention;
fig. 6 is a schematic diagram of a computer readable medium provided in an embodiment of the invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
When an MP4 video file is recorded, a definite framing mark is written in the file head, and if the normal framing mark is not written in the file head because of uncontrollable factors such as power failure, the video cannot be normally played.
In order to solve the problems, a section of MP4 video recorded normally in the same environment is adopted as comparison, the encoding and decoding information of a normal file is extracted, then all video and audio data are respectively extracted from a damaged video file, the encoding and decoding information of the normal video file is compared, and the recoding can be completed.
Referring to fig. 1, there is shown a schematic diagram of a package type of MP4, and as shown, all data in an MP4 file is contained in boxes, that is, an MP4 file is composed of a plurality of boxes, each box has a type and a length, and a box can be understood as a data object block. Another box may be included in the box, and such a box is called a container box. An MP4 file will first have and only have a box of the "ftyp" type, which is a flag in MP4 format and contains some information about the file; there will then be and only one "moov" type box (Movie Box), which is a container box that contains metadata information for the media; the media data of the MP4 file is contained in a type box (Midia Data Box) of "mdat", which is also a container box, and the structure of the media data is described by metadata.
Referring to fig. 2, a flowchart illustrating steps of a video restoration method provided in an embodiment of the present invention may specifically include the following steps:
step 201: obtaining a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting device based on the same coding parameters.
The video file obtained by shooting in the environment with the same parameters of all software and hardware such as code rate, frame rate, resolution is obtained by shooting by the same shooting device based on the same coding parameters.
Specifically, a damaged video file and a reference video file for repairing the damaged video file are acquired.
Step 202: extracting identification information and first codec information from the reference video file; wherein the identification information is used to characterize the type of video file.
The identification information is information used for representing the type of the video file in the box of the 'ftyp' type, and the first coding and decoding information is media information of the box of the 'moov' type.
Step 203: and extracting an audio data frame and a video data frame from the damaged video file.
The Audio data frame and the Video data frame refer to Audio samples and Video samples respectively, and are simply understood as samples, which are units of storage media data; the Audio data frame and the video data frame are stored in an Audio data block (Audio chunk) and a video data block (Audio chunk) in an "mdat" type box (Midia Data Box), respectively. The audio data blocks and the video data blocks are tightly stored in a box of the mdat type, and the audio data blocks and the video data blocks are alternately stored and have certain position correlation; one sample has a plurality of nalus (Network Abstract Layer, i.e., network abstraction layers) with corresponding type information, from which audio data frames and video data frames can be distinguished, further distinguishing audio data blocks from video data blocks.
Specifically, a frame search is performed on a damaged video file, and an audio data frame and a video data frame are extracted from a box of the "mdat" type in the damaged video file, respectively.
Step 204: and encoding the audio data frame and the video data frame according to the first encoding and decoding information.
Step 205: and obtaining second coding and decoding information of the encoded audio data frame and the video data frame.
Specifically, the audio data frame and the video data frame of the damaged video are encoded according to the first codec information of the reference video file, the obtained second codec information of the encoded audio data frame and video data frame,
the second encoding information is media information of a box of a "moov" type in the repackaged new video file, and may include information such as a total frame number, a data frame size, a data frame offset, a data block offset list, a data frame and data block mapping table, a key frame list, and the like.
Step 206: and packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file.
Specifically, the identification information is encapsulated in an ftyp box, the encoded audio data frame and video data frame are encapsulated in a moov box, and the second codec information is encapsulated in an mdat box, forming a new video file.
In the embodiment of the invention, the audio data frame and the video data frame of the damaged file are encoded by referring to the first encoding and decoding information in the video file, the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information are packaged into the new video file, and the damaged video file is further repaired, so that the problem that the recorded MP4 file cannot be normally played due to the fact that the recorded MP4 file is not normally stopped caused by uncontrollable factors such as power-off of video equipment is solved. Meanwhile, ji Yin video data can be re-encoded in the encoding process, so that the problem of audio and video synchronization is solved in the repairing process.
Referring to fig. 3, a flowchart illustrating steps of another video restoration method provided in an embodiment of the present invention may specifically include the following steps:
step 301: obtaining a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting device based on the same coding parameters.
In an embodiment of the present invention, before the obtaining the damaged video file and the reference video file for repairing the damaged video file, the method further includes: detecting whether an audio data frame and a video data frame in a damaged video file are complete or not, if the audio data frame and the video data frame are missing, determining that the damaged video file cannot be repaired, and ending the current video repair flow.
Specifically, before repairing the damaged video file, whether the audio data frame and the video data frame in the damaged video file are complete or not is detected, if the audio data frame and the video data frame are complete, the damaged video file can be repaired, if the audio data frame and the video data frame are missing, the damaged video file is determined to be unable to be repaired, and the current video repairing flow is ended.
In the embodiment of the invention, in the process of repairing the video, the video is repaired by judging whether the damaged video file can be repaired or not and ending the repair of the video under the condition that the damaged video file can not be repaired, thereby effectively improving the resource utilization rate and reducing the time for users to wait for repairing the video.
In an example of the present invention, whether the video file is damaged is determined by detecting whether the information such as the width and height, the duration, the code rate, the coding format, the frame list, the key frame list, the corresponding time stamp and the position in the file are complete.
Step 302: extracting identification information and first codec information from the reference video file; wherein the identification information is used to characterize the type of video file.
Step 303: and extracting an audio data frame and a video data frame from the damaged video file.
Step 304: and respectively storing the audio data frame and the video data frame in the audio data block and the video data block according to the first coding and decoding information.
Specifically, firstly, the offset of an audio data frame and a video data frame relative to the starting address of a damaged video file is queried, the audio data frame and the video data frame are respectively ordered (from small to large) according to the offset, the ordered audio data frame and video data frame are encoded according to first coding and decoding information of a reference video file, and the audio data frame and the video data frame are respectively stored in an audio data block and a video data block.
Step 305: and obtaining second coding and decoding information of the encoded audio data frame and the video data frame.
In an embodiment of the present invention, the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the step 306 includes: acquiring offset of the audio data frame and the video data relative to the initial position of the new video file, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
determining duration information of the new video file according to the total frame number of the audio data frames and the audio sampling rate or the total frame number of the video data frames and the video frame rate;
generating the second encoding and decoding information according to the first encoding and decoding information, byte sizes and offset of the audio data frame and the video data, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block, offset of the audio data block and the video data block, and key frames in the audio data frame and the video data frame, and the duration information of the new video file.
The first encoding and decoding information at least comprises one of video width, video high frequency, frequency frame rate, video encoding format, audio encoding format and audio sampling rate.
Specifically, after the audio data frame and the video data frame are respectively stored in the audio data block and the video data block, information such as video width, video high, frequency frame rate, video coding format, audio sampling rate and the like in the first coding and decoding information is recorded in second coding and decoding information (moov); recording the byte size of the audio data frame and the video data in a stsz box (sample size) of the second codec information (moov); recording the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block into an stsc box (mapping relation between sample and chunk) of second coding and decoding information (moov); recording the offset of the audio data block and the video data block into a stco box (chunk offset list) of the second codec information (moov); key frames in the audio data frame and the video data frame are recorded into a stss box (key frame list) of second codec information (moov), and the key frames are random reference frames.
In an embodiment of the present invention, further includes: the determining the duration information of the new video file according to the total frame number of the audio data frames and the audio sampling rate or the total frame number of the video data frames and the video frame rate includes: determining duration information of each single audio data frame according to the audio sampling rate; summing the time length information of each single audio data frame to obtain the time length information of the new video file; or determining the duration information of each single video data frame according to the video frame rate; and summing the time length information of each single video data frame to obtain the time length information of the new video file.
Specifically, the audio data frame and the video data frame refer to audio samples and video samples, one video data frame includes one or a group of continuous video frames, and one audio data frame is a continuous compressed audio, so that duration time of different samples is different, and therefore, duration time information of each single audio data frame needs to be determined according to an audio sampling rate, and duration time information of each single video data frame needs to be determined according to a video frame rate, and then the duration time information of new video files is obtained by summing the duration time of each different audio data frame or video data frame.
Further, sample to Timestamp Table (a mapping table of time stamp and sample sequence number) in the stts box of the second codec information may be determined according to the duration of each different audio data frame or video data frame.
Step 306: and packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file.
In the embodiment of the invention, the audio data frame and the video data frame of the damaged file are encoded by referring to the first encoding and decoding information in the video file, the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information are packaged into the new video file, and the damaged video file is further repaired, so that the problem that the recorded MP4 file cannot be normally played due to the fact that the recorded MP4 file is not normally stopped caused by uncontrollable factors such as power-off of video equipment is solved. Meanwhile, ji Yin video data can be re-encoded in the encoding process, so that the problem of audio and video synchronization is solved in the repairing process.
In the process of repairing the video, whether the damaged video file can be repaired or not is judged, and under the condition that the video file cannot be repaired, the video repairing is finished, so that the resource utilization rate is effectively improved, and the time for users to wait for video repairing is reduced.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 4, a block diagram of a video repair device provided in an embodiment of the present invention is shown, which may specifically include the following modules:
a file acquisition module 401, configured to acquire a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters;
an information extraction module 402, configured to extract identification information and first codec information from the reference video file; wherein the identification information is used for representing the type of the video file;
a data extraction module 403, configured to extract an audio data frame and a video data frame from the damaged video file;
a data encoding module 404, configured to encode the audio data frame and the video data frame according to the first codec information;
an information obtaining module 405, configured to obtain second codec information of the encoded audio data frame and the video data frame;
and an information packaging module 406, configured to package the identification information, the encoded audio data frame, the encoded video data frame, and the second codec information into a new video file.
In one embodiment of the present invention, the data encoding module 404 includes:
and the data storage module is used for respectively storing the audio data frame and the video data frame in the audio data block and the video data block according to the first coding and decoding information.
Optionally, the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the information obtaining module 405 includes:
the information acquisition sub-module is used for acquiring the offset of the audio data frame and the video data relative to the initial position of the new video file, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
an information determining sub-module, configured to determine duration information of the new video file according to a total frame number of the audio data frames and the audio sampling rate, or a total frame number of the video data frames and the video frame rate;
and the information generation sub-module is used for generating the second coding and decoding information according to the first coding and decoding information, the byte sizes and the offset of the audio data frame and the video data, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block and the key frames in the audio data frame and the video data frame, and the duration information of the new video file.
In an embodiment of the present invention, the information determining submodule includes:
a first information determining unit, configured to determine duration information of each single audio data frame according to the audio sampling rate;
the first information summation unit is used for summing the duration information of each single audio data frame to obtain the duration information of the new video file; or,
a second information determining unit, configured to determine duration information of each single video data frame according to the video frame rate;
and the second information summation unit is used for summing the duration information of each single video data frame to obtain the duration information of the new video file.
In an embodiment of the present invention, the first codec information further includes at least one of video width, video height, video coding format, and audio coding format.
In an embodiment of the present invention, further includes:
the video detection module is used for detecting whether an audio data frame and a video data frame in the damaged video file are complete or not, if the audio data frame and the video data frame are missing, determining that the damaged video file cannot be repaired, and ending the current video repair flow.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
In addition, the embodiment of the invention also provides an electronic device, as shown in fig. 5, which comprises a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete communication with each other through the communication bus 504,
a memory 503 for storing a computer program;
the processor 501 is configured to implement the video restoration method as described in the above embodiment when executing the program stored in the memory 503.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment provided by the present invention, as shown in fig. 6, there is further provided a computer readable storage medium 601 having instructions stored therein, which when run on a computer, cause the computer to perform the video restoration method described in the above embodiment.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the video restoration method described in the above embodiment.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (7)

1. A method of video repair, comprising:
obtaining a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters;
extracting identification information and first codec information from the reference video file; wherein the identification information is used for representing the type of the video file;
extracting an audio data frame and a video data frame from the damaged video file;
encoding the audio data frame and the video data frame according to the first encoding and decoding information;
acquiring second encoding and decoding information of the encoded audio data frame and the encoded video data frame;
packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file;
the encoding the audio data frame and the video data frame according to the first codec information includes:
storing the audio data frame and the video data frame in an audio data block and a video data block respectively according to the first encoding and decoding information;
the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the obtaining the encoded second codec information of the audio data frame and the video data frame includes:
acquiring offset of the audio data frame and the video data relative to the initial position of the new video file, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
determining duration information of the new video file according to the total frame number of the audio data frames and the audio sampling rate or the total frame number of the video data frames and the video frame rate;
generating the second encoding and decoding information according to the first encoding and decoding information, byte sizes and offset of the audio data frame and the video data, mapping relation between the audio data frame and the video data frame and the audio data block and the video data block, offset of the audio data block and the video data block, and key frames in the audio data frame and the video data frame, and the duration information of the new video file.
2. The method of claim 1, wherein determining the duration information of the new video file based on the total number of frames of the audio data frames and the audio sampling rate, or the total number of frames of the video data frames and the video frame rate, comprises:
determining duration information of each single audio data frame according to the audio sampling rate;
summing the time length information of each single audio data frame to obtain the time length information of the new video file; or,
determining duration information of each single video data frame according to the video frame rate;
and summing the time length information of each single video data frame to obtain the time length information of the new video file.
3. The method of claim 1, wherein the first codec information further comprises at least one of a video wide, a video high, a video coding format, and an audio coding format.
4. The method of claim 1, further comprising, prior to the acquiring the damaged video file and the reference video file for repairing the damaged video file:
detecting whether an audio data frame and a video data frame in a damaged video file are complete;
if the audio data frame and the video data frame are missing, determining that the damaged video file cannot be repaired, and ending the current video repair flow.
5. A video repair device, the device comprising:
the file acquisition module is used for acquiring a damaged video file and a reference video file for repairing the damaged video file; the reference video file and the damaged video file are obtained by shooting by the same shooting equipment based on the same coding parameters;
the information extraction module is used for extracting identification information and first coding and decoding information from the reference video file; wherein the identification information is used for representing the type of the video file;
the data extraction module is used for extracting audio data frames and video data frames from the damaged video file;
a data encoding module for encoding the audio data frame and the video data frame according to the first encoding and decoding information;
the information acquisition module is used for acquiring second coding and decoding information of the encoded audio data frames and the encoded video data frames;
the information packaging module is used for packaging the identification information, the encoded audio data frame, the encoded video data frame and the second encoding and decoding information into a new video file;
the data encoding module comprises:
the data storage module is used for respectively storing the audio data frame and the video data frame in an audio data block and a video data block according to the first coding and decoding information;
the first codec information includes at least a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the information acquisition module includes:
the information acquisition sub-module is used for acquiring the offset of the audio data frame and the video data relative to the initial position of the new video file, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block relative to the initial position of the new video file, and key frames in the audio data frame and the video data frame;
an information determining sub-module, configured to determine duration information of the new video file according to a total frame number of the audio data frames and the audio sampling rate, or a total frame number of the video data frames and the video frame rate;
and the information generation sub-module is used for generating the second coding and decoding information according to the first coding and decoding information, the byte sizes and the offset of the audio data frame and the video data, the mapping relation between the audio data frame and the video data frame and the audio data block and the video data block respectively, the offset of the audio data block and the video data block and the key frames in the audio data frame and the video data frame, and the duration information of the new video file.
6. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method according to any one of claims 1-4 when executing a program stored on a memory.
7. One or more computer-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method of any of claims 1-4.
CN202111023494.1A 2021-08-31 2021-08-31 Video restoration method and device, electronic equipment and readable medium Active CN113660442B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111023494.1A CN113660442B (en) 2021-08-31 2021-08-31 Video restoration method and device, electronic equipment and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111023494.1A CN113660442B (en) 2021-08-31 2021-08-31 Video restoration method and device, electronic equipment and readable medium

Publications (2)

Publication Number Publication Date
CN113660442A CN113660442A (en) 2021-11-16
CN113660442B true CN113660442B (en) 2024-03-19

Family

ID=78482699

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111023494.1A Active CN113660442B (en) 2021-08-31 2021-08-31 Video restoration method and device, electronic equipment and readable medium

Country Status (1)

Country Link
CN (1) CN113660442B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114446330B (en) * 2021-12-30 2024-04-16 厦门市美亚柏科信息股份有限公司 Method, device and storage medium for repairing MP4 file

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20130084345A (en) * 2012-01-17 2013-07-25 (주)피타소프트 Mp4 file configuring device and restoring device, mp4 file configuring method and restoring method
CN103404146A (en) * 2013-03-11 2013-11-20 华为技术有限公司 Video file repairing method and device
CN108093299A (en) * 2017-12-22 2018-05-29 厦门市美亚柏科信息股份有限公司 MP4 damages the restorative procedure and storage medium of file
KR20200041650A (en) * 2018-10-12 2020-04-22 펜타시큐리티시스템 주식회사 Method and apparatus for recovering damaged mp4 video file based on meta information of reference video
CN111063376A (en) * 2019-12-13 2020-04-24 厦门市美亚柏科信息股份有限公司 Method, terminal equipment and storage medium for audio and video synchronization in MP4 repairing
CN111813965A (en) * 2020-05-14 2020-10-23 北京嘀嘀无限科技发展有限公司 Encryption method, decryption method, storage medium and electronic equipment for multimedia file

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20130084345A (en) * 2012-01-17 2013-07-25 (주)피타소프트 Mp4 file configuring device and restoring device, mp4 file configuring method and restoring method
CN103404146A (en) * 2013-03-11 2013-11-20 华为技术有限公司 Video file repairing method and device
CN108093299A (en) * 2017-12-22 2018-05-29 厦门市美亚柏科信息股份有限公司 MP4 damages the restorative procedure and storage medium of file
KR20200041650A (en) * 2018-10-12 2020-04-22 펜타시큐리티시스템 주식회사 Method and apparatus for recovering damaged mp4 video file based on meta information of reference video
CN111063376A (en) * 2019-12-13 2020-04-24 厦门市美亚柏科信息股份有限公司 Method, terminal equipment and storage medium for audio and video synchronization in MP4 repairing
CN111813965A (en) * 2020-05-14 2020-10-23 北京嘀嘀无限科技发展有限公司 Encryption method, decryption method, storage medium and electronic equipment for multimedia file

Also Published As

Publication number Publication date
CN113660442A (en) 2021-11-16

Similar Documents

Publication Publication Date Title
CN108093299B (en) Method for repairing damaged MP4 file and storage medium
CN111063376B (en) Method, terminal equipment and storage medium for audio and video synchronization in MP4 repairing
US9792390B2 (en) Metadata/content re-association system and method
CN108076377B (en) Video storage and playing method and device, electronic equipment and storage medium
US20090024644A1 (en) Extended Multimedia File Structure and Multimedia File Producting Method and Multimedia File Executing Method
Su et al. Detection of double-compression in MPEG-2 videos
CN108322808B (en) Video recording processing method and device, computer device and storage medium
CN104602105B (en) The player method and user equipment of video file
CN113660442B (en) Video restoration method and device, electronic equipment and readable medium
EP2981964A1 (en) Syntax-aware manipulation of media files in a container format
EP3809708A1 (en) Video data storage method and device in cloud storage system
CN105357229B (en) Video processing method and device
CN104093038B (en) For test and method for supervising and the device of real time flow medium identification service
CN110944231B (en) Monitoring method and device of video player
CN109597566B (en) Data reading and storing method and device
Park et al. Data fragment forensics for embedded DVR systems
CN110851301A (en) Recovery method and system for MP4 file
CN113569719B (en) Video infringement judging method and device, storage medium and electronic equipment
CN112929686B (en) Method and device for playing back recorded video in real time on line
CN109426589B (en) File repair method and device
CN111083497B (en) Video screenshot method and device
US20080008443A1 (en) Data management system and method
CN115665476B (en) Video analysis method and device, electronic equipment and storage medium
CN116489458B (en) MP4 repairing method, device, terminal and medium based on file byte analysis
CN114125493B (en) Distributed storage method, device and equipment for streaming media

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