CN113660442A - Video repairing method and device, electronic equipment and readable medium - Google Patents

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

Info

Publication number
CN113660442A
CN113660442A CN202111023494.1A CN202111023494A CN113660442A CN 113660442 A CN113660442 A CN 113660442A CN 202111023494 A CN202111023494 A CN 202111023494A CN 113660442 A CN113660442 A CN 113660442A
Authority
CN
China
Prior art keywords
video
data frame
audio data
video file
information
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
CN202111023494.1A
Other languages
Chinese (zh)
Other versions
CN113660442B (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

Images

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Television Signal Processing For Recording (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The embodiment of the invention provides a video repairing method, a video repairing device, electronic equipment and a computer readable storage medium, wherein the video repairing method comprises the following steps: acquiring a damaged video file and a reference video file for repairing the damaged video file, and 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 damaged video file; encoding the audio data frame and the video data frame according to the first encoding and decoding information; and the identification information, the encoded audio data frame and video data frame and the second coding and decoding information are packaged 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 repairing method and device, electronic equipment and readable medium
Technical Field
The present invention relates to the field of data repair technologies, and in particular, to a video repair method, a video repair apparatus, an electronic device, and a computer-readable medium.
Background
The MP4 is a common multimedia container format, and is implemented based on MPEG-4Part 6 or related specifications, and at present, video recording devices such as monitoring devices, automobile data recorders, smartphones and the like are widely applied to the MP4 as a video packaging format.
In the process of recording the MP4 file, the recorded MP4 file is not normally stopped due to uncontrollable factors such as power failure of the video recording equipment and the like, so that the recorded MP4 file cannot be normally played.
Disclosure of Invention
Embodiments of the present invention provide a video repair method, apparatus, electronic device, and computer-readable storage medium, so as to solve the problem that a recorded MP4 file cannot be normally stopped due to uncontrollable factors such as power failure of a video recording device, and the recorded MP4 file cannot be normally played.
The embodiment of the invention discloses a video repair method, which comprises the following steps:
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 the same shooting equipment based on the same coding parameters;
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;
acquiring second coding and decoding information of the coded audio data frame and the coded video data frame;
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 coding and decoding information includes:
and storing the audio data frame and the video data frame in the audio data block and the video data block respectively according to the first coding and decoding information.
Optionally, the first coding and decoding information at least includes a video frame rate and an audio sampling rate, the audio data frame and the video data have corresponding byte sizes, and the obtained second coding and decoding information of the encoded audio data frame and the encoded video data frame includes:
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;
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;
and generating the second coding and decoding information according to the first coding and decoding information, the byte size 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, the key frame 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 the 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; alternatively, the first and second electrodes may be,
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.
Optionally, the first codec information further includes at least one of a video bandwidth, a video height, a video encoding format, and an audio encoding format.
Optionally, before the obtaining the corrupted video file and the reference video file for repairing the corrupted video file, the method further includes:
detecting whether audio data frames and video data frames in the damaged video file are complete or not;
and 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 repairing process.
The embodiment of the invention discloses a video repair 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 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;
the data coding module is used for coding the audio data frame and the video data frame according to the first coding and decoding information;
the information acquisition module is used for acquiring second coding and decoding information of the encoded audio data frame and the encoded video data frame;
and the information packaging module is used for packaging the identification information, the coded audio data frame and the coded video data frame and the second coding 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 encoding and decoding information at least includes a video frame rate and an audio sampling rate, where the audio data frame and the video data have corresponding byte sizes, and the information obtaining module includes:
the information acquisition submodule 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 a key frame in the audio data frame and the video data frame;
the information determining submodule is used for 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;
and the information generation submodule is used for generating the second coding and decoding information according to the first coding and decoding information, the byte size 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, 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 sub-module includes:
the first information determining unit is used for determining the duration information of each single audio data frame according to the audio sampling rate;
the first information summing unit is used for summing the time length information of each single audio data frame to obtain the time length information of the new video file; alternatively, the first and second electrodes may be,
the second information determining unit is used for determining the duration information of each single video data frame according to the video frame rate;
and the second information summing unit is used for 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 a video bandwidth, a video height, a video encoding format, and an audio encoding 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 judgment 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 repair process.
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 finish mutual communication 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.
Also disclosed are one or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform a method according to an embodiment of the invention.
The embodiment of the invention has the following advantages: acquiring 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 the same shooting equipment based on the same coding parameters, 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, and extracting an audio data frame and a video data frame 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 encapsulating the identification information, the encoded audio data frame and the encoded video data frame and the second encoding and decoding information into a new video file according to the acquired second encoding and decoding information of the encoded audio data frame and the encoded video data frame. 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 coding and decoding information in the video file, the identification information, the encoded audio data frame and video data frame and the second coding and decoding information are packaged into the new video file, and then the damaged video file is repaired, so that the problem that the recorded MP4 file is not normally stopped due to uncontrollable factors such as power failure of a video device and the like, and the recorded MP4 file cannot be normally played is solved. Meanwhile, the audio and video data can be realigned in the encoding process, so that the problem of audio and video synchronization in the repairing process is solved.
Drawings
Fig. 1 is a schematic structural diagram of a package type of MP4 provided in an embodiment of the present invention;
fig. 2 is a flowchart illustrating steps of a video repair method according to an embodiment of the present invention;
FIG. 3 is a flow chart of steps of another video repair method provided in an embodiment of the present invention;
fig. 4 is a block diagram of a video repair apparatus provided in 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 to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
A normally played MP4 file consists of a file header, audio and video data and a file tail, when an MP4 video file is recorded, a clear framing mark is written in the file header, and if the file header is not written with the normal framing mark due to 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 used as comparison to extract the coding and decoding information of a normal file, then all video and audio data are respectively extracted from a damaged video file, and the coding and decoding information of the normal video file is compared and recoded to complete restoration.
Referring to fig. 1, a schematic diagram of a package type of MP4 is shown, and as shown in the figure, all data in an MP4 file are contained in a box, that is, an MP4 file is composed of several boxes, each of which has a type and a length, and can be understood as a data object block. Another box may be included in the box, which is called a container box. An MP4 file will first have and only have one "ftyp" type box, which acts as a flag for MP4 format and contains some information about the file; there will be and only one "moov" type box (movie box) later, which is a container box, and the sub-box contains metadata information of the media; the media Data of the MP4 file is contained in a box (midi Data box) of the "mdat" type, 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 repair method provided in an embodiment of the present invention is shown, which may specifically include the following steps:
step 201: acquiring a damaged video file and a reference video file for repairing the damaged video file; and the reference video file and the damaged video file are shot by the same shooting equipment based on the same coding parameters.
The same shooting equipment shoots and obtains video files which are obtained by shooting in an environment with the same software and hardware parameters such as code rate, frame rate, resolution ratio and the like based on the same coding parameters.
Specifically, a corrupted video file and a reference video file for repairing the corrupted video file are obtained.
Step 202: extracting identification information and first coding and decoding information from the reference video file; wherein the identification information is used for characterizing the type of the video file.
The identification information is information used for representing the type of the video file in the ftyp type box, and the first coding and decoding information is media information of the moov type box.
Step 203: audio data frames and video data frames are extracted from the corrupted video file.
Wherein, the Audio data frame and the Video data frame respectively refer to Audio Sample and Video Sample, and the Sample is simply understood as a Sample and is a unit for storing media data; the Audio Data frame and the video Data frame are stored in an Audio chunk (Audio chunk) and a video chunk (Audio chunk), respectively, in a box (midia Data box) of the "mdat" type. Audio data blocks and video data blocks are stored in an mdat type box tightly, and the audio data blocks and the video data blocks are stored alternately and have certain position correlation; one sample has a plurality of nalus (Network Abstract Layer), which have corresponding type information, and can distinguish audio data frames and video data frames according to the Nalu, and further distinguish audio data blocks and video data blocks.
Specifically, a frame search is performed on the damaged video file, and audio data frames and video data frames are respectively extracted from an "mdat" type box in the damaged video file.
Step 204: and encoding the audio data frame and the video data frame according to the first encoding and decoding information.
Step 205: and acquiring second coding and decoding information of the encoded audio data frame and the encoded video data frame.
Specifically, the audio data frame and the video data frame of the damaged video are encoded according to the first coding and decoding information of the reference video file, the second coding and decoding information of the encoded audio data frame and the video data frame is obtained,
the second encoding information is the media information of the box of the "moov" type in the newly encapsulated video file, and may include, for example, the total frame number, the data frame size, the data frame offset, the data block offset list, the data frame-to-data block mapping table, the key frame list, and so on.
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, so as to form 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 coding and decoding information in the video file, the identification information, the encoded audio data frame and the encoded video data frame and the second coding and decoding information are packaged into the new video file, and then the damaged video file is repaired, so that the problem that the recorded MP4 file is not normally stopped due to uncontrollable factors such as power failure of a video device and the like, and the recorded MP4 file cannot be normally played is solved. Meanwhile, the audio and video data can be realigned in the encoding process, so that the problem of audio and video synchronization in the repairing process is solved.
Referring to fig. 3, a flowchart illustrating steps of another video repair method provided in the embodiment of the present invention is shown, which may specifically include the following steps:
step 301: acquiring a damaged video file and a reference video file for repairing the damaged video file; and the reference video file and the damaged video file are shot by the same shooting equipment based on the same coding parameters.
In an embodiment of the present invention, before the acquiring the damaged video file and the reference video file for repairing the damaged video file, the method further includes: and detecting whether the audio data frame and the 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 repairing process.
Specifically, before repairing the damaged video file, whether an audio data frame and a 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, and if the audio data frame and the video data frame are missing, it is determined that the damaged video file cannot be repaired, and the current video repairing process 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 under the condition that the damaged video file cannot be repaired, the video is repaired, so that the resource utilization rate is effectively improved, and the time for a user to wait for video repair is reduced.
In an example of the present invention, whether a video file is damaged is determined by detecting whether information such as width, height, duration, code rate, encoding format, frame list, key frame list, corresponding timestamp, and position in the file of the video file is complete.
Step 302: extracting identification information and first coding and decoding information from the reference video file; wherein the identification information is used for characterizing the type of the video file.
Step 303: audio data frames and video data frames are extracted from the corrupted video file.
Step 304: and storing the audio data frame and the video data frame in the audio data block and the video data block respectively according to the first coding and decoding information.
Specifically, the offset of the audio data frame and the video data frame relative to the start address of the damaged video file is firstly inquired, the audio data frame and the video data frame are respectively sorted (from small to large) according to the offset, the sorted audio data frame and the video data frame are coded according to the first coding and decoding information of the reference video file, and the audio data frame and the video data frame are respectively stored in the audio data block and the video data block.
Step 305: and acquiring second coding and decoding information of the encoded audio data frame and the encoded video data frame.
In an embodiment of the present invention, the first encoding/decoding information at least includes 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 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;
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;
and generating the second coding and decoding information according to the first coding and decoding information, the byte size 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, the key frame in the audio data frame and the video data frame, and the duration information of the new video file.
The first encoding/decoding information at least comprises one of video frequency width, video frequency height, video frequency frame rate, video frequency coding format, audio frequency coding format and audio frequency sampling rate.
Specifically, after an audio data frame and a video data frame are respectively stored in an audio data block and a video data block, information such as video frequency width, video height, video frame rate, video coding format, audio coding format and audio sampling rate in first coding and decoding information is recorded into second coding and decoding information (moov); recording byte size systems of the audio data frame and the video data into an 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 between the audio data block and the video data block into an stsc box (mapping relation between sample and chunk) of second encoding 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 coding and decoding information (moov); and inputting a key frame in the audio data frame and the video data frame into a stss box (key frame list) of second coding and decoding information (moov), wherein the key frame is a random reference frame.
In an embodiment of the present invention, the method further includes: 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, including: determining the 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 frames and the video data frames 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 section of continuous compressed audio, so that the duration of different samples is different, and therefore, the duration information of each single audio data frame needs to be determined according to the audio sampling rate, the duration information of each single video data frame is determined according to the video frame rate, and then the duration information of each different audio data frame or video data frame is summed according to the duration of each different audio data frame or video data frame to obtain the duration information of a new video file.
Further, it is also possible to determine a Sample to Timestamp Table (mapping Table of Timestamp-Sample sequence number) in the stts box of the second codec information 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 coding and decoding information in the video file, the identification information, the encoded audio data frame and the encoded video data frame and the second coding and decoding information are packaged into the new video file, and then the damaged video file is repaired, so that the problem that the recorded MP4 file is not normally stopped due to uncontrollable factors such as power failure of a video device and the like, and the recorded MP4 file cannot be normally played is solved. Meanwhile, the audio and video data can be realigned in the encoding process, so that the problem of audio and video synchronization in the repairing process is solved.
In the process of repairing the video, whether the damaged video file can be repaired is judged, and under the condition that the damaged video file cannot be repaired, the video is repaired, so that the resource utilization rate is effectively improved, and the time for a user to wait for video repair is reduced.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 4, a block diagram of a video repair apparatus provided in an embodiment of the present invention is shown, which may specifically include the following modules:
a file obtaining module 401, configured to obtain 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 the same shooting equipment based on the same coding parameters;
an information extraction module 402, configured to extract 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;
a data extraction module 403, configured to extract audio data frames and video data frames 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 encoding and decoding information;
an information obtaining module 405, configured to obtain second encoding and decoding information of the encoded audio data frame and the encoded video data frame;
an information encapsulating module 406, configured to encapsulate the identification information, the encoded audio data frame and the encoded video data frame, and the second encoding and decoding information into a new video file.
In an 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 encoding and decoding information at least includes 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 submodule 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 a key frame in the audio data frame and the video data frame;
the information determining submodule is used for 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;
and the information generation submodule is used for generating the second coding and decoding information according to the first coding and decoding information, the byte size 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, 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 sub-module includes:
the first information determining unit is used for determining the duration information of each single audio data frame according to the audio sampling rate;
the first information summing unit is used for summing the time length information of each single audio data frame to obtain the time length information of the new video file; alternatively, the first and second electrodes may be,
the second information determining unit is used for determining the duration information of each single video data frame according to the video frame rate;
and the second information summing unit is used for summing the time length information of each single video data frame to obtain the time length information of the new video file.
In an embodiment of the invention, the first encoding/decoding information further includes at least one of a video bandwidth, a video height, a video encoding format, and an audio encoding format.
In an embodiment of the present invention, the method 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 process.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
In addition, an embodiment of the present invention further provides an electronic device, as shown in fig. 5, which includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, where the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504,
a memory 503 for storing a computer program;
the processor 501 is configured to implement the video repair method described in the above embodiments when executing the program stored in the memory 503.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment provided by the present invention, as shown in fig. 6, there is further provided a computer-readable storage medium 601, which stores instructions that, when executed on a computer, cause the computer to execute the video repair method described in the above embodiment.
In yet another embodiment provided by the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the video repair method described in the above embodiment.
In the above embodiments, the implementation may be wholly or partially realized 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, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the 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)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A method of video repair, comprising:
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 the same shooting equipment based on the same coding parameters;
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;
acquiring second coding and decoding information of the coded audio data frame and the coded video data frame;
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.
2. The method of claim 1, wherein encoding the frame of audio data and the frame of video data according to the first coding information comprises:
and storing the audio data frame and the video data frame in the audio data block and the video data block respectively according to the first coding and decoding information.
3. The method of claim 2, wherein the first coding information at least comprises a video frame rate and an audio sampling rate, the audio data frames and the video data have corresponding byte sizes, and the obtained second coding information of the encoded audio data frames and the video data frames comprises:
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;
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;
and generating the second coding and decoding information according to the first coding and decoding information, the byte size 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, the key frame in the audio data frame and the video data frame, and the duration information of the new video file.
4. The method of claim 3, wherein the determining the duration information of the new video file according to the total number of the audio data frames and the audio sampling rate, or the total number of the video data frames and the video frame rate comprises:
determining the 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; alternatively, the first and second electrodes may be,
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.
5. The method of claim 1, wherein the first codec information further comprises at least one of video bandwidth, video height, video encoding format, and audio encoding format.
6. The method of claim 1, further comprising, prior to said obtaining the corrupted video file and the reference video file used to repair the corrupted video file:
detecting whether audio data frames and video data frames in the damaged video file are complete or not;
and 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 repairing process.
7. A video repair apparatus, the apparatus 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 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;
the data coding module is used for coding the audio data frame and the video data frame according to the first coding and decoding information;
the information acquisition module is used for acquiring second coding and decoding information of the encoded audio data frame and the encoded video data frame;
and the information packaging module is used for packaging the identification information, the coded audio data frame and the coded video data frame and the second coding and decoding information into a new video file.
8. The apparatus of claim 7, wherein the data encoding module comprises:
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.
9. 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, when executing a program stored on the memory, implementing the method of any of claims 1-6.
10. 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-6.
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 true CN113660442A (en) 2021-11-16
CN113660442B 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)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114446330A (en) * 2021-12-30 2022-05-06 厦门市美亚柏科信息股份有限公司 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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
CN113660442B (en) 2024-03-19

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
Su et al. Detection of double-compression in MPEG-2 videos
CN108322808B (en) Video recording processing method and device, computer device and storage medium
CN104602105A (en) Video file playing method and user equipment
CN113660442B (en) Video restoration method and device, electronic equipment and readable medium
KR102104409B1 (en) Image Recording system based on Open-platform and protocol-conversion method thereof
CN104093038B (en) For test and method for supervising and the device of real time flow medium identification service
US8584252B2 (en) Electronic device and copyright protection method of audio file thereof
KR20200041650A (en) Method and apparatus for recovering damaged mp4 video file based on meta information of reference video
CN110851301B (en) Recovery method and system for MP4 file
Park et al. Data fragment forensics for embedded DVR systems
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
US11599570B2 (en) Device and method to render multimedia data stream tamper-proof based on block chain recording
CN112866745B (en) Streaming video data processing method, device, computer equipment and storage medium
CN113301391B (en) Video downloading method, device, computing equipment, medium and cloud storage system
CN114501140A (en) Video character superposition processing method, system and storage medium
CN109426589B (en) File repair method and device
CN114257840B (en) Repairing method and system for Matroska format video
CN112416873B (en) Video fragment file recovery method and device, computer equipment and storage medium
US20080008443A1 (en) Data management system and method
CN104980792A (en) Method and device for testing video play
CN116489458B (en) MP4 repairing method, device, terminal and medium based on file byte analysis

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