How to Fix Corrupted MP4 Files – The Definitive Guide

20 March 2019 | by the restore.media team

This is a complete guide to fixing corrupted mp4 files. In this guide you will find plain-English instructions on how to fix mp4 video files depending on the issues you encounter.

To get started, let’s first define what exactly causes your mp4 video being unplayable. Choose your case from the list below to jump straight to the appropriate chapter in the article:

  • I have a regular MP4 file, no accidents have happened with it. The video just doesn’t play in my media player. If this is your case, click here.
  • When shooting video on my camera, the recording was interrupted by an accident and wasn’t finalized properly (e.g. a camera drop, dead battery, etc.). Go here.
  • I accidentally deleted my mp4 file from an SD card or other storage media. Jump here.

Chapter 1:
Start here if you’re sure your mp4 file is valid (not corrupted)

So, you’re quite sure the mp4 file you’re trying to play is valid and you haven’t damaged it in any way.

For example, you may have downloaded an mp4 file from a trusted source, a website, or someone just shared the video with you. The file looks to be fine, but when trying to play it, you get an error, something like “unsupported file format”, “the file isn’t playable”, or similar. If this is your case, chances are you just have an outdated media player or miss proper video codecs installed on your computer.

All you need to do is install the latest version of a video player suggested below along with a codec pack:

  • For Windows users we recommend the latest version of K-Lite Codec Pack. It’s a free, yet powerful codec pack that includes all essential codecs needed to play a wide variety of media file types, including mp4. It also comes with a lightweight media player called Media Player Classic (MPC), which is a great replacement to the built-in Windows Media Player. In some cases, it allows you to play even corrupted mp4 files that miss a part of indices in their headers.
    Please note: once you installed K-Lite Codec Pack, it is not recommended to install any other codecs on the same PC to avoid possible conflicts between them.
  • For Mac and other non-Windows users, we recommend VLC media player. It’s free and works across all popular platforms, including Mac, Linux, Android and iOS. VLC media player also comes with video and audio codecs, including AVC/H.264 and HEVC/H.265, needed for playing mp4 video files.

Head over to the next section of this article to try fixing the file.

Chapter 2:
Fixing mp4 files that were corrupted due to interrupted recording.

The Problem

Interrupted recording is one of the most common reasons why mp4 files actually get damaged. Here is how this usually happens:

  • You accidently dropped your camera or phone while shooting a video
  • A battery was low on power and suddenly died when you were still recording the video
  • Your memory card ran out of space while recording a video to it
  • You didn’t manage to land your drone properly and it crashed or fell into the water
  • A car accident happened and as a result the video from the dash cam can’t be played

So, basically if you didn’t stop your video recording properly, but it was interrupted for any reason, you may end up with a damaged, unplayable mp4 file. Why is this?

When recording a video, every camera, regardless of the form factor, keeps video’s metadata along with indices in its internal memory (RAM), while writing the actual video into a permanent storage (this is usually an external memory card, such as SD).

RAM (random-access memory) is a temporary memory needed for cameras to operate quickly. When you stop shooting a video, its metadata and indices are saved from RAM to the permanent storage, usually at the end of the recorded mp4 file. The metadata contains details about codecs, video and audio streams, etc. and is then used by media players to play the video.

Unfortunately, though, RAM can’t hold data without power. As you may have already guessed, if the camera is turned off by an accident while still recording the video, the metadata can get lost and not saved in the final video file. As a result, you have an mp4 file that looks like a valid video, but is unplayable.

Solution

The good news is that it’s possible to fix such corrupted mp4 files. All you need to do is inject the missing metadata/indices into the broken video. But since the metadata from the original file has been lost in the RAM forever, you can use metadata taken from a reference video recorded with the same camera and settings.

Here is how to do this:

If you had recorded multiple shots during a video session with the same camera settings before the disaster happened, take any valid one as a reference file. Alternatively, you can use any video you shot earlier on the same camera/settings from your video archive.

If you don’t have such a video, just try to recall what settings you used when shooting the broken mp4 file and record a new sample video with the same settings. A video of around 5 minutes and 100MB would be enough.

Important! Do not record the reference video on the same memory card that holds the damaged mp4 file. If nothing else helps, you may need to send an image (backup) of your memory card to video recovery experts for manual processing.

Also, if you don’t have any reference videos and can’t access the camera to shoot one, or the camera has been damaged, email us and our engineers will try to find a reference mp4 file from our archive.

Now that you have a corrupted mp4 file and a reference video, you need to use a tool that will extract the missing metadata from the valid video and inject it into the broken mp4 file.

Method 1

Please note that this method will work for Windows users only and it requires some basic knowledge of the Command Prompt. If you’re using any other operating system or you aren’t comfortable with Command Prompt, please see method 2.

Step 1

Make a backup copy of your corrupted mp4 file.
If you use a valuable video as a reference file, make a backup copy of this video too.

Step 2

Here, at Restore.Media, we’ve developed a video recovery tool, called recover_mp4. It extracts metadata from a valid reference video and injects it into the corrupted mp4 file. You can download the tool for free by clicking on the link bellow:
Download recover_mp4

Please note that we do not provide support for recover_mp4 users, since this is a free tool.

Step 3

Download another free tool, called ffmpeg. You’ll need it later on to combine the fixed video and audio streams into a final mp4 file. The download link is below:
Download ffmpeg

Step 4

At this stage, you should have two zip archives downloaded on your PC. Now, extract ffmpeg.zip somewhere on your disk drive. Rename the extracted folder to ffmpeg.

Step 5

Inside the ffmpeg folder, there is a bin directory. Open that directory and then extract all files from recover_mp4.zip into it. Once done, you should have all the .exe files from both archives stored in the /ffmpeg/bin folder.

Step 6

Rename your corrupted mp4 file to “bad.mp4”.
Rename your valid video file (reference) to “good.mp4”.
Then copy both the bad.mp4 and good.mp4 into the \ffmpeg\bin folder.

Step 7

Now, you need to launch the Command Prompt as an administrator. For this, click Start and type CMD in the search box. A Command Prompt option should appear. Right-click on it and choose Run as administrator. This will open the Command Prompt in a new window.

Step 8

In the Command Prompt change the working directory to where the ffmpeg.exe, recover_mp4.exe and mp4 files are.

For example, if you’ve extracted all the files, as described in the previous steps to the following directory: C:\ffmpeg\bin

Then you would have to enter the following command: cd C:\ffmpeg\bin

Step 9

Copy the following command into the Command Prompt and press enter:

recover_mp4.exe good.mp4 --analyze

What will this command do?

  • recover_mp4.exe – executes (calls) the video recovery app
  • good.mp4 – specifies a path to the refence video needed for the recovery app
  • --analyze – instructs the tool to extract the needed data from the reference file

Step 10

Once the processing is done, you will get a message containing two commands. First one is to fix the missing metadata. And the second one is to build the resulting video and audio stream into a final mp4 file.

At this stage we recommend that you copy the second command to a text document, so that you can run it later.

Now, run the first command in the Command Prompt (just copy/paste it and hit Enter). The command should look the following way:

recover_mp4.exe bad.mp4 recovered.h264 recovered.aac

What will this command do?

  • recover_mp4.exe – executes (calls) the video recovery app
  • bad.mp4 – specifies a path to the corrupted mp4 file
  • recovered.h264 – specifies the output filename for the video stream of the fixed file
  • recovered.aac – specifies the output filename for the audio stream of the fixed file

Step 11

Now you need to merge the resulting video and audio streams into a final valid mp4 file. For this, run the command you saved in a text document previously. The command should look the following way:

ffmpeg.exe -r 30 -i recovered.h264 -i recovered.aac -bsf:a aac_adtstoasc -c:v copy -c:a copy recovered.mp4

Essentially, this command will call the ffmpeg tool to merge the streams. The final mp4 file will be saved into the same folder (C:\ffmpeg\bin), titled recovered.mp4.

The mp4 file is fixed now! You can play it in your favorite media player.

Please note that the above commands may differ depending on the paths you used to extract the ffmpeg and recover_mp4 tools to. If this is the case, be sure to follow the instructions from the Command Prompt.

Also, please note that we do not provide support for recover_mp4 users, since this is a free tool.

Also, if you’re stuck with the Command Prompt or can’t repair your mp4 file for any reason, we encourage you to try Method 2, which is a much easier process.

Method 2

Lately we’ve been receiving lots of requests from Mac users and those who are not comfortable with all that stuff in the Windows Command Prompt for another version of the mp4 recovery tool that is easier to use and can be run across different platforms.

You asked – we did it!

With our online mp4 recovery service, you can now fix mp4 files regardless of the platform you are using (Windows, Mac, Linux, Android, iOS, etc.) easily and much more quickly.

So, here we go:

Step 1

Register a free account at Restore.Media

Registration is free and you can repair/preview the resulting file for free too. However, please note that to download the fixed mp4 file, you will need to pay a small fee.

Step 2

Once you’re in, click Get started

Step 3

Type in a short description of the mp4 video you’re about to fix. This could be something like “Wedding”, “Interview”, “Cucumber cat”, or just “123” – anything meaningful for you.

Now, choose the camera or device model used to record the corrupted mp4 file. If you can’t find your camera model in the list, simply type in one manually. And if you don’t know what camera was used to record the mp4 file, simply choose Generic .mp4 file (H.264/AVC).

mp4 video description

Step 4

Upload a reference mp4 file.

This should be a valid video file recorded with the same camera and settings (video resolution, frame rate, bit rate, etc.) as the corrupted one.

The best option here is to use any video you shot on the camera with the same settings just before the corrupted one. Alternatively, you can upload such a video from your archive, or record a new one. A video of around 5 minutes and 100MB should be enough.

Again, the key point here is that the reference video must be shot with the same camera and the same settings as the corrupted mp4 file. Restore.Media will use the data from the reference video to fix the corrupted file.

Step 5

Review details about the uploaded reference file and procced to the next step.

Step 6

Create a recovery task. Feel free to name the task whatever would make sense for you.

create a recovery task

Step 7

Now, upload your corrupted mp4 file and wait until Restore.Media completes the recovery. The time it takes to fix a video depends on the file size and varies from a few seconds up to 30 minutes.

Step 8

Once finished, you will be presented with a few screenshots taken from the fixed mp4 file along with a video preview. The screenshots will be in the original resolution, while the preview video will be in low resolution just so you could check if it’s actually repaired.

If you’re satisfied with the results, proceed to download your fixed mp4 file in the original resolution. If the video wasn’t repaired properly, just follow the instructions to try to recover it with other settings.

fix corrupted mp4 files

If you’ve tried different settings, but your mp4 video hasn’t been fixed, we suggest to send it to us for manual recovery. Just choose an appropriate option in your Restore.Media account, or drop us a line.

Chapter 3:
Recovering your deleted MP4 video files

Now, this is a tough one. In this section we’ll try to help those of you who have:

  • Accidentally deleted an mp4 file from an SD card or other storage media
  • Run a quick format of the memory card with the mp4 file stored on it

The chances of successful video recovery in these cases depend on how much your mp4 file is fragmented and whether you’ve recorded anything over the deleted file.

The Problem

File fragmentation occurs due to the way most of the file systems operate. Every storage device, be it a flash memory card or an HDD, is divided into small blocks. When writing a file to a storage, its file system splits the file into small chunks that fit into the blocks. However, free space blocks where the file chunks can be written to are not always aligned continuously on the storage media. It’s quite a common case when free space blocks lay in between some other files you’ve written on the disk earlier. So, the file system fills in all those free space gaps with the new video you’re recording at the moment.

As a result, chunks of your mp4 video file may be scattered across the storage. Sometimes there are as many as hundreds or even thousands of file chunks, depending on how fragmented the storage is.

When you delete a file or do a quick format of the storage media, the file system doesn’t actually delete the file, but removes indices that point to where all the chunks of that particular file are located on the storage.

To recover such a fragmented mp4 video file, one would need to analyze the whole storage media to gather all the file’s parts and then combine them cluster by cluster into a single video file.

PRO TIP

Do a quick format of your memory card prior to shooting important footage. This will ensure there is no junk data left on the card and new video files will be written into continuous blocks followed one by one, rather than scattered across the storage.

So far, we’re not aware of any software that could recover such fragmented video files accurately. But…

Solution

Step 1

If you’ve accidentally deleted an mp4 file, or quick-formatted your memory card, first thing you should do is take the memory card out of the camera and lock it to prevent any new data being written on it. Remember – the less modifications you do on the memory card, the higher the chances to recover your mp4 file.

Also, please note that if you deleted the mp4 file from your HDD storage, unfortunately, chances for its recovery are quite low. And it’s almost certainly impossible to recover deleted video files from an SSD drive.

Step 2

Now, create a backup image of the whole memory card. Please note that file format must be .img not .iso. You can use any appropriate software for this, for example USB Image Tool.

Step 3

Upload the image file to a file sharing service, such as Google Drive and email us a link to it. Our video engineers will analyze the image of your memory card and will try to recover the video file for you.

___________

We hope this guide helped you to fix your corrupted mp4 file. If not, please email us and our engineers will try to fix the video for you.

Happy recovering!