Answers.Body: <p>I recently encountered this exact problem and I was able to repair the file using <a href="http://vcg.isti.cnr.it/~ponchio/untrunc.php" rel="noreferrer">Untrunc</a>, a program created specifically to solve this problem, <a href="https://superuser.com/a/596402/83682">as suggested by sparrowt on SuperUser</a>:</p>
  
  <blockquote>
    <p>For this method you need:</p>
    
    <ul>
    <li><p>another video file which <em>isn't</em> broken</p></li>
    <li><p>a linux installation (I used Ubuntu 12.04) and basic ability to use a command line.</p></li>
    </ul>
    
    <p>This is what to do:</p>
    
    <ol>
    <li><p>Install some pre-requisite libraries with this command:</p>
    
    <p><code>sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev</code></p></li>
    <li><p>Download the source code for Untrunc from the github repo:</p>
    
    <p><code>wget https://github.com/ponchio/untrunc/archive/master.zip</code></p></li>
    <li><p>Unzip the source code:</p>
    
    <p><code>unzip master.zip</code></p></li>
    <li><p>Go into the directory where it's been unzipped:</p>
    
    <p><code>cd untrunc-master</code></p></li>
    <li><p>Compile the source code using this command (all one line):</p>
    
    <p><code>g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp
    -L/usr/local/lib -lavformat -lavcodec -lavutil</code></p>
    
    <p>(you can try skipping this step and using the ready-provided
    executable, but it didn't work for me)</p></li>
    <li><p>Then you can actually fix the video. You need both the broken video and an example working video.</p>
    
    <p>Ideally the video should be from the same camera &amp; have the same
    resolution (mine was but it might work without). Also if it is at
    least as long as the broken one (preferably roughly the same) this may
    help.</p>
    
    <p>Run this command in the folder where you have unzipped and compiled
    Untrunc but replace the /path/to/... bits with your 2 video files:</p>
    
    <p><code>./untrunc /path/to/working-video.m4v /path/to/broken-video.m4v</code></p>
    
    <p>Then it should churn away and hopefully produce a playable file
    called <code>broken-video_fixed.m4v</code></p></li>
    </ol>
    
    <p>That's it you're done!</p>
    
    <p>VLC Media Player should now be able to play the file. However it may
    be reporting the wrong length information (Untrunc tries to guess/work
    this out, but doesn't always get it right). To fix this try
    re-encoding the video through another program.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-16T19:58:39.940Z
Answers.Text: I have this error when trying to build: `track.cpp:60:32: fatal error: libavcodec/h264dec.h`
Answers.UserDisplayName: unfa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T19:13:10.417Z
Answers.Text: @unfa I have the same issue, so I've used [the port of untrunc](https://github.com/anthwlock/untrunc) made by@anthwlock which is far easier to build and install.
Answers.UserDisplayName: Gwyneth Llewelyn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-02T15:01:10.760Z
Answers.LastActivityDate: 2016-08-02T15:01:10.760Z
Answers.LastEditDate: 2017-03-20T10:18:33.487Z
Answers.UserDisplayName: Ajedi32
Answers.Body: <p><strong>Updated</strong>: this tool can now recover files from more sources.</p>
  
  <p>Try with <a href="http://slydiman.me/eng/mmedia/recover_mp4.htm" rel="nofollow">recover_mp4_to_h264</a>. It's a command line program, and will require a good reference file.</p>
  
  <p>Usage as indicated:</p>
  
  <pre><code>recover_mp4 in_good_similar.mp4 --analyze
  recover_mp4 in_corrupted.mp4 {out_video.h264 | out_video.hevc | --novideo} [out_audio.aac | out_audio.wav | out_audio.mp3 | out_audio.raw | --noaudio] [options]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-28T17:30:42.370Z
Answers.Text: I had a go with that before, it said the format wasn't supported.
Answers.UserDisplayName: username_unavailable
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T19:22:25.023Z
Answers.Text: [Restore.media](https://restore.media/), the company that makes `recover_mp4`, does not offer that download any more, and instead only repairs files online via their site (for a fee). You can still get an earlier version of that tool (legally so; Restore.media even provides the [direct link for the download](https://restore.media/blog/recover_mp4.zip)). Sadly, it's closed source, and available for Windows (32/64bits) only...
Answers.UserDisplayName: Gwyneth Llewelyn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-28T05:58:05.837Z
Answers.LastActivityDate: 2016-08-02T15:29:13.040Z
Answers.LastEditDate: 2016-08-02T15:29:13.040Z
Answers.UserDisplayName: Gyan
Answers.Body: <p>You may also, to save yourself trouble, check to see the data is even there first. The file size being 1.21 GB, does that sound correct for the time until you lost power?</p>
  
  <p>I bring this up because some programs write the data first to memory... sometimes very long large chunks of data, before actually committing it to disk. </p>
  
  <p>With an MP4, the video should play, if it has valid headers, up until the last good packet containing the correct key/i frames. </p>
  
  <p>What pops into my head, is the data may not be there, as in, it had been committed to memory, but not to disk-- I'd do a test record (factoring the time it "should be", and compare file sizes). Before you jump through hoops. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-29T15:12:41.177Z
Answers.Text: The MOOV atom, containing stream info and sample positions, is written at the time of finishing the file i.e. when all the media stream data has been committed to disk. You can have a MP4 with a MOOV atom upfront with just the stream info, which makes the file playable but not seekable. However, very few apps or devices write MP4s in this way.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-30T15:22:54.330Z
Answers.Text: Bandicam, a very popular screen capture application has an option as to how often it commits the data captured into ram to disk, which is why i mentioned it- just to check. Theres so many software applications out there. A non-seekable file can also be fixed using ffmpeg, and VLC can do it also by inserting in the proper key frames. Another example of larger cache rewrites are with AJA products, some of which wont write to disk until 60 seconds has passed.
Answers.UserDisplayName: McFlySoHigh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-04T21:52:35.393Z
Answers.Text: I tried using a piece of freemium software to see if it could be recovered, and yes the data is definitely there. The video data is at least. However like I said, I don't really want to go buying software for one video file I don't need that much.
Answers.UserDisplayName: username_unavailable
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-29T15:01:40.713Z
Answers.LastActivityDate: 2016-05-29T15:01:40.713Z
Answers.UserDisplayName: McFlySoHigh
Body: <p>I was recording an MP4 file using PlaysTV, and my computer had a power fault half-way through the recording.
  I'm sure that the file contains valid data, it's just that no media player will recognize it.</p>
  <p>To fix it I have tried Avidemux, I have tried numerous programs listed in other questions on stackexchange. And so far nothing has worked.</p>
  <p>The ffmpeg -i output is as follows:</p>
  <pre><code>  libavutil      55. 24.100 / 55. 24.100
    libavcodec     57. 43.100 / 57. 43.100
    libavformat    57. 37.100 / 57. 37.100
    libavdevice    57.  0.101 / 57.  0.101
    libavfilter     6. 46.100 /  6. 46.100
    libswscale      4.  1.100 /  4.  1.100
    libswresample   2.  0.101 /  2.  0.101
    libpostproc    54.  0.100 / 54.  0.100
  [mov,mp4,m4a,3gp,3g2,mj2 @ 000000000262d040] moov atom not found
  2016_05_27_20_08_12-ses.mp4: Invalid data found when processing input
  </code></pre>
  <p>Mediainfo output:</p>
  <pre><code>General
  Complete name                            : F:\vids\2016_05_27_20_08_12-ses.mp4
  Format                                   : MPEG-4
  Format profile                           : Base Media / Version 2
  Codec ID                                 : mp42 (mp41/isom)
  File size                                : 1.21 GiB
  </code></pre>
  <p>There are probably paid services that will fix this file for me, however since it is a (quite)large-ish file, they cost too much.</p>
  <p>Can anyone help me here?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-28T17:45:36.020Z
Comments.Text: Similar questions on superuser: https://superuser.com/q/1033251/514709 and https://superuser.com/q/417100/514709.
Comments.UserDisplayName: DaBler
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-03T07:25:27.237Z
Comments.Text: I've occasionally been successful with mplayer when ffmpeg didn't care for a file. Be that as it may, I'm not near as confident as you are that the file contains enough valid data to be of any use.
Comments.UserDisplayName: Elder Geek
Tags: <video><file-formats><software><video-recording><mp4>
Title: Corrupt MP4 [recording interrupted]
UserDisplayName: username_unavailable
ThreadText: # Corrupt MP4 [recording interrupted]
  
  (Asked by: username_0 on 2016-05-27)
  
  I was recording an MP4 file using PlaysTV, and my computer had a power fault half-way through the recording.
  I'm sure that the file contains valid data, it's just that no media player will recognize it.
  
  To fix it I have tried Avidemux, I have tried numerous programs listed in other questions on stackexchange. And so far nothing has worked.
  
  The ffmpeg -i output is as follows:
  
  ```
    libavutil      55. 24.100 / 55. 24.100
    libavcodec     57. 43.100 / 57. 43.100
    libavformat    57. 37.100 / 57. 37.100
    libavdevice    57.  0.101 / 57.  0.101
    libavfilter     6. 46.100 /  6. 46.100
    libswscale      4.  1.100 /  4.  1.100
    libswresample   2.  0.101 /  2.  0.101
    libpostproc    54.  0.100 / 54.  0.100
  [mov,mp4,m4a,3gp,3g2,mj2 @ 000000000262d040] moov atom not found
  2016_05_27_20_08_12-ses.mp4: Invalid data found when processing input
  
  ```
  
  Mediainfo output:
  
  ```
  General
  Complete name                            : F:\vids\2016_05_27_20_08_12-ses.mp4
  Format                                   : MPEG-4
  Format profile                           : Base Media / Version 2
  Codec ID                                 : mp42 (mp41/isom)
  File size                                : 1.21 GiB
  
  ```
  
  There are probably paid services that will fix this file for me, however since it is a (quite)large-ish file, they cost too much.
  
  Can anyone help me here?
  
  **Tags:** video, file-formats, software, video-recording, mp4
  
  > **Comments:**
  > **username_2**: I've occasionally been successful with mplayer when ffmpeg didn't care for a file. Be that as it may, I'm not near as confident as you are that the file contains enough valid data to be of any use.  
  > **username_1**: Similar questions on superuser: https://superuser.com/q/1033251/514709 and https://superuser.com/q/417100/514709.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2016-08-02. Score: 6
  
  I recently encountered this exact problem and I was able to repair the file using [Untrunc](http://vcg.isti.cnr.it/~ponchio/untrunc.php), a program created specifically to solve this problem, [as suggested by sparrowt on SuperUser](https://superuser.com/a/596402/83682):
  
  > For this method you need:
  >
  > * another video file which *isn't* broken
  > * a linux installation (I used Ubuntu 12.04) and basic ability to use a command line.
  >
  > This is what to do:
  >
  > 1. Install some pre-requisite libraries with this command:
  >
  >    `sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev`
  > 2. Download the source code for Untrunc from the github repo:
  >
  >    `wget https://github.com/ponchio/untrunc/archive/master.zip`
  > 3. Unzip the source code:
  >
  >    `unzip master.zip`
  > 4. Go into the directory where it's been unzipped:
  >
  >    `cd untrunc-master`
  > 5. Compile the source code using this command (all one line):
  >
  >    `g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp
  >    -L/usr/local/lib -lavformat -lavcodec -lavutil`
  >
  >    (you can try skipping this step and using the ready-provided
  >    executable, but it didn't work for me)
  > 6. Then you can actually fix the video. You need both the broken video and an example working video.
  >
  >    Ideally the video should be from the same camera & have the same
  >    resolution (mine was but it might work without). Also if it is at
  >    least as long as the broken one (preferably roughly the same) this may
  >    help.
  >
  >    Run this command in the folder where you have unzipped and compiled
  >    Untrunc but replace the /path/to/... bits with your 2 video files:
  >
  >    `./untrunc /path/to/working-video.m4v /path/to/broken-video.m4v`
  >
  >    Then it should churn away and hopefully produce a playable file
  >    called `broken-video_fixed.m4v`
  >
  > That's it you're done!
  >
  > VLC Media Player should now be able to play the file. However it may
  > be reporting the wrong length information (Untrunc tries to guess/work
  > this out, but doesn't always get it right). To fix this try
  > re-encoding the video through another program.
  
  > **Comments:**
  > **username_4**: I have this error when trying to build: `track.cpp:60:32: fatal error: libavcodec/h264dec.h`  
  > **username_5**: @username_4 I have the same issue, so I've used [the port of untrunc](https://github.com/anthwlock/untrunc) made by@anthwlock which is far easier to build and install.  
  
  ---
  
  ### Answer by username_6 on 2016-05-28. Score: 4
  
  **Updated**: this tool can now recover files from more sources.
  
  Try with [recover\_mp4\_to\_h264](http://slydiman.me/eng/mmedia/recover_mp4.htm). It's a command line program, and will require a good reference file.
  
  Usage as indicated:
  
  ```
  recover_mp4 in_good_similar.mp4 --analyze
  recover_mp4 in_corrupted.mp4 {out_video.h264 | out_video.hevc | --novideo} [out_audio.aac | out_audio.wav | out_audio.mp3 | out_audio.raw | --noaudio] [options]
  
  ```
  
  > **Comments:**
  > **username_0**: I had a go with that before, it said the format wasn't supported.  
  > **username_5**: [Restore.media](https://restore.media/), the company that makes `recover_mp4`, does not offer that download any more, and instead only repairs files online via their site (for a fee). You can still get an earlier version of that tool (legally so; Restore.media even provides the [direct link for the download](https://restore.media/blog/recover_mp4.zip)). Sadly, it's closed source, and available for Windows (32/64bits) only...  
  
  ---
  
  ### Answer by username_7 on 2016-05-29. Score: 1
  
  You may also, to save yourself trouble, check to see the data is even there first. The file size being 1.21 GB, does that sound correct for the time until you lost power?
  
  I bring this up because some programs write the data first to memory... sometimes very long large chunks of data, before actually committing it to disk.
  
  With an MP4, the video should play, if it has valid headers, up until the last good packet containing the correct key/i frames.
  
  What pops into my head, is the data may not be there, as in, it had been committed to memory, but not to disk-- I'd do a test record (factoring the time it "should be", and compare file sizes). Before you jump through hoops.
  
  > **Comments:**
  > **username_6**: The MOOV atom, containing stream info and sample positions, is written at the time of finishing the file i.e. when all the media stream data has been committed to disk. You can have a MP4 with a MOOV atom upfront with just the stream info, which makes the file playable but not seekable. However, very few apps or devices write MP4s in this way.  
  > **username_7**: Bandicam, a very popular screen capture application has an option as to how often it commits the data captured into ram to disk, which is why i mentioned it- just to check. Theres so many software applications out there. A non-seekable file can also be fixed using ffmpeg, and VLC can do it also by inserting in the proper key frames. Another example of larger cache rewrites are with AJA products, some of which wont write to disk until 60 seconds has passed.  
  > **username_0**: I tried using a piece of freemium software to see if it could be recovered, and yes the data is definitely there. The video data is at least. However like I said, I don't really want to go buying software for one video file I don't need that much.  
  
  ---
  
  