During filming of off-road piano improvisations in New Zealand a Phantom 4 drone crashed in the flight, the last video is corrupted. Here's how we fixed it:
DJI_0065.mov
- corruptDJI_0065.mov
- OK
Let's compare the metadata:
$ ffmpeg -i DJI_0065.mov
[...]
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8aa9801000] moov atom not found
DJI_0065.MOV: Invalid data found when processing input
Correct file:
$ ffmpeg -i DJI_0060.mov
[...]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'DJI_0060.MOV':
Metadata:
major_brand : qt
minor_version : 538182144
compatible_brands: qt
creation_time : 2017-05-10 16:20:49
location : -44.592137+168.912571+3.000
location-{ : -44.592137+168.912571+3.000
comment : 0.9.138M
Duration: 00:00:28.99, start: 0.000000, bitrate: 59661 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 4096x2160 [SAR 1:1 DAR 256:135], 59658 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2017-05-10 16:20:49
handler_name : DJI.AVC
encoder : Dji AVC encoder
Let's use a tool called djifix exactly for this purpose. Download a binary (OSX):
$ wget http://djifix.live555.com/macosx/djifix -O djifix && chmod +x djifix
...or compile it from source:
$ wget http://djifix.live555.com/djifix.c -O djifix.c && cc -O -o djifix djifix.c
Then let's try to fix the video. It asks for the video resolution and fps. In our case it was 4096x2160, 23.98, ie. 2160p/24 fps -> entery type 2. Then it produces another file DJI_0065-repaired.h264, which is some raw.
$ ./djifix DJI_0065.mov
./djifix, version 2017-04-24; Copyright (c) 2014-2017 Live Networks, Inc. All rights reserved.
The latest version of this software is available at http://djifix.live555.com/
Saw initial 'ftyp'.
Didn't see a 'moov' atom.
Saw 'mdat'.
Didn't see a 'ftyp' atom inside the 'mdat' data.
Looking for 0x00000002...
Found 0x00000002 (at file position 0x28)
We can repair this file, but the result will be a '.h264' file (playable by the VLC media player), not a '.mp4' file.
First, however, we need to know which video format was used. Enter this now.
If the video format was 2160p, 30fps: Type 0, then the "Return" key.
If the video format was 2160p, 25fps: Type 1, then the "Return" key.
If the video format was 2160p, 24fps: Type 2, then the "Return" key.
If the video format was 1530p, 30fps: Type 3, then the "Return" key.
If the video format was 1530p, 24fps: Type 4, then the "Return" key.
If the video format was 1520p, 30fps: Type 5, then the "Return" key.
If the video format was 1520p, 25fps: Type 6, then the "Return" key.
If the video format was 1520p, 24fps: Type 7, then the "Return" key.
If the video format was 1080p, 60fps: Type 8, then the "Return" key.
If the video format was 1080i, 60fps: Type 9, then the "Return" key.
If the video format was 1080p, 50fps: Type A, then the "Return" key.
If the video format was 1080p, 30fps: Type B, then the "Return" key.
If the video format was 1080p, 25fps: Type C, then the "Return" key.
If the video format was 1080p, 24fps: Type D, then the "Return" key.
If the video format was 720p, 60fps: Type E, then the "Return" key.
If the video format was 720p, 48fps: Type F, then the "Return" key.
If the video format was 720p, 30fps: Type G, then the "Return" key.
If the video format was 720p, 25fps: Type H, then the "Return" key.
If the video format was 480p, 30fps: Type I, then the "Return" key.
(If you are unsure which video format was used, then guess as follows:
If your file was from a Phantom 2 Vision+: Type B, then the "Return" key.
If your file was from an Inspire: Type 2, then the "Return" key.
If the resulting file is unplayable by VLC, then you may have guessed the wrong format;
try again with another format.)
If you know for sure that your video format was *not* one of the ones listed above, then please email "[email protected]", and we'll try to update the software to support your video format.
2
Repairing the file (please wait)......done
Repaired file is "DJI_0065-repaired.h264"
This file can be played by the VLC media player (available at <http://www.videolan.org/vlc/>)
The output is some strange container with extension h264
:
$ file DJI_0065-repaired.h264
DJI_0065-repaired.h264: JVT NAL sequence, H.264 video @ L 51
So let's convert that into some common container (MP4):
$ ffmpeg -i DJI_0065-repaired.h264 -c copy DJI_0065-repaired.mp4
Now it's possible to open the video and ... it works!
The only remaining problem was it produced a file with 2x fps (48 instead of 24), but that can be then adjusted in some video cutting software.
After inspecting the video, we can see the footage almost up to the point when the drone crashed. Unfortunately it stops around 3 meters above ground the the crash itself it not visible. So still we have no clue what happened. On the ground there was the body, the camera and a broken plastic part of the gimball.
Thanks for this, worked perfectly for me! For the last step use
$ ffmpeg -framerate 24 -i DJI_0065-repaired.h264 -c copy DJI_0065-repaired.mp4
to fix the frame rate issue.