TehnoBlog.org

Video Repair Guide – Corrupted MP4 / AVI / H264 / H265 File Fix

Video Repair Guide - Broken Film Strip

Article Updated: 14 Feb 2022

HOW TO REPAIR UNPLAYABLE VIDEO FILES RECORDED WITH YOUR PHONE, DRONE OR DIGITAL CAMERA?

Sometimes, your phone’s recording app may become unresponsive and crash or your phone’s/camera’s/drone’s battery can become dead and abruptly interrupt recording process. In those cases, recordings will NOT be finalized and they’ll refuse to play in any app (phone or desktop) with example messages: “unsupported video format”, “unrecognized file format”, “file with 0 length”, “cannot render file” etc. Additionally, if you accidentally deleted some videos from your computer or phone, and later used tools such as Recuva, GetDataBack, PC Tools File Recovery and so on to bring them back, just to later discover that the files are useless and unplayable, you should still have a hope – because additional recovery step may be required until full recovery success!

Watch Video Tutorial

Note: download links in the video are all expired, please check updated links in the video description, pinned youtube comment or further below.

There are many different APPs and DESKTOP TOOLS on the market but they are usually NOT FREE! To name just a few most popular:

⚠️ Recommended Reading

NEW FREE VIDEO REPAIR TOOL & TUTORIAL

There’s another free video repair tool that you should definitely try! It has a graphical interface and you can repair your videos in just a few simple clicks!

▶️ Read here!

Sometimes, even those commercial apps CANNOT fix your videos!

IMPORTANT NOTE

Remember: the less modifications you do on your storage media that holds damaged video file(s), the higher the chance for recovery! For instance, if you accidentally deleted your videos on a file system level (e.g. with File Manager or Media Player) and then used Recuva / Get Data Back / File Recovery / Various Undelete apps to restore the files and then you find out they are not playable, there is a very low chance this procedure will actually help you in that case!

Because, despite “successful” file recovery reported by the undelete/restore apps, videos may still miss important headers which hold crucial recovery information and also could be already overwritten by other files in the middle of the stream, which will make the recovery procedure with video recovery tools virtually impossible!

In those cases, where files are unrecoverable by recovery tools, the only chance is to hire some digital forensics expert and try to salvage individual frames (if any), and do frame-by-frame video reconstruction. There are no publicly available tools (that I’m aware of) that can do this for (arbitrary) video codec/format.

Also, read user comments below about specialized file recovery tools, that also take fragmentation into account and possibility of potential recovery in that case.

STEP BY STEP TUTORIAL

First, you will need another GOOD video that will serve as a reference for repair procedure. This reference video should be recorded on the same device (hardware) as the broken video that you’re trying to fix with the same framerate + bitrate (quality) and codec settings, including device tilt / orientation (as some users reported in the comments). If you don’t have it, make/record one, usually couple of seconds is all that you need, but in some cases you should use loner reference videos (at least 30-60 seconds in length), in order to properly construct frame structure and have a higher chance in repairing both video and audio parts in the broken file(s).

DO NOT record this reference/example footage on the same memory card / storage media that holds your broken file! If your device is broken or lost, you can use a video from your archive (assuming that you have saved them). If you don’t have a reference video, this guide cannot help you in that unfortunate case :(

Then follow below steps to repair it:

STEP 1

Download recover_mp4 Video Repair Tool:
recover_mp4_192.zip

STEP 2

Download ffmpeg Tool:
Use new GitHub builds repository (only 64-bit versions are available)

Quick direct .zip archive ffmpeg download links:

  1. ffmpeg-2020-12-15-git-32586a42da-essentials_build.zip (newer 64-bit)
  2. ffmpeg-tools-2020-10-14-git-6bdfea8d4b.zip (older 64-bit)

Alternatively, if you need even older ffmpeg versions from 2019 (in case of codec compatibility), you can get them from our server:

  1. ffmpeg-20190212-a84af76-win32-static.zip (2019-Feb 32-bit version) [ VirusTotal Report ]
  2. ffmpeg-20190212-a84af76-win64-static.zip (2019-Feb 64-bit version) [ VirusTotal Report ]

STEP 3

Extract ffmpeg.zip, then extract recover_mp4.zip inside /ffmpeg/bin/ directory so that all the .exe files are in the same folder! Also, for simplicity, rename ffmpeg’s directory to a shorter name (useful for next steps).

STEP 4

Copy your “good.mp4” reference file into SAME directory with .exe files as described in STEP 3
Copy your “bad.mp4” damaged file to be repaired into SAME directory with .exe files as described in STEP 3

STEP 5 

(Windows 10)
Search > type CMD > then right click on COMMAND PROMPT to RUN AS ADMINISTRATOR and confirm with YES

STEP 6

Change your working directory inside COMMAND PROMPT to where your ffmpeg.exe and recover_mp4.exe and .mp4 video files are (see step 3)

STEP 7

Execute following command inside COMMAND PROMPT + press ENTER

recover_mp4.exe good.mp4 --analyze

COMMAND EXPLAINED / BREAK-DOWN
recover_mp4.exe | means that we are executing/calling our recovery program/app
good.mp4 | we pass as a parameter name/path of the good reference video file (since it is in the same directory as recover_mp4.exe tool then we simply just type the filename+extension)
–analyze | we instruct recovery tool to analyze damaged video file and try to figure it out with it’s magic! :)

STEP 8

After analysis is completed, run 1st command you received from recover_mp4, for example:

recover_mp4.exe bad.mp4 result.h264 result.aac

Note: this is generic case without any specific options (switches).

COMMAND EXPLAINED / BREAK-DOWN
recover_mp4.exe | means that we are executing/calling our recovery program/app
bad.mp4 | we pass as a parameter name/path of the damaged video file (since it is in the same directory as recover_mp4.exe tool then we simply just type the filename+extension)
result.h264 | we specify the output filename+extension of RAW video portion of recovered file
result.aac | we specify the output filename+extension of audio portion of recovered file

NOTE: above are only example commands, they will be different for each video format – follow instructions you receive from recover_mp4 tool!

STEP 9

Then run 2nd command:

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

In case you receive an error, but your result.h264 file is actually playable, you can try the most basic ffmpeg command first, ignoring audio part and see if that works:

ffmpeg.exe -r 30 -i result.h264 -c:v copy recovered.mp4

If above command does not work either (you may receive a lot of errors, but the end result should be fine) you can try re-encoding output with following command:

ffmpeg.exe -r 30 -i result.h264 recovered.mp4

Later on you can try to mix audio part in dedicated video editor such as Adobe Premiere, Sony Vegas, or VirtualDub.

NOTE: above are only example commands, they will be different for each video format – follow instructions you receive from recover_mp4 tool!

NOTE: ffmpeg also supports fractions for frame rate parameter if your video uses NTSC ‘irregular’ value like 29.97 it is better to use 3000/1001 instead, as that is the actual correct value without common time code rounding.

DONE!

Looks too complicated? Watch the 5-minute video version instead.

Your video should be fully recovered and playable in ANY video player :)

RECOVERY COMMANDS & SWITCHES (OPTIONS)

NOTE: these commands were taken from original slydiman.me website. You can also find limited examples in the readme .txt file inside recover_mp4.zip archive! Usually, you should follow instructions from the recovery tool itself, but sometimes you may have to experiment with other options. It’s a trial & error process, really.

Example Usage: recover_mp4 good_similar.mp4 --analyze recover_mp4 raw.mp4 out_corrupted.mp4 --clean_amba [<hex> [<dec>]] recover_mp4 raw.mp4 out_corrupted.mp4 --clean_xiaoyi [<hex> [<dec>]] recover_mp4 raw.mp4 out_corrupted.mp4 --clean_dji [<hex> [<dec>]] recover_mp4 corrupted.mp4 {out_video.h264 | out_video.hevc | out_video.mov | --none} {out_audio.aac | out_audio.wav | out_audio.mp3 | out_audio.raw | --none} [options] recover_mp4 raw.mxf out.raw --mxf <hex>

NOTE: Please note that not ALL options may be / are available in last published free version!

Options: --verbose --start read from position (ignore mdat atom) --end <hex> end position (ignore mdat atom). Specify 0 for EOF --align <hex> default 1. Use --drim5 --align 10 for Samsung Gear 360. --nohdr try to extract SPS and PPS from the stream --forcehdr for GoPro 4+ --avcidrmax <hex> ignore AVC NAL units (IDR) with the size above than <hex> bytes --avcxmax <hex> ignore AVC NAL units (non IDR) with the size above than <hex> bytes --noavcidrmin --noavcxmin --nocheck simple checking --noidr do not wait first IDR --nodecaac do not decode AAC --aaclong --aacmin <hex> --pcmmin <hex> --pcmfix <hex> --audio assume audio only, do not check any video templates --prores Apple ProRes video --custom experimental --adobe experimental --sony2 experimental --novatek2 experimental --wowza2 experimental --gopro6.avc use GoPro6 AVC templates --gopro6.hvc use GoPro6 HEVC templates --gopro5 use GoPro5 templates --gopro4 use GoPro4 templates --gopro_session use GoPro Session templates --ambarella use Ambarella templates --garmin use Garmin VIRB Ultra 30 templates --xiaoyi use Xiaomi YI action camera templates --yicarcam use Xiaomi YI CarCam templates --novatek use car DVR templates based on Novatek (DV turnkey, Street Guardian, etc.) --pitta use car DVR templates based on PittaSoft --lav use Lav/ffmpeg templates --vlc use VLC templates --jvc use JVC GY-HM200 templates --mainconcept use Mainconcept templates --qt use QuickTime templates (default for MOV files) --panasonic use Panasonic DMC-G7, DMC-GX80, DMC-G85, DMC-GH4, DC-GH5, AW-HE40 templates --panasonic_hc use Panasonic HC-X1000 templates --panasonic_ag use Panasonic AG-DVX200 templates --sony use SONY A7S [Mark II], AX1E, NX5R, A6000, HDR-CX405, HDR-CX625 templates --drim use DRIMeIII templates (Samsung NX1000 camcorder) --drim5 use DRIMeV HEVC/H.265 templates (Samsung NX1/NX500 camcorder) --gear360 use Samsung gear360 --galaxy use Samsung Galaxy templates --android81 use Android 8.1 templates --iphone4 use iPhone4 templates --filmic61 use iPhone Filmic 6.1.2 templates --filmic63 use iPhone Filmic 6.3.x templates --filmic65 use iPhone Filmic 6.5.x templates --lumia use Lumia templates --eos use Canon EOS 5D Mark II, 60D, 7D, 550D templates --eos3 use Canon EOS 5D Mark III, 5DS, 7D Mark II (PCM), 100D templates --eos4 use Canon EOS 5D Mark IV templates (default align 8) --canon use Canon SX, Legria, Vixia, EOS 80D, 7D Mark II (AAC) templates --nikon use Nikon D750, D3300 templates --zcam use Z Cam --wowza use Wowza templates --vmix use vMix templates --obs use Open Broadcaster Software --blackmagic use BlackMagic templates --avermedia use AVerMedia Live Gamer Portable C875 templates --tomtom use TomTom Bandit Action Camera templates --aim use Aim SmartyCam HD templates --corvette use Corvette Performance Data Recorder templates --icat use iCatch templates --cgo3 use cgo3 templates --dji.avc use DJI.AVC Phantom (H.264) templates --dji.hvc use DJI.HVC Phantom (H.265) templates --hevc use generic HEVC/H.265 templates --ext use generic templates for any other camcorder or smartphone, etc. (default for MP4 files)

FREQUENTLY ASKED QUESTIONS (FAQ) / TROUBLESHOOTING TIPS

The following section contains various help tips, Q&As adapted from YouTube comments, to additionally explain certain steps or clarify why this method sometimes doesn’t work.

Question: I cannot run/execute recover_mp4.exe app. It just opens and closes immediatly… I’m working on Windows 10. Do you have any solution please?

Answer: You cannot execute it like an ordinary program :) Watch the video tutorial carefully, you must first run Command Prompt (terminal) and call recover_mp4.exe from a command line. Sorry, this tool does not come with a GUI (Graphical User Interface).

 

Question: I am totally stuck with Command Prompt part, how do I change my “working directory”? My bin folder address is this “C:\Users\xx\Downloads\ffp\bin”.

Answer: First, the reason why you should use root D:\ or some other letter drive (if possible, that is — if you have more than 1 disk or virtual partition on your PC) as shown in our video is because Windows might prevent you to read/write data on C:\ drive (but, if you run Command Prompt tool as Administrator, this should not be a problem). Anyway, another benefit of working in the root of the drive is because the paths will be much shorter, and tutorial simpler to follow.

When you run Windows’s Command Prompt tool for the very first time, your path will be set to:

C:\WINDOWS\system32>

You need to go back to the “root” simply by typing this (yes, it is not a mistake — you need to repeat command 2 times!):

cd.. [ENTER]
cd.. [ENTER]

literally: type letter C, then type letter D, then type 2 dots (all glued, no space!) and press [ENTER] key on your keyboard. “cd” command is a short for “change directory” in Command Prompt.

Alternatively, you can do it directly with a single command:

cd C:\ [ENTER]

This will directly bring you to your root path of C drive.

Next, you need to change your location to the one you have mentioned in your comment. Again, we will use “cd” command:

cd C:\Users\xx\Downloads\ffp\bin [ENTER]

NOTE: replace “xx” above with your actual PC user name!
So, after you execute the above command, the path in Command Prompt will look like this:

C:\Users\xx\Downloads\ffp\bin>

Now, you can use command:

dir [ENTER]

The above dir command will list your files and directories, along file sizes in bytes, and you should see all of them in the list (e.g. ffmpeg.exe, recover_mp4.exe, your good.mp4 and bad.mp4 files and so on). From there, you should follow up tutorial exactly as in the video.

If you are keeping your videos in a different drive/partition (like in our video tutorial), in order to change to another drive/partition, you don’t type “cd” in front of it, just the drive letter plus semicolon : symbol, like this:

D: [ENTER]
E: [ENTER]
F: [ENTER]

 

Question: Is it possible to use this method for repairing a video of a recorded game / screen capture from my computer or phone? Is it possible to use this method for repairing a video from some obscure/rare/unknown codec/hardware/format?

Answer: Thing is, it might work, but most probably it won’t. Read comments from some users below (or on YouTube), some users were successful! If you use/used standard mp4 audio-video codec, then your chances are pretty high. On the other hand, if you used a custom/proprietary codec for screen recording, then you might be out of luck.

It is probably possible to repair your custom video, but an expert in audio/video formats and codecs needs to analyze it manually first, to examine the inner structure of the bits/frames/etc. In case of screen recordings — because of so many variants in codecs and lack of industry standard — this may not be optimal nor easy to do. In this case, it just might be (often is) easier to re-record everything again, to save you from the repair trouble.

On the other hand, if you recorded a live-action video with hardware camera (e.g. your holiday shenanigans), which are non-repeatable in nature, it is often worth the trouble of restoration procedure. Be aware/keep in mind that custom video repairs may cost you a lot of $$$!

 

Question: Is it possible to repair a video without a reference?

Answer: No, you must provide a good reference file for this repair method.

 

Question: Can I send you my broken video to you for repair?

Answer: No. We are not a professional video repair service! We wrote this article in good will, with the best of hope that it will help someone out there in the similar situation. We neither create/develop video repair software tools, nor provide repair service for free or otherwise.

 

Question: After successful analysis step of good.mp4 reference video, I received an error messages in second and third step about file being impossible to repair because it is filled with zeros. What can I do?

Answer: Unfortunately, this file is, indeed, non-repairable because there is NOTHING to repair! If you open your bad.mp4 video file with a HEX Editor (low-level file utility that reads all files in their true binary formats), you will see that except maybe the header, entire file is filled with 0 bytes. This means that either there was a storage recovery error, copy-paste error, and that the actual file content is permanently lost on the storage medium. Your only hope, if the file was previously accidentally deleted, is to use another scan and recovery tool, that might recover it properly.

Otherwise, it is lost.

 

Question: Can’t find a bin folder after extracting ffmpeg! Did they remove it? Also, how do I extract tar.bz2 file?

Answer: Please make sure you selected Windows ffmpeg versions (you most likely downloaded a Linux one). It is still there, it would not make sense to remove binary exe. Recovery MP4 tool runs in Windows environment only. Also, all Windows versions come in standard .zip archive format which can be automatically extracted without any additional software. If you have a different file extension, then you most probably have the wrong operating system ffmpeg version. Check back article instructions above for current ffmpeg download links.

 

Question: In ffmpeg step I receive an error about result.h264 or result.aac – what can I do?

Answer: Can you play the result.h264 and/or result.aac file(s) in some video (audio) player from recovery step (command)? At this stage, the results must be already playable, at least on desktop/laptop computer with some universal media/stream player like VLC or MPC-HC. If they are playable, then you can try to combine them together in some video editor like Adobe Premiere, Sony Vegas etc. If not, then the recovery tool probably didn’t do the recovery task properly, messed something up and ffmpeg cannot mux (combine) them. Newer version of recovery tool, which is not publicly available (read further below), could help in that case, but it may also indicate that the format is not supported for recovery or that video became fragmented and lost important pieces.

 

Question: It worked! I have my video back! But I can’t get audio for some reason. Any suggestions?

Answer: Audio can be tricky to recover in some cases. Check above available switches (–options) and .txt readme file inside recover_mp4.zip archive to see all available commands and experiment with them.

 

Question: I received an error / warning during 2nd command (ffmpeg mux stage) about .h264 (video) and .aac (audio) parts:

[h264 @ 0000xxxx] Stream #0: not enough frames to estimate rate; consider increasing probesize | Duration: N/A | Bitrate: N/A

[aac @ 0000xxxx] Number of scalefactor bands in group (50) exceeds limit (49)

Answer: If you watched video tutorial till the end at 4:50, I received exactly the same notice regarding framerate, but the result (fixed file) was perfectly playable! In fact, result.h264 was playable already, too, as shown in the video. Ignore that error / warning and go through the end. Later, you may use MediaInfo tool to check meta data. If it refuses to play in hardware-based players (stand-alone equipment), you may need to re-encode again with some video editor.

About header and audio related errors, try to play that result.aac file in some audio player (Winamp, Foobar, MPC-HC, VLC), if you get the audio — great! You can then convert it to WAV (PCM) uncompressed format, and simply mix your audio/video later in some video editor (OpenShot, Sony Vegas, Adobe Premiere etc).

Also, try to fix it with some custom switches (options) during recovery command stage, as it may help to use pre-defined templates for specific formats (dji, gopro, panasonic, sony, apple, samsung etc.).

If not, then I am really out of ideas, only option is to try with some other video recovery app or service.

 

ALL GOOD THINGS…

(March 2018) It is not clear at this moment whether recover_mp4 tool will remain free of charge, or turn into a fully commercial web-based repair service. There are several indicators pointing into that direction:

  • version 1.x of the tool received infrequent updates in the past year (versions 1.8.x, 1.9.x)
  • version 2.x of the tool was at first available at individual requests, presumably after making a donation to the author
  • later, author started own web-based repair service powered by version 2.x, claiming greater support for some formats such as GoPro
  • web service was completely automated and free and did not require any registration at first
  • web service is now behind a login/registration wall, so the next logical step will be a fee for repairs

Of course, this is all fine and completely understandable, author was kind enough to provide excellent tool for few years completely free, but at this moment it is still not clear what will happen to the free version of the tool (it is still available for download). Older version still supports many, many hardware devices, despite slower update cycle, but newer ones might not be so lucky, if they use updated codec formats and custom optimizations.

Web-based services have some disadvantages for users, one being privacy concerns, the other being bandwidth and time requirements (it is much slower than working with local files on your PC). On the other hand, running a web-based video repair service is a very costly thing, you need to pay for a bandwidth and fast server with lots of raw CPU power. Remains to be seen…

You have been warned in case this tutorial becomes no longer current :)

THE END

(May 2018) The free recover_mp4 video repair tool is no longer available for download on author’s personal website. It is now officially replaced by the commercial web based service (as we’ve wrote above few months ago).

(November 2018) Project’s website seems to be offline.

(March 2019) Project’s website is back online with free tool again available for download. Of course, without updates. According to original page, author currently uses version 3.0, which supports even more newer formats (e.g. ProRes) and comes with other improvements.