Repairing Corrupt DJI Video Files

Sometimes, if you accidentally power off your DJI quadcopter (Phantom, Mavic, Spark, or Inspire) before stopping video recording, you'll be left with a file that's corrupt, and cannot be played.

The user manual advises: "Keep or place the Micro-SD card back into the camera. Power cycle the camera and wait about 30 seconds for the video file to be restored." This often works, but sometimes you'll still be left with a corrupt file.

This page explains the problem, and provides software that can be used to repair such a file.

The problem

This section assumes some knowledge of the MP4 file format. If you're interested only in the software for repairing corrupt video files, you can skip this section.

Three basic kinds of corrupt file seem to be possible.

  1. Often, the corrupt video file looks like a proper MP4-format file; it begins with 'ftyp' and 'moov' atoms, followed by a 'mdat' ('movie data') atom. Normally, this 'mdat' atom would contain raw video data (H.264 NAL units). In a corrupt file, however, the 'mdat' atom instead contains new 'ftyp', 'moov', and 'mdat' atoms. These new atoms make up a valid MP4 video file!

    Therefore, the file can be repaired simply by skipping over the initial 'ftyp' and 'moov' atoms, and the header for the 'mdat' atom, and copying the remaining data into a new file.

  2. Another type of corrupt file is also possible (especially after a crash). In this case, the file does not contain any MP4-format data at all. Instead, the file consists only of a sequence of raw H.264 NAL units, each preceded by a 4-byte size field. (The first of these NAL units has a size of 2 bytes.)

    In this case, we can repair the file, but the result will be a ".h264"-format file, not a MP4-format file. The repaired file will be playable by the VLC media player, but might not be playable by other media players or video editors. (The file can, however, be converted (transcoded) to a MP4-format file using software such as the "MiroVideoConverter, or converted (copied) to a MP4-format file using "ffmpeg -c copy".)

  3. Another possibility is that the corrupt video file begins as a normal MP4-format file; it begins with 'ftyp' and 'moov' atoms, followed by a 'mdat' ('movie data') atom that contains raw video data. However, the tail of the file - following the 'mdat' data - can be incorrect, perhaps because the file was not 'finalized' properly. In this case, because the file contains raw video data (inside the 'mdat' atom), we can repair it just like the previous case - resulting in a '.h264'-format file.

Software for repairing a corrupt video file

The (command-line) application "djifix" will repair a corrupt DJI video file. Note that this software is intended only for repairing a corrupt video file that was generated by the DJI Phantom, Mavic, Spark, or Inspire quadcopter (or a DJI Osmo camera); it is not general-purpose software for repairing any video file. Note also that video file must be the original file that came from your quadcopter's SD card; not a file that was generated by some other 'repair' software.

Pre-built application binaries

For Mac OS X (64-bit)

  1. Download the file "djifix", and move it to your "Movies" folder.
  2. Also move the file that you want to repair into your "Movies" folder.
  3. Run the "Terminal" application (which you'll find in the "Utilities" folder, inside the "Applications" folder), then, in a Terminal window, type (on separate lines):
            cd Movies
            chmod +x djifix
            ./djifix name-of-video-file-to-repair-including-any-.MP4-or-.MOV-filename-suffix

For Windows (32-bit)

  1. Download the file "djifix.exe", and move it to the same folder as the file that you want to repair.
  2. Run the Windows "Cmd" application (i.e., the command shell), and use the "cd" command to change to the folder that contains "djifix.exe" and the file that you want to repair.
  3. In the command shell, type:
            djifix name-of-video-file-to-repair-including-any-.MP4-or-.MOV-filename-suffix

Source code

(Current version: 2017-08-29)

If you have software development tools (a C compiler), you can compile the C program "djifix.c" (released under the GNU GPL).

To build the program, download "djifix.c", and run (from a terminal or command window):

       cc -O -o djifix djifix.c
Then run:
        djifix name-of-video-file-to-repair-including-any-.MP4-or-.MOV-filename-suffix

If this program didn't work

If you have a file that this "djifix" software cannot repair, then please put it online and send the URL in an email to "djifix(at)". (Note: please do not 'zip' the file before uploading it; video files are already compressed, and do not need to be 'zip'ped.) We'll take a look at your file, and see whether the software can be updated to repair it.

Note, however: Please first check the size of your video file. If your video file is very small - i.e., less than 10 MBytes in size - then it would contain only a fraction of a second of video. It's not worth trying to repair.

Note also that we cannot provide one-on-one assistance for this software 'for free'. If you do not want to run the "djifix" software yourself (or do not know how to do so), then we would be happy to look at your file and repair it for you; once again, please put it online and send the URL in an email to "djifix(at)". For this, we will charge a fee - but the fee will be refunded in full if your file turns out to be one that the "djifix" software cannot repair.

We can also - as a service, on request - convert a repaired ".h264"-format file (playable by VLC) into a ".MP4"-format file that's playable by other media players. (For this, we also charge a fee.)

Frequently-asked questions (FAQ)

  1. The repaired video is missing the 'crash' at the very end. I want to see this. Can you recover this?

    Unfortunately not. The "dijfix" software recovers all of the video that it finds in a file. However, the last few seconds of video might not have been written to the file - especially if the power to the camera was disconnected suddenly (e.g. during a crash). Apparently the camera+encoder buffers the last few seconds of video in volatile RAM before writing it to the (non-volatile) Flash storage.)
  2. I ran the software, and it produced a 'repaired' file, but this file does not play. What's the problem?

    If the 'repaired' file has a filename that ends with ".h264", then this file cannot be played by many media players. However, the VLC Media Player should be able to play the file. If, however, it cannot, then it's probably because you chose an incorrect video format code when the "djifix" software asked you to enter the video format. Try running "djifix" again, this time entering a different video format code when prompted. If necessary, try each of the possible format codes, in turn, until you find the one that works.

    If, however, the 'repaired' file has a filename that ends with ".mp4", but cannot be played, then try running "djifix" a second time, this time on the 'repaired' file. This time, you will get a ".h264" file that can be played by VLC.

  3. The "djifix" software produced a ".h264" file. How can I convert this to a ".mp4" file that can be played by any media player?

    I usually use "ffmpeg", and run:
            ffmpeg -i DJI_XYZW-repaired.h264 -c copy DJI_XYZW-repaired.mp4
    (Replace "DJI_XYZW" with the name of your file.)

    Alternatively (if you're not familiar with "ffmpeg"), you can use the "MiroVideoConverter"; however, this will transcode the video (rather than copying it directly), so will lose a little video quality.

  4. My video file was recorded in a format that "djifix" does not support. Can you update the software to support this format?

    Perhaps. To do this, we will need a short (working) example movie that was recorded in this format. This working example movie can be very short; just a few seconds long would be OK. Please put it online, and include the URL in an email to "djifix(at)".
  5. I ran the software, but it told me that the file "appears to contain nothing but zeros or 0xFF! We cannot repair this file!". What can I do about this?

    Unfortunately, nothing. The software means what it says. Your file (for some reason) contains nothing but '0' bits (or nothing but '1' bits). Obviously, it cannot be repaired. (Imagine that you were given a book that contained pages that were all blank, or all black; obviously, you could not expect to 'repair' it.)
  6. I ran your software to repair my file, but when I played the repaired file with the VLC media player, the video was very jerky. What's the problem?

    You may be running an old version of VLC. Make sure that you download the latest version of VLC; available from
  7. Can this software repair corrupted movies recorded by a DJI Osmo camera?

    Perhaps. However, the software will recover only the video track; not the audio - so the repaired file will be video-only.
  8. I'm on a Mac. When I tried running the pre-built "djifix" Mac OS X application binary, I got an "Illegal instruction" error. What's the problem?

    You may be running an old version of Mac OS X. If you upgrade, you should be able to run the "djifix" application binary. (Alternatively, if you have "Xcode" installed, you can build the application from source code, as described above.)

If you've found this software useful, please

what your repaired video(s) were worth to you.

Copyright Live Networks, Inc. All Rights Reserved
"djifix" is a trademark of Live Networks, Inc.