40

I took a video from my Android phone (Sony Xperia P, if you need to know), and before I could stop recording it, the phone memory got full and the phone got hanged too. I rebooted the phone, the video was there, but I couldn't play it from any media player on Android. It's in mp4 format.

So I tried to open it on PC and Mac with different video player, like VLC, quick Time, Windows Media Player etc., but none of them can play it. I know that the video is corrupted, but I believe it's repairable, since it got more than a GB in size. Is there anything that I can try to repair the video file? The video is really important.

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
noob
  • 1,247
  • 4
  • 16
  • 25

2 Answers2

30

This is an old question, but I just ran into the same situation and I figured I would post the solution that worked for me.

When you see the message "moov atom not found", that typically means that whatever was creating the video was not able to write terminal metadata that contains information about things like the codecs used in the video and so forth. Without this "moov atom", most players will reject the video.

If you have another video that was generated by the same device, you can use the untrunc program to generate a new moov atom that will in most cases render the file playable.

You will need to compile the untrunc program yourself. I built it in an Ubuntu 12.04 docker container, and needed to install the following prerequisites to get it to build:

sudo apt-get install libavformat-dev libavcodec-dev \
  libavutil-dev libqt4-dev make g++ libz-dev
larsks
  • 4,053
  • 28
  • 36
  • It supposedly it supports files bigger then 1GB. However my input was >1GB and the output was just below 1GB and missing the end. The following tool helped to restore more video: https://github.com/bookkojot/mp4fixer – jakob-r Jan 28 '20 at 14:35
  • Your prerequisites lack something: On Ubuntu 20.04 I get `libqt4-dev` has no installation candidate. – rubo77 Jan 27 '21 at 09:05
  • But I used the docker container like described in their Readme now, and that worked fine! – rubo77 Jan 27 '21 at 09:05
  • 5
    Be advised that in case the original [ponchio/untrunc](https://github.com/ponchio/untrunc) doesn't work for you to also try the newer `logging` branch in that repository and also try this fork: [anthwlock/untrunc](https://github.com/anthwlock/untrunc) – rubo77 Jan 27 '21 at 09:18
  • I had to install yasm as well in order to compile libavformat – franzlorenzon Oct 05 '21 at 09:51
24

If you have ffmpeg, from the command-line you can try:

ffmpeg -i input.mp4 -c copy output.mp4

If the problem is just with the container, this will fix it.

If that doesn't work, please post the complete terminal message, as it could give a clue as to how to fix the file.

evilsoup
  • 13,097
  • 3
  • 59
  • 80
  • Sorry, I forgot about that video. I'll try your method tonight. Can you let me know of any link from where I can get to know how to install ffmpeg. They just give zip or tar archives. Thanks anyways – noob Jan 31 '13 at 09:32
  • @Creator - Look [here](http://ffmpeg.org/download.html), scroll down to 'Linux builds' or 'Windows builds' or 'OSX builds', depending on your OS. – evilsoup Jan 31 '13 at 14:34
  • 18
    Sorry for the late reply. This is the error I am getting while using ffmpeg command - [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f88f9018e00] moov atom not found input.mp4: Invalid data found when processing input – noob Mar 17 '13 at 20:31
  • 2
    did you ever resolve this? getting the same problem. Think it was caused by more or less the same thing too – Horse Oct 08 '14 at 16:19
  • 1
    I got the same problem and the same output. I could resolve it with this: http://grauonline.de/cms2/?page_id=5 but you have to pay for it if you want the other half of the video. Is there any other software that somebody can suggest to fix my mp4 file? – VaTo Jun 06 '15 at 05:30
  • 2
    Have you tried recover_mp4_to_h264? http://stackoverflow.com/questions/23202611/repairing-a-corrupt-mp4-video-file – Mint Sep 12 '16 at 03:37
  • As @noob said: it doesn't work. – Ken Sharp Apr 15 '17 at 21:04
  • see also: https://video.stackexchange.com/questions/18220/fix-bad-files-and-streams-with-ffmpeg-so-vlc-and-other-players-would-not-crash?newreg=d3469ba54b784618bdee40c015f75889 – awiebe Dec 01 '17 at 10:40
  • This worked for me on an .MP4 that for some reason disallowed seeking in the video player (Win10 Movies & TV). – InteXX Aug 27 '18 at 09:58
  • I get this error on Ubuntu 20.04: `avconv: command not found` – rubo77 Jan 26 '21 at 02:36
  • @rubo77 You first have to install ffmpeg with `sudo apt install ffmpeg` (if it is Ubuntu) or see here (http://ffmpeg.org/download.html) for other operating systems. – Ajith Natarajan Mar 28 '21 at 23:45
  • Ffmpeg is installed. The error is thrown by avconf – rubo77 Mar 29 '21 at 08:49