0

I have an app which records mp4. Some videos are fine and some corrupt. But even the corrupt ones are huge in size which I conclude have data.However, I have tried ffmpg, avconv and media info. I am pasting media info from both working and corr ones. How do I recover the corrupt video ?

Possible solution: I found this webpage (look at the Incomplete files - or not finalised section). I am guessing this is one of the issues that while recording my phone would have died ? Anyway to recover this ? If you notice in the ffmpeg output only for corrupt video that the video stream is not detected.I do not know how to do this on ubuntu.

http://www.cnwrecovery.com/html/3gp_recovery.html

Corrupt:

mediainfo cor.mp4 
General
Complete name                            : cor.mp4
File size                                : 2.91 MiB

Working:

mediainfo ../wo1.mp4
General
Complete name                            : ../wo1.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 150 KiB
Duration                                 : 334ms
Overall bit rate                         : 3 689 Kbps
Encoded date                             : UTC 2016-01-12 18:31:21
Tagged date                              : UTC 2016-01-12 18:31:21

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings, CABAC                   : No
Format settings, ReFrames                : 1 frame
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 334ms
Bit rate                                 : 3 659 Kbps
Width                                    : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 3:2
Rotation                                 : 90°
Frame rate mode                          : Variable
Frame rate                               : 29.970 fps
Minimum frame rate                       : 28.911 fps
Maximum frame rate                       : 31.110 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.353
Stream size                              : 149 KiB (99%)
Title                                    : VideoHandle
Language                                 : English
Encoded date                             : UTC 2016-01-12 18:31:21
Tagged date                              : UTC 2016-01-12 18:31:21

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 320ms
Source duration                          : 597ms
Source_Duration_FirstFrame               : 277ms
Bit rate mode                            : Constant
Bit rate                                 : 4 125 bps
Nominal bit rate                         : 128 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 165 Bytes (0%)
Source stream size                       : 165 Bytes (0%)
Title                                    : SoundHandle
Language                                 : English
Encoded date                             : UTC 2016-01-12 18:31:21
Tagged date                              : UTC 2016-01-12 18:31:21
mdhd_Duration                            : 320

Working ffmpeg:

ffmpeg -i ../wo1.mp4
ffmpeg version 2.5.10-0ubuntu0.15.04.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
  configuration: --prefix=/usr --extra-version=0ubuntu0.15.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx --enable-libx264 --enable-libsoxr --enable-gnutls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../wo1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2016-01-12 18:31:21
  Duration: 00:00:00.33, start: 0.000000, bitrate: 3688 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 720x480, 3658 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2016-01-12 18:31:21
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      creation_time   : 2016-01-12 18:31:21
      handler_name    : SoundHandle
At least one output file must be specified

Corrupt ffmpeg

ffmpeg -i cor.mp4 
ffmpeg version 2.5.10-0ubuntu0.15.04.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
  configuration: --prefix=/usr --extra-version=0ubuntu0.15.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx --enable-libx264 --enable-libsoxr --enable-gnutls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[adp @ 0x16967e0] Format adp detected only with low score of 25, misdetection possible!
Input #0, adp, from 'cor.mp4':
  Duration: 00:00:55.61, start: 0.000000, bitrate: 438 kb/s
    Stream #0:0: Audio: adpcm_dtk, 48000 Hz, stereo, s16p
At least one output file must be specified

Update I will put my progress here as this thread can potentially help someone else also

201604270700: ffmpeg is not able to get the video stream from corrupt file figuring out right codec -- look at links

    ffmpeg -i cor.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb -loglevel 56 test1.h264
ffmpeg version 2.5.10-0ubuntu0.15.04.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
  configuration: --prefix=/usr --extra-version=0ubuntu0.15.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx --enable-libx264 --enable-libsoxr --enable-gnutls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'cor.mp4'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-bsf:v' ... matched as option 'bsf' (A comma-separated list of bitstream filters) with argument 'h264_mp4toannexb'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '56'.
Reading option 'test1.h264' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument 56.
Successfully parsed a group of options.
Parsing a group of options: input file cor.mp4.
Successfully parsed a group of options.
Opening an input file: cor.mp4.
[adp @ 0x2672d60] Format adp detected only with low score of 25, misdetection possible!
[adp @ 0x2672d60] Before avformat_find_stream_info() pos: 0 bytes read:1048576 seeks:0
[adp @ 0x2672d60] All info found
[adp @ 0x2672d60] After avformat_find_stream_info() pos: 51200 bytes read:1048576 seeks:0 frames:50
Input #0, adp, from 'cor.mp4':
  Duration: 00:00:55.61, start: 0.000000, bitrate: 438 kb/s
    Stream #0:0, 50, 1/48000: Audio: adpcm_dtk, 48000 Hz, stereo, s16p
Successfully opened the file.
Parsing a group of options: output file test1.h264.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument copy.
Applying option an (disable audio) with argument 1.
Applying option bsf:v (A comma-separated list of bitstream filters) with argument h264_mp4toannexb.
Successfully parsed a group of options.
Opening an output file: test1.h264.
File 'test1.h264' already exists. Overwrite ? [y/N] y
Successfully opened the file.
Output #0, h264, to 'test1.h264':
Output file #0 does not contain any stream
[AVIOContext @ 0x2673da0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x2672320] Statistics: 1048576 bytes read, 0 seeks
3
  • Try this.
    – Gyan
    Apr 27, 2016 at 14:21
  • recover_mp4_to_h264 does not work. I ran it on the correct video. It outputted 2 files which it will then consume to run the incorrect video. And after running an incorrect video it just outputted a 25kb file. Any other suggestions ? Is there a hex editor which can fix mp4 etc ?
    – analyst
    May 2, 2016 at 3:31
  • @analyst Ive just found mp4fixer, maybe you can give it a try.
    – SebMa
    Apr 22, 2020 at 23:24

1 Answer 1

3

Untrunc may be able to help.

It's a Linux based command line utility that will restore lost MOOV sections. Using it currently requires libav and a C++ build environment, though instructions are provided to do the build. After it is built, you call it via the command line and just provide the path to a working video from the same phone, the broken video and it will write out a new file that should hopefully work.

6
  • Can you add some more detail about how this tool would be useful/used?
    – AJ Henderson
    Jul 1, 2016 at 13:38
  • @AJ Henderson This tool solves the problem
    – CarryFlag
    Jul 4, 2016 at 13:03
  • 1
    yes, but how do you use it? Generally when a tool is the answer, explaining how to use the tool to solve the problem is preferred.
    – AJ Henderson
    Jul 4, 2016 at 14:09
  • @AJ Henderson I need to copy the documentation from github?
    – CarryFlag
    Jul 4, 2016 at 14:12
  • Ok, I went ahead and made the alteration. I hope that makes it more clear. Sorry about the confusion, I moderate 3 different sites, so I didn't actually have a chance to look more in depth at the particular answer until clarification was needed. Basically, we just don't want people to have to click through multiple answers to find the best one, so the key pieces to determining which answer is best for a particular user should be in the answer itself, when possible. Hope that makes sense.
    – AJ Henderson
    Jul 4, 2016 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.