ponchio / untrunc

Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video.
GNU General Public License v2.0
1.63k stars 229 forks source link

failure to fix file. #79

Open AndKe opened 7 years ago

AndKe commented 7 years ago
$ ./untrunc /media/andre/64GB/Screencast_good.mp4 /media/andre/64GB/Screencast_bad.mp4 
Reading: /media/andre/64GB/Screencast_good.mp4
[aac @ 0x232bba0] Input buffer exhausted before END element found
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/media/andre/64GB/Screencast_good.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2017-04-13 11:41:43
  Duration: 00:00:10.29, start: 0.000000, bitrate: 4994 kb/s
    Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 2560x1440, 4926 kb/s, 26.61 fps, 90k tbr, 90k tbn, 180k tbc
    Metadata:
      creation_time   : 2017-04-13 11:41:43
    Stream #0.1(eng): Audio: aac, 44100 Hz, 2 channels (FC), s16, 63 kb/s
    Metadata:
      creation_time   : 2017-04-13 11:41:43
avc1: Match with 0 header
Nal type: 5
Length for first packet = 204520 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 39511 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 76226 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 32936 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 85334 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 58753 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 72719 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 145015 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 128057 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 203367 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 133747 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 145745 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 99957 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 358269 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 49851 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 241434 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 36918 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 239900 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 33895 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 20993 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 127859 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 21813 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 246025 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 36070 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 13446 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 230231 / 800000
avc1: Match with 0 header
Nal type: 1
Length for first packet = 33287 / 800000
avc1: failed for not particular reason
mp4a: Success because of large s value
[aac @ 0x232bba0] Prediction is not allowed in AAC-LC.

Invalid length. -1094995529. Wrong match in track: 1
Found 27 packets

the files are Android (6.0.1) screen recording, bad is 1.6GB (due to no more space on device) - good is 6.4MB (created to have a good one.)

dluga93 commented 7 years ago

Similar thing happens to me as well. The bad video is 1.4 GB, and the good video is 1.5 mb, both from the same source (twitch.tv recordings). The errors shown below seem to continue for at least 5 minutes unless I stop them.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'good_video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2017-05-05 09:00:37
    encoder         : vlc 3.0.0-git stream output
    encoder-eng     : vlc 3.0.0-git stream output
  Duration: 00:00:31.70, start: 0.000000, bitrate: 368 kb/s
    Stream #0:0(eng): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 127 kb/s (default)
    Metadata:
      creation_time   : 2017-05-05 09:00:37
      handler_name    : SoundHandler
    Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 235 kb/s, 30 fps, 30 tbr, 90k tbn, 2k tbc (default)
    Metadata:
      creation_time   : 2017-05-05 09:00:37
      handler_name    : VideoHandler
Reading: good_video.mp4
Failure because of NULL header
avc1: Match with 0 header
Nal type: 6
Length for first packet = 606 / 800000
Failure because of NULL header
avc1: Match with 0 header
Nal type: 5
Length for first packet = 26156 / 800000
Success for no particular reason....
Failure because of NULL header
avc1: Match with 0 header
Nal type: 1
Length for first packet = 11 / 800000
Success for no particular reason....
Failure because of NULL header
avc1: Match with 0 header
Nal type: 1
Length for first packet = 14 / 800000
Success for no particular reason....
Failure because of NULL header
avc1: Match with 0 header
Nal type: 1
Length for first packet = 45 / 800000
Success for no particular reason....
Success for no particular reason....
Failure because of NULL header
avc1: Match with 0 header
Nal type: 1
jevgenijs-jefimovs commented 6 years ago

Hi! Same problem here. Source files are GoPro Hero5, 4K video format. Any idea what is causing this?

./untrunc ./GP040153.MP4 ./GOPR0156.MP4 1> log.log 2>log2.log

log.log

Reading: ./GP040153.MP4 Track codec: mp4a mp4a: Success because of large s value Duration: 0

Invalid length. -1052488119. Wrong match in track: 0 Track codec: avc1 avc1: failed for not particular reason Track codec: Track codec: Track codec: Found 0 packets Track duration: 0 movie timescale: 90000 track timescale: 48000 Track duration: 0 movie timescale: 90000 track timescale: 90000 Track duration: 0 movie timescale: 90000 track timescale: 90000 Track duration: 0 movie timescale: 90000 track timescale: 1000 Track duration: 0 movie timescale: 90000 track timescale: 90000

log2.log

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 2 with DTS 0, packet 3 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 3 with DTS 0, packet 4 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 4 with DTS 0, packet 5 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 5 with DTS 0, packet 6 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 6 with DTS 0, packet 7 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 7 with DTS 0, packet 8 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 8 with DTS 0, packet 9 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 9 with DTS 0, packet 10 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 10 with DTS 0, packet 11 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 11 with DTS 0, packet 12 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 12 with DTS 0, packet 13 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 13 with DTS 0, packet 14 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 14 with DTS 0, packet 15 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 15 with DTS 0, packet 16 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 16 with DTS 0, packet 17 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 17 with DTS 0, packet 18 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 18 with DTS 0, packet 19 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 19 with DTS 0, packet 20 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 20 with DTS 0, packet 21 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 21 with DTS 0, packet 22 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 22 with DTS 0, packet 23 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 23 with DTS 0, packet 24 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 24 with DTS 0, packet 25 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 25 with DTS 0, packet 26 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 26 with DTS 0, packet 27 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 27 with DTS 0, packet 28 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 28 with DTS 0, packet 29 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 29 with DTS 0, packet 30 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 30 with DTS 0, packet 31 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 31 with DTS 0, packet 32 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 32 with DTS 0, packet 33 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 33 with DTS 0, packet 34 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 34 with DTS 0, packet 35 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 35 with DTS 0, packet 36 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 36 with DTS 0, packet 37 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 37 with DTS 0, packet 38 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 38 with DTS 0, packet 39 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 39 with DTS 0, packet 40 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 40 with DTS 0, packet 41 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 41 with DTS 0, packet 42 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 42 with DTS 0, packet 43 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 43 with DTS 0, packet 44 with DTS 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56469cb73ae0] Non-increasing DTS in stream 4: packet 44 with DTS 0, packet 45 with DTS 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './GP040153.MP4': Metadata: major_brand : mp41 minor_version : 538120216 compatible_brands: mp41 creation_time : 2017-08-19 15:12:25 Duration: 00:02:35.12, start: 0.000000, bitrate: 60195 kb/s Stream #0:0(eng): Video: h264 (High) [avc1 / 0x31637661] yuvj420p, pc, bt709/bt709/bt709 3840x2160 [PAR 1:1 DAR 16:9], 60011 kb/s 25 fps, 90k tbn (default) Metadata: creation_time : 2017-08-19 15:12:25 handler_name : GoPro AVC encoder : GoPro AVC encoder Stream #0:1(eng): Audio: aac (LC) [mp4a / 0x6134706D] 48000 Hz, stereo, fltp, 127 kb/s (default) Metadata: creation_time : 2017-08-19 15:12:25 handler_name : GoPro AAC Stream #0:2(eng): Data: tmcd / 0x64636D74 (default) Metadata: creation_time : 2017-08-19 15:12:25 handler_name : GoPro TCD Stream #0:3(eng): Data: gpmd / 0x646D7067, 37 kb/s (default) Metadata: creation_time : 2017-08-19 15:12:25 handler_name : GoPro MET Stream #0:4(eng): Data: fdsc / 0x63736466, 9 kb/s (default) Metadata: creation_time : 2017-08-19 15:12:25 handler_name : GoPro SOS [aac @ 0x56469cb76060] channel element 2.3 is not allocated

mattvb91 commented 6 years ago

same problem here

charsi commented 5 years ago

Was having the same problem. Adding the -a flag fixed it somehow and I got a working file!

I don't even know what -a is supposed to do. It is undocumented.

anthwlock commented 5 years ago

untrunc -a <ok.mp4> lets you analyze (Mp4::analyze) the codecs inside ok.mp4 It should not change the result of Mp4::repair.

Future readers should try this fork, it even supports GoPro videos!

gregology commented 4 years ago

How do you add flags to the untrunc command when using the docker container?