Giter Club home page Giter Club logo

untrunc's People

Contributors

anthwlock avatar benjamin-loison avatar brandon-dacrib avatar dirceu-jr avatar hacklin avatar hexluthor avatar martinml avatar ponchio avatar poppyer9 avatar sebix avatar serl avatar teknoraver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

untrunc's Issues

Compile statically?

Are there any configuration preferences for the makefile to compile this statically?

error: use of undeclared identifier '__gcd'; note that Makefile uses c++11 (and not c++17)

Hello,

First of all, thanks so much for your port of untrunc, having a 'real' Makefile makes all the difference! 😄
I'm compiling under macOS Catalina 10.15.1 (Beta), using XCode 11.1, as well as brewto install libav, and I'm getting the error listed on the subject. According to this, there are two issues that require fixing:

  1. Do not use __gcd() — while it's common usage, it's supposed to be a private, internal function. Use gcd() instead.
  2. gcd() is available under c++17, but your Makefile uses c++11.

Both fixes are actually very easy to do (even for someone who has not programmed in C++ for almost two decades, like me! 😲)

Build on CentOS 7 error

Hi, guys!
I was really amused that I found your maintained fork, because we've been using main untrunc repo build for few years and it worked not bad (on CentOS 6 and then on CentOS 7), but it's always good to have even more. Thanks for a great job!
I have an error during the build
I'm trying to build your fork using these steps:

yum install -y unzip
wget https://github.com/anthwlock/untrunc/archive/master.zip
unzip master.zip

Found some ready libav binaries:

wget http://www.nosuchhost.net/~cheese/fedora/packages/epel-7/x86_64/cheese-release-7-1.noarch.rpm
rpm -Uvh cheese-release*rpm
yum instal -y install libavformat-devel libavcodec-devel libavutil-devel

cd untrunc-master
Simple make instantly fails with:

untrunc:
ffmpeg: shared
g++ -MMD -MP -DUNTR_VERSION=\"\" -std=c++11 -D_FILE_OFFSET_BITS=64 -g -o .build_shared/src/track.o -c src/track.cpp
src/track.cpp:32:32: fatal error: libavcodec/avcodec.h: No such file or directory
 #include <libavcodec/avcodec.h>
                                ^
compilation terminated.
make: *** [.build_shared/src/track.o] Error 1

Didn't find any instructions to include lib paths, but found that I need to change Makefile script to make it work on CentOS 7.
nano Makefile
Removed wget attribute --show-progress . It’s not supported in CentOS 7
Then
make FF_VER=3.3.9
And it compiled pretty long with a few warnings (I think, it's not related).
And completely failed on this:

ffmpeg: 3.3.9

g++ -MMD -MP -DUNTR_VERSION=\"\" -I./ffmpeg-3.3.9 -std=c++11 -D_FILE_OFFSET_BITS=64 -g -o .build_3.3.9/src/track.o -c src/track.cpp
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Tp = std::tuple<int, double, int>; _Compare = Track::genPatternPerm()::__lambda0]':
/usr/include/c++/4.8.2/bits/stl_algo.h:2296:78:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Compare = Track::genPatternPerm()::__lambda0]'
/usr/include/c++/4.8.2/bits/stl_algo.h:2337:62:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Size = long int; _Compare = Track::genPatternPerm()::__lambda0]'
/usr/include/c++/4.8.2/bits/stl_algo.h:5499:44:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Compare = Track::genPatternPerm()::__lambda0]'
src/track.cpp:338:3:   required from here
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: error: no match for call to '(Track::genPatternPerm()::__lambda0) (std::tuple<int, double, int>&, const std::tuple<int, double, int>&)'
    while (__comp(*__first, __pivot))
                                   ^
src/track.cpp:335:34: note: candidates are:
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                  ^
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: note: bool (*)(tuple_t&, tuple_t&) {aka bool (*)(std::tuple<int, double, int>&, std::tuple<int, double, int>&)} <conversion>
    while (__comp(*__first, __pivot))
                                   ^
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: note:   candidate expects 3 arguments, 3 provided
src/track.cpp:335:58: note: Track::genPatternPerm()::__lambda0
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                                          ^
src/track.cpp:335:58: note:   no known conversion for argument 2 from 'const std::tuple<int, double, int>' to 'tuple_t& {aka std::tuple<int, double, int>&}'
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: error: no match for call to '(Track::genPatternPerm()::__lambda0) (const std::tuple<int, double, int>&, std::tuple<int, double, int>&)'
    while (__comp(__pivot, *__last))
                                  ^
src/track.cpp:335:34: note: candidates are:
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                  ^
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: note: bool (*)(tuple_t&, tuple_t&) {aka bool (*)(std::tuple<int, double, int>&, std::tuple<int, double, int>&)} <conversion>
    while (__comp(__pivot, *__last))
                                  ^
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: note:   candidate expects 3 arguments, 3 provided
src/track.cpp:335:58: note: Track::genPatternPerm()::__lambda0
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                                          ^
src/track.cpp:335:58: note:   no known conversion for argument 1 from 'const std::tuple<int, double, int>' to 'tuple_t& {aka std::tuple<int, double, int>&}'
make: *** [.build_3.3.9/src/track.o] Error 1

Complete logs

Please provide some further steps to fix the build and I will send you complete instructions to install this on CentOS (to add this in your readme).

Core dumped after Assertion `track.offsets_.back() < mdat->start_ + mdat->length_' failed

Info: version '51ebdc1-dirty' using ffmpeg 'N-95906-g2952d9c'
Info: reading /media/cdrom/backup/Videos/dessert.mp4
Info: parsing healthy moov atom ...
Composition time offset atom found. Out of order samples possible.
Sample dependency flag atom found. I and P frames might need to recover that info.
untrunc: src/mp4.cpp:117: void Mp4::parseTracksOk(): Assertion `track.offsets_.back() < mdat->start_ + mdat->length_' failed.
Aborted (core dumped)

Could not read at position

I am but a simple meme farmer trying to save a meme. I tried this on both Windows and Linux! Same output for both

I did:
youtube-dl https://coub.com/view/1cr0g0
renamed the file to smoke.mp4

then when I noticed the file was corrupted, I looked into solutions. I came upon untrunc, but unfortunately, it can't recover anything.

untrunc -i smoke.mp4
Info: version 'b7a674c' using ffmpeg '3.3.4'
Info: reading smoke.mp4
Info: parsing healthy moov atom ...
Could not read at position

I know this is largely a youtube-dl dilemma, but given they are constantly backlogged, I figured I'd have more luck with this. Any thoughts?

Assertion failed!

Hello! Thank you very much for this tool.

I seem to have a problem when running it:

untrunc -v .\WE11-3.MP4 .\WE11-4.MP4
Info: version 'ebeb1a1' using ffmpeg '3.3.4'
Info: reading .\WE11-3.MP4
Info: parsing healthy moov atom ...
Composition time offset atom found. Out of order samples possible.
ftyp_ = 'XAVC'
detected 'XAVC', deactivating 'g_strict_nal_frame_check'
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000046bcf80] Drop frame is only allowed with 30000/1001 or 60000/1001 FPS
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\WE11-3.MP4':
  Metadata:
    major_brand     : XAVC
    minor_version   : 16785407
    compatible_brands: XAVCmp42iso2
    creation_time   : 2020-03-07T13:01:38.000000Z
  Duration: 01:24:02.04, start: 0.000000, bitrate: 58213 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 56422 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2020-03-07T13:01:38.000000Z
      handler_name    : Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2020-03-07T13:01:38.000000Z
      handler_name    : Sound Media Handler
    Stream #0:2(und): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2020-03-07T13:01:38.000000Z
      handler_name    : Time Code Media Handler
    Stream #0:3(und): Data: none (rtmd / 0x646D7472), 245 kb/s (default)
    Metadata:
      creation_time   : 2020-03-07T13:01:38.000000Z
      handler_name    : Timed Metadata Media Handler
      timecode        : 00:00:00:00
found avcC after: 102
remaining len:169
parsing avcC ...
len_sps: 52
decoding SPS ...
log2_max_frame_num: 6
avcC got decoded
assuming constant duration of 1001 for 'avc1' (x151110)
assuming constant duration of 1 for 'twos' (x242017920)
Info: special track found (tmcd, 'Time Code Media Handler')
assuming constant duration of 1001 for 'rtmd' (x151110)
Info: special track found (meta, 'Timed Metadata Media Handler')

Info: unknown track 'twos' found -> fallback to dynamic stats
created dummy track 'free'
Assertion failed!

Program: H:\untrunc_x64\untrunc.exe
File: src/mp4.cpp, Line 557

Expression: off - current_mdat_->contentStart() >= pat_size_ / 2

Do you have any ideas what might be going wrong? The reference file does play fine.

Thank you very much for your time.

"unable to find correct codec" and restore fails

The actual file is about 45 min long.

$ ./untrunc reference.mp4 corrupt.mp4
Info: version '43037a2' using ffmpeg '4.1.3-1'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x55ddc3c09ac0] Multiple frames in a packet.
[aac @ 0x55ddc3c09ac0] Prediction is not allowed in AAC-LC.
Error: unable to find correct codec -> premature end
       try '-s' to skip unknown sequences

Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
[...]

ffmpeg '4.1.3-1'

$ ./untrunc -s reference.mp4 corrupt.mp4
WARNING: Because of internal decoder changes, using ffmpeg '4.1.3-1' with '-s' can be slow!
         You are advised to compile untrunc against ffmpeg 3.3!
         See the README.md on how to do that. Press [ENTER] to continue ... 
Info: version '43037a2' using ffmpeg '4.1.3-1'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x55e93a4a1080] Multiple frames in a packet.
[aac @ 0x55e93a4a1080] Prediction is not allowed in AAC-LC.
Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
Info: Duration of mp4a: 3s 818ms  (3818 ms)
Info: Duration of avc1: 4s 25ms  (4025 ms)
Warning: Unknown sequences: 1
Warning: Bytes not matched: 35MiB (0%)

ffmpeg '3.3.9'

$ ./untrunc -s reference.mp4 corrupt.mp4
Info: version '43037a2' using ffmpeg '3.3.9'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x564d340ab1c0] Multiple frames in a packet.
[aac @ 0x564d340ab1c0] Number of bands (46) exceeds limit (43).
Info: unknown sequence -> muting ffmpeg and warnings ..
Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
Info: Duration of mp4a: 3s 818ms  (3818 ms)
Info: Duration of avc1: 4s 25ms  (4025 ms)
Warning: Unknown sequences: 1
Warning: Bytes not matched: 35MiB (0%)

No codec found!

I'm getting the following message, which I assume is an error. bad-fixed.mp4is never created.

$ untrunc -v good.mp4 bad.mp4 
Info: version '53e3ce1' using ffmpeg '3.3.9'
Info: reading good.mp4
Info: parsing healthy moov atom ... 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x563244680da0] Using non-standard frame rate 29/1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'good.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2019-06-24T07:21:48.000000Z
    firmware        : HD7.01.01.70.00
  Duration: 00:00:29.16, start: 0.000000, bitrate: 45334 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 45078 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2019-06-24T07:21:48.000000Z
      handler_name    : GoPro AVC  
      encoder         : GoPro AVC encoder
      timecode        : 07:36:34:20
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2019-06-24T07:21:48.000000Z
      handler_name    : GoPro AAC  
      timecode        : 07:36:34:20
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2019-06-24T07:21:48.000000Z
      handler_name    : GoPro TCD  
      timecode        : 07:36:34:20
    Stream #0:3(eng): Data: none (gpmd / 0x646D7067), 39 kb/s (default)
    Metadata:
      creation_time   : 2019-06-24T07:21:48.000000Z
      handler_name    : GoPro MET  
    Stream #0:4(eng): Data: none (fdsc / 0x63736466), 10 kb/s (default)
    Metadata:
      creation_time   : 2019-06-24T07:21:48.000000Z
      handler_name    : GoPro SOS  
found avcC after: 121
remaining len:75
parsing avcC ...
len_sps: 52
decoding SPS ...
log2_max_frame_num: 5
Info: avcC got decoded
No codec found!

I can email the relevant files.

some deprecated warnings when building under Debian testing

Got some deprecated warnings, maybe you would want to look into that -

~/games/untrunc$ g++ -o untrunc -O3 *.cpp -lavformat -lavcodec -lavutil -std=c++11
codec.cpp: In member function ‘int Codec::getSize(const uchar*, uint, int&)’:
codec.cpp:196:73: warning: ‘int avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations]
   int consumed = avcodec_decode_audio4(context_, frame, &got_frame, &avp);
                                                                         ^
In file included from codec.cpp:9:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4722:5: note: declared here
 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
     ^~~~~~~~~~~~~~~~~~~~~
codec.cpp:196:73: warning: ‘int avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations]
   int consumed = avcodec_decode_audio4(context_, frame, &got_frame, &avp);
                                                                         ^
In file included from codec.cpp:9:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4722:5: note: declared here
 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
     ^~~~~~~~~~~~~~~~~~~~~
mp4.cpp: In member function ‘void Mp4::parseOk(std::__cxx11::string&)’:
mp4.cpp:71:18: warning: ‘void av_register_all()’ is deprecated [-Wdeprecated-declarations]
  av_register_all();
                  ^
In file included from mp4.cpp:28:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:2043:6: note: declared here
 void av_register_all(void);
      ^~~~~~~~~~~~~~~
mp4.cpp:71:18: warning: ‘void av_register_all()’ is deprecated [-Wdeprecated-declarations]
  av_register_all();
                  ^
In file included from mp4.cpp:28:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:2043:6: note: declared here
 void av_register_all(void);
      ^~~~~~~~~~~~~~~
mp4.cpp: In member function ‘void Mp4::parseTracks()’:
mp4.cpp:320:47: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
   Track track(traks[i], context_->streams[i]->codec);
                                               ^~~~~
In file included from mp4.cpp:28:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:878:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
mp4.cpp:320:47: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
   Track track(traks[i], context_->streams[i]->codec);
                                               ^~~~~
In file included from mp4.cpp:28:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:878:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
mp4.cpp:320:47: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
   Track track(traks[i], context_->streams[i]->codec);
                                               ^~~~~
In file included from mp4.cpp:28:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:878:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
nal.cpp: In constructor ‘NalInfo::NalInfo(const uchar*, int)’:
nal.cpp:16:67: warning: passing NULL to non-pointer argument 1 of ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<unsigned char>]’ [-Wconversion-null]
 NalInfo::NalInfo(const uchar* start, int max_size) : payload_(NULL){                                                                   ^

Package: libavformat-dev
Version: 7:4.1-1
Severity: normal

-- System Information:
Debian Release: buster/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_IN, LC_CTYPE=en_IN (charmap=UTF-8), LANGUAGE=en_IN:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libavformat-dev depends on:
ii libavcodec-dev 7:4.1-1
ii libavformat58 7:4.1-1
ii libavutil-dev 7:4.1-1
ii libswresample-dev 7:4.1-1

libavformat-dev recommends no packages.

libavformat-dev suggests no packages.

-- no debconf information

Add output directory switch please

Hi,

Thanks for doing this and making a Windows build! Could you please add a switch or argument to define the output directory or file? This will allow the program to be used more easily in an automated fashion.

Got unexpected packet size after a partial decode

I tried to use this tool to restore my broken mp4 video but , I have this error:

Info: reading /path/to/working-video.m4v
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: parsing mdat from truncated file ... 
[aac @ 0x10da980] Multiple frames in a packet.
[aac @ 0x10da980] Got unexpected packet size after a partial decode
Error: Invalid length: -22. Wrong match in track: 0
Error: unable to find correct codec -> premature end
Info: Found 1 packets ( mp4a: 1 avc1: 0 avc1-keyframes: 0 )
Info: Duration of mp4a: 21ms  (21 ms)
Info: Duration of avc1:  (0 ms)
Info: saving /path/to/broken-video.mp4_fixed.mp4

I have cloned the last version (master) and follow the readme instructions.

Please, what can I do?

Regards.

Changes produce broken video

Hi! As you requested in my pull request, I've uploaded a sample video which is fixed correctly by ponchio's master, but when I run it on your master, the output is a broken video. Here are the files.

Running:
./untrunc ok.mp4 broken_sample.mp4

The original code produces the file I've renamed output_original.mp4, and this version produces output_corrupted.mp4.

Let me know if I can help!

Sowt is just raw data, no way to guess length

Getting the following message when attempting to repair a truncated MOV from my dashcam...

Sowt is just raw data, no way to guess length (unless reliably detecting the other codec start)

The process does not error, but produces a file with a duration of 0.

Here is the result of ffmpeg -i for a working file from the same dashcam:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '<redacted>/working.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-06-28T12:24:12.000000Z
original_format : NVT-IM
original_format-eng: NVT-IM
comment : CarDV-TURNKEY
comment-eng : CarDV-TURNKEY
Duration: 00:03:01.00, start: 0.000000, bitrate: 13078 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 11879 kb/s, 30 fps, 30 tbr, 30k tbn, 60k tbc (default)
Metadata:
creation_time : 2019-06-28T12:24:12.000000Z
handler_name : VideoHandler
encoder : h264
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 32000 Hz, mono, s16, 512 kb/s (default)
Metadata:
creation_time : 2019-06-28T12:24:12.000000Z
handler_name : SoundHandler

Fixed mp4 highly truncated

anthwlock,

Per your comments over on poncio/untrunc, I was able to get a successful compile with no errors. However, when I run it on the good and bad mp4 files, it heavily truncates the new file and appears to show only the first frame of the bad video.

The original mp4 is 109Mb, the fix file is 428Kb. I have several 'good' mp4 files taken with the same camera, but the result is the same no matter which one I choose as the good file.

Here is the result of the run that shows the errors:


$ ./untrunc /home/monty/'Yuneec Q500 Drone/Videos'/YUN00003.mp4 /home/monty/'Yuneec Q500 Drone/Videos'/YUN00005.mp4
Info: reading /home/monty/Yuneec Q500 Drone/Videos/YUN00003.mp4
Info: parsing healthy moov atom ... 
Composition time offset atom found. Out of order samples possible.
Info: avcC got decoded
Info: parsing mdat from truncated file ... 
Error: New access unit since seen picture (type: 12)
Error: Invalid length: -22. Wrong match in track: 0
Error: unable to find correct codec -> premature end
Info: Found 3 packets ( mp4a: 1 avc1: 2 avc1-keyframes: 1 )
Info: Duration of mp4a = 1.024s
Info: Duration of avc1 = 6.006s
Info: saving /home/monty/Yuneec Q500 Drone/Videos/YUN00005.mp4_fixed.mp4

Is this bad file a lost cause?

Thanks for your help!

Monty

Error: bad track: 'mebx'

Hi there,
I've tried using on both windows and linux. I wasn't able to recover my files due to an error:

Info: version '' using ffmpeg '3.3.9'
Info: reading good_file.mp4
Info: parsing healthy moov atom ... 
Sample dependency flag atom found. I and P frames might need to recover that info.
Info: special track found (meta, 'Core Media Metadata')
Info: special track found (meta, 'Core Media Metadata')

Info: unknown track 'mebx' found -> fallback to dynamic stats
Error: bad track: 'mebx'

Can you tell me what this means? I'm not sure why it doesn't work, I've followed all instructions and compiled correctly. on the gui version the it crashes when I click 'repair' this error was taken from terminal not sure if that affects anything.

Please help me out, thanks!

Missing Movie Header Atom

Hello,

I have a truncated mp4 file that i produced using a home brewed powershell script that leverages ffmpeg to record a multicast stream. Script was not able to lay down the last atom moov packet and I now have a 7.3GB file that is not playable. I tried using the windows (x64) exe to read another working mp4 file that was created the same exact way but i keep getting "Missing movie header atom"

What am i doing wrong?

Need help

Can you upload the source of windows gui? I wanna add more function

Cannot fix the file

I am definitely not a tech guru and I am definitely new to coding. I really got fixated upon the issue of fixing the broken file in .m4a format. Its size is very small, about 20MB and yeah, I really did my best.

I tried installing VirtualBox just to emulate Linux Ubuntu and used ponchio's instructions but every time I got to compiling step I would stumble upon the problem of not having config.h file. When I used your instructions, the problem disappeared. But another one came up after - Linux cannot open .m4a files and cannot fix it.

So yeah, I just tried to use your instruction on macOS which I am using, but never got any success as Terminal doesn't understand the commands that are in your Building instructions. What am I to do?

It's been almost two days of me trying everything. I tried various libav libraries, tried to translate the linux terminal language to macos terminal language. Updated YASM and so on. i don't know what to do and I am totally frustrated...

OsX Build Error

I have a need to fix a file that is larger than 7GB and use a OsX (10.13.6) as my primary machine these days. I cannot compile this fork of untrunc. I'm fairly new to all this and could use a little help.

Here is what i did:

  1. Downloaded the code and unzipped
  2. Downloaded and placed libav dir in the untrunc-master dir
  3. Compiled the libav binaries using the instructions on ponchio's instructions
    cd libav-12.3/ ./configure make cd ..
  4. Then running
    g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -I./libav-12.3 -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavutil -lavutil -lpthread -lz -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration -lbz2 -DOSX
    see the attached log for the errors.

Any assistance would be appreciated.
log.txt

program crash

I was happy to find this in a windows version as i didn't get the Linux version to work. Im too new to Linux i gues and i cannot run the program properly it seems.
Anyways, this is regarding the Win version.
I load the GUI, load a reference from same camera and day, load truncated mp4 file and hit repair, the program starts working for about a min then crashes, i can see in a split second it's writing something to the log (set to -v) and the crash, i don't get to read what is writing.

Any help will be appreciated.

Files used can be found here with a video of crash, you can se some log file text there that i dont understand

https://drive.google.com/open?id=10uf6xAZQ8DlceaBGk4ugwPTzwQc5lIuA

100CPU, no progress

Hi and thanks for your fork and contribution.
The following files will cause untrunc(both your fork and ponchio master) to run endlessly and consume 100%CPU with no output file
Console shows:

Info: reading reference-video.mp4
Info: parsing healthy moov atom ... 
Info: parsing mdat from truncated file ... 

As requested,I'm sharing a reference file and example of broken video from the same camera.
https://goo.gl/urvwFn

Latest Build of Windows isn't working

Hi i downloaded latest windows build, it showing below error message when i tried to fix a corrupt file

Info: version '25004ba' using ffmpeg '3.3.4'
Info: reading working.mp4
Info: parsing healthy moov atom ...
Info: avcC got decoded
Info: searching start of mdat ...
invalid atom length: -8

if i run untrunc.exe -vv working.mp4 video.mp4, this is output i get
if i run untrunc.exe -vv working.mp4 video.mp4, this is the output

Working mp4 file size is 84mb, corrupt mp4 file size is 176mb.
i get same above message if i build untrunc from source with below command

g++ -o untrunc -I./libav-12.3 *.cpp -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavutil -lavutil -O3 -std=c++11

the same corrupt file was fixed in one of the old version of untrunc (as far as i remember, around 7 months ago)

the reason i'm trying to fix corrupt mp4 with latest untrunc is because in old version it doesn't fix files above 2GB

but in latest version its not fixing smaller files as well..
Here is the working video's codec details (taken from MediaInfo)

what might have gone wrong?
I'm running windows 10 64bit

Thanks & Regards
Prakash

Compile error on ARM running Debian Jessie

Hi, I am trying to compile untrunc on an ARM SBC running Debian Jessie 3.10, but I am getting the following error

root@Lamer:~/Source/untrunc-master# make
untrunc:
ffmpeg: shared

mkdir .build_shared
g++ -MMD -MP -DUNTR_VERSION=\"\" -O3 -std=c++11 -g -o .build_shared/track.o -c track.cpp
g++ -MMD -MP -DUNTR_VERSION=\"\" -O3 -std=c++11 -g -o .build_shared/codec.o -c codec.cpp
codec.cpp: In constructor ‘Codec::Codec(AVCodecParameters*)’:
codec.cpp:25:33: error: invalid use of incomplete type ‘class AVCodecParameters’
  codec_ = avcodec_find_decoder(c->codec_id);
                                 ^
In file included from codec.cpp:1:0:
codec.h:11:7: error: forward declaration of ‘class AVCodecParameters’
 class AVCodecParameters;
       ^

plus a few more. Is this my bad, please? Thank you. :-)

interested in a snap version?

Hi, I used the Dockerfile as a basis to create a snapcraft.yaml for your untrunc version.

snaps offer the advantage that they are automatically updated to the latest version.

As an added benefit, snapcraft.io can automatically build new snap versions on their infrastructure whenever there is a change on the github repo.

various errors when fixing mp4

Running the dockerfile untrunc. Ran into some errors when repairing an mp4

mp4a: Success for no particular reason....
Duration: 0
avc1: No match because of NAL type: 27

Track 0 codec: mp4a
[aac @ 0x1f8fac0] Sample rate index in program config element does not match the sample rate index configured by the container.
[aac @ 0x1f8fac0] Reserved bit set.
[aac @ 0x1f8fac0] Prediction is not allowed in AAC-LC.

Repair: /mnt/bad1.MP4
Track 0 codec: mp4a
Track 1 codec: avc1
First byte expected 0.
mp4a: Failure because of NULL header.
avc1: Match with 0 header.

Would appreciate some help - taken me forever just to get the dockerfile to work correctly

Have --version and --help arguments

untruc doesn't have a version string or --help arguments. It would be nice to have these. The version string could be the git commit short id for now d6828ed as an identifier for now. Something on the lines of -

$ git rev-parse --short HEAD
d6828ed

Offset set before beginning of mdat out of range in Windows

I have used untrunc_x64 and it maked an error

Info: using 64-bit offsets for the broken file
terminate called after throwing an instance of 'std::out_of_range'
what(): Offset set before beginning of mdat (-204185700)

Is my broken vedio too large?

Windows and Debian - untrunc does not finish

Hi, both under Windows and Debian untrunc prints out some info but then hangs forever (uh) at:
Info: Found 498 packets ( avc1: 498 avc1-keyframes: 50 )
With other files the similar happens:
Info: Found 122 packets ( avc1: 122 avc1-keyframes: 14 )
It uses some CPU power, but does nothing for hours now. Any help/suggestions much appreciated.

single core maxes out to 100% but no progress

I get this output


Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different bottom pic flag
Warning: Different poc lsb
Warning: New access unit since seen picture (type: 6)
Warning: Different nal type (5, 1)
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Warning: Different poc lsb
Info: Found 715 packets ( avc1: 715 avc1-keyframes: 18 )

unknown track 'hvc1' found

Would you add support for GoPro mp4 files ?

It is a time-lapse video, so no audio presents.

The mp4 file will have no moov when there is a sudden power lost.

$ ./untrunc-master/untrunc -v  good.mp4 bad.mp4 
Info: version '' using ffmpeg 'n4.2.2'
Info: reading good.mp4
Info: parsing healthy moov atom ... 
ftyp_ = 'mp41'
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'good.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2020-03-06T02:17:57.000000Z
    location        : +22.5869+114.2602/
    location-eng    : +22.5869+114.2602/
    firmware        : HD8.01.01.60.00
  Duration: 00:05:20.32, start: 0.000000, bitrate: 100199 kb/s
    Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 100002 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2020-03-06T02:17:57.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
      timecode        : 02:23:18:05
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2020-03-06T02:17:57.000000Z
      handler_name    : GoPro TCD  
      timecode        : 02:23:18:05
    Stream #0:2(eng): Data: bin_data (gpmd / 0x646D7067), 184 kb/s (default)
    Metadata:
      creation_time   : 2020-03-06T02:17:57.000000Z
      handler_name    : GoPro MET  
    Stream #0:3(eng): Data: none (fdsc / 0x63736466), 6 kb/s (default)
    Metadata:
      creation_time   : 2020-03-06T02:17:57.000000Z
      handler_name    : GoPro SOS  
assuming constant duration of 3600 for 'hvc1' (x8008)
Info: special track found (tmcd, 'GoPro TCD')
assuming constant duration of 4000 for 'gpmd' (x8008)
Info: special track found (meta, 'GoPro MET')
assuming constant duration of 0 for 'fdsc' (x16018)
Info: special track found (meta, 'GoPro SOS')

Info: unknown track 'hvc1' found -> fallback to dynamic stats
created dummy track 'free'
removed dummy track 'free'
first_failed: 0 of 32034
order_finished: 0
order: (1, 2) (2, 1) (1, 1) (3, 1) (1, 1) (0, 1) (1, 1) (2, 1) (1, 1) (0, 1) (1, 1) (2, 1) (1, 1) (0, 1) (1, 1) (2, 1) (1, 1) (0, 1) (1, 1) (2, 1) (1, 1) (0, 1) (1, 1) (2, 1) (1, 1) 
isTrackOrderEnough: 0  (sz=0)
Error: bad track: 'hvc1'
$ AtomicParsley good.mp4 -T 1
Atom ftyp @ 0 of size: 20, ends @ 20
Atom mdat @ 20 of size: 4011713292, ends @ 4011713312
Atom moov @ 4011713312 of size: 285976, ends @ 4011999288
     Atom mvhd @ 4011713320 of size: 108, ends @ 4011713428
     Atom udta @ 4011713428 of size: 26421, ends @ 4011739849
         Atom ©xyz @ 4011713436 of size: 30, ends @ 4011713466                                   ~
         Atom FIRM @ 4011713466 of size: 23, ends @ 4011713489                                   ~
         Atom LENS @ 4011713489 of size: 56, ends @ 4011713545                                   ~
         Atom CAME @ 4011713545 of size: 24, ends @ 4011713569                                   ~
         Atom SETT @ 4011713569 of size: 20, ends @ 4011713589                                   ~
         Atom MUID @ 4011713589 of size: 40, ends @ 4011713629                                   ~
         Atom HMMT @ 4011713629 of size: 412, ends @ 4011714041                                  ~
         Atom BCID @ 4011714041 of size: 44, ends @ 4011714085                                   ~
         Atom GUMI @ 4011714085 of size: 24, ends @ 4011714109                                   ~
         Atom GPMF @ 4011714109 of size: 25608, ends @ 4011739717                                        ~
         Atom free @ 4011739717 of size: 132, ends @ 4011739849
     Atom iods @ 4011739849 of size: 24, ends @ 4011739873
     Atom trak @ 4011739873 of size: 65941, ends @ 4011805814
         Atom tkhd @ 4011739881 of size: 92, ends @ 4011739973
         Atom tref @ 4011739973 of size: 20, ends @ 4011739993
             Atom tmcd @ 4011739981 of size: 12, ends @ 4011739993                               ~
         Atom edts @ 4011739993 of size: 36, ends @ 4011740029
             Atom elst @ 4011740001 of size: 28, ends @ 4011740029
         Atom mdia @ 4011740029 of size: 65785, ends @ 4011805814
             Atom mdhd @ 4011740037 of size: 32, ends @ 4011740069
             Atom hdlr @ 4011740069 of size: 44, ends @ 4011740113
             Atom minf @ 4011740113 of size: 65701, ends @ 4011805814
                 Atom vmhd @ 4011740121 of size: 20, ends @ 4011740141
                 Atom dinf @ 4011740141 of size: 36, ends @ 4011740177
                     Atom dref @ 4011740149 of size: 28, ends @ 4011740177
                         Atom alis @ 4011740165 of size: 12, ends @ 4011740177
                 Atom stbl @ 4011740177 of size: 65637, ends @ 4011805814
                     Atom stsd @ 4011740185 of size: 229, ends @ 4011740414
                         Atom hvc1 @ 4011740201 of size: 213, ends @ 4011740414                  ~
                     Atom stts @ 4011740414 of size: 24, ends @ 4011740438
                     Atom stsc @ 4011740438 of size: 28, ends @ 4011740466
                     Atom stsz @ 4011740466 of size: 32052, ends @ 4011772518
                     Atom stco @ 4011772518 of size: 32048, ends @ 4011804566
                     Atom stss @ 4011804566 of size: 1248, ends @ 4011805814
     Atom trak @ 4011805814 of size: 464, ends @ 4011806278
         Atom tkhd @ 4011805822 of size: 92, ends @ 4011805914
         Atom mdia @ 4011805914 of size: 364, ends @ 4011806278
             Atom mdhd @ 4011805922 of size: 32, ends @ 4011805954
             Atom hdlr @ 4011805954 of size: 44, ends @ 4011805998
             Atom minf @ 4011805998 of size: 280, ends @ 4011806278
                 Atom gmhd @ 4011806006 of size: 82, ends @ 4011806088
                 Atom dinf @ 4011806088 of size: 36, ends @ 4011806124
                     Atom dref @ 4011806096 of size: 28, ends @ 4011806124
                         Atom alis @ 4011806112 of size: 12, ends @ 4011806124
                 Atom stbl @ 4011806124 of size: 154, ends @ 4011806278
                     Atom stsd @ 4011806132 of size: 50, ends @ 4011806182
                         Atom tmcd @ 4011806148 of size: 34, ends @ 4011806182
                     Atom stts @ 4011806182 of size: 24, ends @ 4011806206
                     Atom stsc @ 4011806206 of size: 28, ends @ 4011806234
                     Atom stsz @ 4011806234 of size: 24, ends @ 4011806258
                     Atom stco @ 4011806258 of size: 20, ends @ 4011806278
     Atom trak @ 4011806278 of size: 64468, ends @ 4011870746
         Atom tkhd @ 4011806286 of size: 92, ends @ 4011806378
         Atom mdia @ 4011806378 of size: 64368, ends @ 4011870746
             Atom mdhd @ 4011806386 of size: 32, ends @ 4011806418
             Atom hdlr @ 4011806418 of size: 44, ends @ 4011806462
             Atom minf @ 4011806462 of size: 64284, ends @ 4011870746
                 Atom gmhd @ 4011806470 of size: 44, ends @ 4011806514
                 Atom dinf @ 4011806514 of size: 36, ends @ 4011806550
                     Atom dref @ 4011806522 of size: 28, ends @ 4011806550
                         Atom alis @ 4011806538 of size: 12, ends @ 4011806550
                 Atom stbl @ 4011806550 of size: 64196, ends @ 4011870746
                     Atom stsd @ 4011806558 of size: 36, ends @ 4011806594
                         Atom gpmd @ 4011806574 of size: 20, ends @ 4011806594                   ~
                     Atom stts @ 4011806594 of size: 24, ends @ 4011806618
                     Atom stsc @ 4011806618 of size: 28, ends @ 4011806646
                     Atom stsz @ 4011806646 of size: 32052, ends @ 4011838698
                     Atom stco @ 4011838698 of size: 32048, ends @ 4011870746
     Atom trak @ 4011870746 of size: 128542, ends @ 4011999288
         Atom tkhd @ 4011870754 of size: 92, ends @ 4011870846
         Atom mdia @ 4011870846 of size: 128442, ends @ 4011999288
             Atom mdhd @ 4011870854 of size: 32, ends @ 4011870886
             Atom hdlr @ 4011870886 of size: 44, ends @ 4011870930
             Atom minf @ 4011870930 of size: 128358, ends @ 4011999288
                 Atom gmhd @ 4011870938 of size: 40, ends @ 4011870978
                 Atom dinf @ 4011870978 of size: 36, ends @ 4011871014
                     Atom dref @ 4011870986 of size: 28, ends @ 4011871014
                         Atom alis @ 4011871002 of size: 12, ends @ 4011871014
                 Atom stbl @ 4011871014 of size: 128274, ends @ 4011999288
                     Atom stsd @ 4011871022 of size: 34, ends @ 4011871056
                         Atom fdsc @ 4011871038 of size: 18, ends @ 4011871056                   ~
                     Atom stts @ 4011871056 of size: 24, ends @ 4011871080
                     Atom stsc @ 4011871080 of size: 28, ends @ 4011871108
                     Atom stsz @ 4011871108 of size: 64092, ends @ 4011935200
                     Atom stco @ 4011935200 of size: 64088, ends @ 4011999288

 ~ denotes an unknown atom
------------------------------------------------------
Total size: 4011999288 bytes; 89 atoms total.
Media data: 4011713292 bytes; 285996 bytes all other atoms (0.007% atom overhead).
Total free atom space: 132 bytes; 0.000% waste.
------------------------------------------------------
AtomicParsley version: 0.9.6 (utf8)
------------------------------------------------------
Movie duration: 320.320 seconds (05:20.32) - 100192.64* kbp/sec bitrate (*=approximate)
Low-level details. Total tracks: 4
Trk  Type  Handler                    Kind  Lang  Bytes
1    vide  GoPro H.265                hvc1  ```   4004088824
2    tmcd  GoPro TCD                  tmcd  ```   4
3    meta  GoPro MET                  gpmd  ```   7367360
4    meta  GoPro SOS                  fdsc  ```   257096

Windows Build error

i downloaded mingw from here [Win-Builds version 1.5]
in which mingw was missing but other files were present like gcc, g++ , libav etc
so i used mingw from msys installation.
then exported the path
$ export PATH=$PATH:"/c/mingw-w64_1.5/bin"
using mingw64.exe on windows 10 64bit, when i run below command :
$ g++ -o untrunc -O3 *.cpp -lavformat -lavcodec -lavutil -std=c++11
i get few error

codec.cpp: In constructor 'Codec::Codec(AVCodecParameters*)':
codec.cpp:24:33: error: invalid use of incomplete type 'class AVCodecParameters'
codec_ = avcodec_find_decoder(c->codec_id);
^
In file included from codec.cpp:1:0:
codec.h:11:7: error: forward declaration of 'class AVCodecParameters'
class AVCodecParameters;
^
codec.cpp:27:43: error: 'avcodec_parameters_to_context' was not declared in this scope
avcodec_parameters_to_context(context_, c);
^
mp4.cpp: In member function 'void Mp4::parseTracks()':
mp4.cpp:326:47: error: 'AVStream' has no member named 'codecpar'
Track track(traks[i], context_->streams[i]->codecpar);

i like to build this repository because it fixes corrupt mp4 files in couple of seconds (tested on ubuntu 18.04 LTS)
for windows we have this repo, but it takes 5 mins to fix 5 mins length video

i tried to use the libav that i built
g++ -o untrunc -I./libav-12.3 *.cpp -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavresample -lavresample -L./libav-12.3/libavutil -lavutil -lpthread -lz -std=c++11

got same error as above.
it looks like libav version that came with mingw installation is different than required.
which version of libav is needed to build this repository ?

Thanks & Regards
Prakash

Error: No codec found!

Hi, I'm having the following error:

Info: reading /mnt/c/Users/purch/Desktop/recover/C0113.MP4
Info: parsing healthy moov atom ...

requests: 4 at offset : 0
requests: 4 at offset : 4
start_ = 0
length_ = 28
name_ = ftyp
requests: 20 at offset : 8

requests: 4 at offset : 28
requests: 4 at offset : 32
start_ = 28
length_ = 148
name_ = uuid
requests: 140 at offset : 36

requests: 4 at offset : 176
requests: 4 at offset : 180
requests: 8 at offset : 184
start_ = 184
length_ = 96468808
name_ = mdat

requests: 4 at offset : 0
requests: 4 at offset : 4
start_ = 96468992
length_ = 3981
name_ = moov

requests: 4 at offset : 8
requests: 4 at offset : 12
start_ = 96469000
length_ = 108
name_ = mvhd
requests: 100 at offset : 16

requests: 4 at offset : 116
requests: 4 at offset : 120
start_ = 96469108
length_ = 2706
name_ = trak

requests: 4 at offset : 124
requests: 4 at offset : 128
start_ = 96469116
length_ = 92
name_ = tkhd
requests: 84 at offset : 132

requests: 4 at offset : 216
requests: 4 at offset : 220
start_ = 96469208
length_ = 36
name_ = edts

requests: 4 at offset : 224
requests: 4 at offset : 228
start_ = 96469216
length_ = 28
name_ = elst
requests: 20 at offset : 232

requests: 4 at offset : 252
requests: 4 at offset : 256
start_ = 96469244
length_ = 2518
name_ = mdia

requests: 4 at offset : 260
requests: 4 at offset : 264
start_ = 96469252
length_ = 32
name_ = mdhd
requests: 24 at offset : 268

requests: 4 at offset : 292
requests: 4 at offset : 296
start_ = 96469284
length_ = 52
name_ = hdlr
requests: 44 at offset : 300

requests: 4 at offset : 344
requests: 4 at offset : 348
start_ = 96469336
length_ = 2426
name_ = minf

requests: 4 at offset : 352
requests: 4 at offset : 356
start_ = 96469344
length_ = 20
name_ = vmhd
requests: 12 at offset : 360

requests: 4 at offset : 372
requests: 4 at offset : 376
start_ = 96469364
length_ = 36
name_ = dinf

requests: 4 at offset : 380
requests: 4 at offset : 384
start_ = 96469372
length_ = 28
name_ = dref
requests: 20 at offset : 388

requests: 4 at offset : 408
requests: 4 at offset : 412
start_ = 96469400
length_ = 2362
name_ = stbl

requests: 4 at offset : 416
requests: 4 at offset : 420
start_ = 96469408
length_ = 462
name_ = stsd
requests: 454 at offset : 424

requests: 4 at offset : 878
requests: 4 at offset : 882
start_ = 96469870
length_ = 24
name_ = stts
requests: 16 at offset : 886

requests: 4 at offset : 902
requests: 4 at offset : 906
start_ = 96469894
length_ = 976
name_ = ctts
requests: 968 at offset : 910

requests: 4 at offset : 1878
requests: 4 at offset : 1882
start_ = 96470870
length_ = 28
name_ = stsc
requests: 20 at offset : 1886

requests: 4 at offset : 1906
requests: 4 at offset : 1910
start_ = 96470898
length_ = 740
name_ = stsz
requests: 732 at offset : 1914

requests: 4 at offset : 2646
requests: 4 at offset : 2650
start_ = 96471638
length_ = 76
name_ = stco
requests: 68 at offset : 2654

requests: 4 at offset : 2722
requests: 4 at offset : 2726
start_ = 96471714
length_ = 48
name_ = stss
requests: 40 at offset : 2730

requests: 4 at offset : 2770
requests: 4 at offset : 2774
start_ = 96471762
length_ = 52
name_ = uuid
requests: 44 at offset : 2778

requests: 4 at offset : 2822
requests: 4 at offset : 2826
start_ = 96471814
length_ = 560
name_ = trak

requests: 4 at offset : 2830
requests: 4 at offset : 2834
start_ = 96471822
length_ = 92
name_ = tkhd
requests: 84 at offset : 2838

requests: 4 at offset : 2922
requests: 4 at offset : 2926
start_ = 96471914
length_ = 36
name_ = edts

requests: 4 at offset : 2930
requests: 4 at offset : 2934
start_ = 96471922
length_ = 28
name_ = elst
requests: 20 at offset : 2938

requests: 4 at offset : 2958
requests: 4 at offset : 2962
start_ = 96471950
length_ = 372
name_ = mdia

requests: 4 at offset : 2966
requests: 4 at offset : 2970
start_ = 96471958
length_ = 32
name_ = mdhd
requests: 24 at offset : 2974

requests: 4 at offset : 2998
requests: 4 at offset : 3002
start_ = 96471990
length_ = 52
name_ = hdlr
requests: 44 at offset : 3006

requests: 4 at offset : 3050
requests: 4 at offset : 3054
start_ = 96472042
length_ = 280
name_ = minf

requests: 4 at offset : 3058
requests: 4 at offset : 3062
start_ = 96472050
length_ = 16
name_ = smhd
requests: 8 at offset : 3066

requests: 4 at offset : 3074
requests: 4 at offset : 3078
start_ = 96472066
length_ = 36
name_ = dinf

requests: 4 at offset : 3082
requests: 4 at offset : 3086
start_ = 96472074
length_ = 28
name_ = dref
requests: 20 at offset : 3090

requests: 4 at offset : 3110
requests: 4 at offset : 3114
start_ = 96472102
length_ = 220
name_ = stbl

requests: 4 at offset : 3118
requests: 4 at offset : 3122
start_ = 96472110
length_ = 52
name_ = stsd
requests: 44 at offset : 3126

requests: 4 at offset : 3170
requests: 4 at offset : 3174
start_ = 96472162
length_ = 24
name_ = stts
requests: 16 at offset : 3178

requests: 4 at offset : 3194
requests: 4 at offset : 3198
start_ = 96472186
length_ = 40
name_ = stsc
requests: 32 at offset : 3202

requests: 4 at offset : 3234
requests: 4 at offset : 3238
start_ = 96472226
length_ = 20
name_ = stsz
requests: 12 at offset : 3242

requests: 4 at offset : 3254
requests: 4 at offset : 3258
start_ = 96472246
length_ = 76
name_ = stco
requests: 68 at offset : 3262

requests: 4 at offset : 3330
requests: 4 at offset : 3334
start_ = 96472322
length_ = 52
name_ = uuid
requests: 44 at offset : 3338

requests: 4 at offset : 3382
requests: 4 at offset : 3386
start_ = 96472374
length_ = 553
name_ = trak

requests: 4 at offset : 3390
requests: 4 at offset : 3394
start_ = 96472382
length_ = 92
name_ = tkhd
requests: 84 at offset : 3398

requests: 4 at offset : 3482
requests: 4 at offset : 3486
start_ = 96472474
length_ = 20
name_ = tref

requests: 4 at offset : 3490
requests: 4 at offset : 3494
start_ = 96472482
length_ = 12
name_ = cdsc
requests: 4 at offset : 3498

requests: 4 at offset : 3502
requests: 4 at offset : 3506
start_ = 96472494
length_ = 36
name_ = edts

requests: 4 at offset : 3510
requests: 4 at offset : 3514
start_ = 96472502
length_ = 28
name_ = elst
requests: 20 at offset : 3518

requests: 4 at offset : 3538
requests: 4 at offset : 3542
start_ = 96472530
length_ = 345
name_ = mdia

requests: 4 at offset : 3546
requests: 4 at offset : 3550
start_ = 96472538
length_ = 32
name_ = mdhd
requests: 24 at offset : 3554

requests: 4 at offset : 3578
requests: 4 at offset : 3582
start_ = 96472570
length_ = 61
name_ = hdlr
requests: 53 at offset : 3586

requests: 4 at offset : 3639
requests: 4 at offset : 3643
start_ = 96472631
length_ = 244
name_ = minf

requests: 4 at offset : 3647
requests: 4 at offset : 3651
start_ = 96472639
length_ = 12
name_ = nmhd
requests: 4 at offset : 3655

requests: 4 at offset : 3659
requests: 4 at offset : 3663
start_ = 96472651
length_ = 36
name_ = dinf

requests: 4 at offset : 3667
requests: 4 at offset : 3671
start_ = 96472659
length_ = 28
name_ = dref
requests: 20 at offset : 3675

requests: 4 at offset : 3695
requests: 4 at offset : 3699
start_ = 96472687
length_ = 188
name_ = stbl

requests: 4 at offset : 3703
requests: 4 at offset : 3707
start_ = 96472695
length_ = 32
name_ = stsd
requests: 24 at offset : 3711

requests: 4 at offset : 3735
requests: 4 at offset : 3739
start_ = 96472727
length_ = 24
name_ = stts
requests: 16 at offset : 3743

requests: 4 at offset : 3759
requests: 4 at offset : 3763
start_ = 96472751
length_ = 28
name_ = stsc
requests: 20 at offset : 3767

requests: 4 at offset : 3787
requests: 4 at offset : 3791
start_ = 96472779
length_ = 20
name_ = stsz
requests: 12 at offset : 3795

requests: 4 at offset : 3807
requests: 4 at offset : 3811
start_ = 96472799
length_ = 76
name_ = stco
requests: 68 at offset : 3815

requests: 4 at offset : 3883
requests: 4 at offset : 3887
start_ = 96472875
length_ = 52
name_ = uuid
requests: 44 at offset : 3891

requests: 4 at offset : 3935
requests: 4 at offset : 3939
start_ = 96472927
length_ = 46
name_ = uuid
requests: 38 at offset : 3943

requests: 4 at offset : 3981
requests: 4 at offset : 3985
start_ = 96472973
length_ = 1520
name_ = meta
requests: 1512 at offset : 3989
Composition time offset atom found. Out of order samples possible.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/c/Users/purch/Desktop/recover/C0113.MP4':
Metadata:
major_brand : XAVC
minor_version : 16785407
compatible_brands: XAVCmp42iso2
creation_time : 2018-09-19T00:40:55.000000Z
Duration: 00:00:07.51, start: 0.000000, bitrate: 102769 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/unknown/bt709), 3840x2160 [SAR 1:1 DAR 16:9], 96970 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2018-09-19T00:40:55.000000Z
handler_name : Video Media Handler
encoder : AVC Coding
Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
Metadata:
creation_time : 2018-09-19T00:40:55.000000Z
handler_name : Sound Media Handler
Stream #0:2(und): Data: none (rtmd / 0x646D7472), 196 kb/s (default)
Metadata:
creation_time : 2018-09-19T00:40:55.000000Z
handler_name : Timed Metadata Media Handler
timecode : 13:35:47:00
found avcC after: 102
remaining len:360
parsing avcC ...
len_sps: 52
decoding SPS ...
log2_max_frame_num: 6
Info: avcC got decoded
No codec found!

My reference file and damaged file are generated from a Sony A7RIII and I have the according XMLs.
The reference file plays just great.

Do you have any clues on how to fix this?

expression result unused [-Wunused-value]

Hey, I've been working at this for days upon days now trying to get my GoPro footage to come back to life. I've started with ponchio's release, but it was creating a 3kb file and giving me an error: [aac @ 0x7f89b0000a00] channel element 2.3 is not allocated

I stumbled across your fork, as you have the most recently updated version. unfortunately, I'm getting tons of warnings: expression result unused [-Wunused-value]

Theses warnings are showing for common.h.

an example error is:

7 warnings generated.
In file included from sps-info.cpp:1:
In file included from ./sps-info.h:4:
./common.h:19:2: warning: expression result unused [-Wunused-value]
        creator{ 0, ( std::cout << (std::forward<Args>(args)), 0) ... };
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./common.h:32:2: note: in instantiation of function template specialization 'logg<char const (&)[18]>'
      requested here
        logg(std::forward<Args>(x)...);
        ^
sps-info.cpp:25:2: note: in instantiation of function template specialization 'logg<char const (&)[18]>'
      requested here
        logg(V, "decoding SPS ...\n");
        ^
In file included from sps-info.cpp:1:
In file included from ./sps-info.h:4:
./common.h:19:2: warning: expression result unused [-Wunused-value]
        creator{ 0, ( std::cout << (std::forward<Args>(args)), 0) ... };
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./common.h:32:2: note: in instantiation of function template specialization 'logg<char const (&)[21], int &,
      char>' requested here
        logg(std::forward<Args>(x)...);
        ^
sps-info.cpp:32:2: note: in instantiation of function template specialization 'logg<char const (&)[21], int
      &, char>' requested here
        logg(V, "log2_max_frame_num: ", log2_max_frame_num, '\n');

Also, I had to tweak the command line when I compile everything:

g++ -o untrunc -O3 -I./libav-12.3 *.cpp -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavresample -lavresample -L./libav-12.3/libavutil -lavutil -lpthread -lz -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration -std=c++11 -lbz2

any help would be great

Sample file from RTMP recorder

Thank you so much for maintaining this fork!

I've got an issue with server shutting down during RTMP recording and now trying to recover the mp4 file, however getting some errors that are hard to decode, and not found in this repository closed issues.

Can you please clarify what some of them mean? It does look like recovery didn't work, unfortunately. Any recommendation?

untrunc# docker run -v ~/untrunc:/streams untrunc -s /streams/LIAGXQUE.mp4 /streams/EBYWVSIQ.mp4
WARNING: Because of internal decoder changes, using ffmpeg '3.4.6-0ubuntu0.18.04.1' with '-s' can be slow!
You are advised to compile untrunc against ffmpeg 3.3!
See the README.md on how to do that.
Info: version '7e38461-dirty' using ffmpeg '3.4.6-0ubuntu0.18.04.1'
Info: reading /streams/LIAGXQUE.mp4
Info: parsing healthy moov atom ...
Warning: avcC was not decoded correctly

Info: reading mdat from truncated file ...
Info: Muted ffmpeg to reduce redundant warnings/errors. Use '-do' to see them.
Failed reading golomb: too large!
Warning: Invalid slice type, probably this is not an avc1 sample
Warning: Invalid slice type, probably this is not an avc1 sample
Warning: guessed frame durations of 'mp4a' will probably be wrong!
Warning: guessed frame durations of 'avc1' will probably be wrong!
Info: Found 77 packets ( mp4a: 0 avc1: 77 avc1-keyframes: 0 )
Info: Duration of mp4a: (0 ms)
Info: Duration of avc1: 2s 376ms (2376 ms)
Warning: Unknown sequences: 78
Warning: Bytes NOT matched: 260MiB (99.99%)
Info: pruned empty 'mp4a' track
Info: saving /streams/EBYWVSIQ.mp4_fixed-s1.mp4
Could not create file for writing: /streams/EBYWVSIQ.mp4_fixed-s1.mp4

Here's ffprobe of healthy file:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'streams/LIAGXQUE.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:03:10.16, start: 0.000000, bitrate: 3144 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, stereo, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 3074 kb/s, 29.90 fps, 90k tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler

Thank you in advance

track 'mp4v' is not supported with ffmpeg > 3.3!

Here's the error I'm getting:

Info: version '56aee28' using ffmpeg 'n4.2.3'
Info: reading voy_101_000_2.00x_1440x1152_Gaia-HQ.mp4
Info: parsing healthy moov atom ... 

Error: track 'mp4v' is not supported with ffmpeg > 3.3!
Help: You need to build against ffmpeg 3.3.
      See the README.md on how to do that.

I need an older ffmpeg version for it to work?

Error: unable to find correct codec -> premature end (~0%)

Info: version '71d1a65' using ffmpeg '3.3.4'
Info: reading ok.mp4
Info: parsing healthy moov atom ...
Composition time offset atom found. Out of order samples possible.

Info: reading mdat from truncated file ...
Error: unable to find correct codec -> premature end (~0%)
try '-s' to skip unknown sequences

Warning: guessed frame durations of 'mp4a' will probably be wrong!
Warning: guessed frame durations of 'avc1' will probably be wrong!
Info: Found 0 packets ( mp4a: 0 avc1: 0 avc1-keyframes: 0 )
Info: Duration of mp4a: (0 ms)
Info: Duration of avc1: (0 ms)
Info: pruned empty 'mp4a' track
Info: pruned empty 'avc1' track
Info: saving no.mp4_fixed.mp4

Invalid length -1 / unable to find correct codec

I have a broken .3gp audio file whose codec is (I think) amr_wb. I tried to run untrunc with the broken file against two different correct files from the same phone (one shorter and another longer) and I get a 670-byte output file only.

Info: reading /tmp/ok2.3gp
Info: parsing healthy moov atom ... 
Info: parsing mdat from truncated file ... 
Error: Invalid length. -1. Wrong match in track: 0
Error: unable to find correct codec -> premature end
Info: Found 0 packets ( sawb: 0 )
Info: Duration of sawb = 0s
Info: saving /tmp/mal.3gp_fixed.mp4

I tried with the standard libav package and also compiling the latest libav from source, selecting both the default 'amr' codec and also the 'opencore amr' codec, but the output is the same.
Are audio-only files also supported?

windows build question

Hi I am the guy that you helped with the windows build. I got the file working but the last 2 minutes of the video or so is frozen. Just wondering if there might be some command line varibles I can type in to get those last 2 minutes.

Also I did notice that the audio is not synced and wasn't sure how to fix it. I have to say I am still very happy but just wondering if you might have an idea. Just got back and donated btw. :)

Failing assert: assert(tag == 5);

I have a file which is failing this assert. It goes straight to tag == 6.

If I just remove the assert I then get this:

[mp3 @ 0x55fb59e6a560] Multiple frames in a packet.
[mp3 @ 0x55fb59e6a560] Got unexpected packet size after a partial decode

Invalid offset in track--large files

Hey,

I'm trying to recover a very large mp4 file (~13GB) and untrunc can't seem to handle it. I've tried running with -i and -a against a known-good mp4 and I'm getting the same errors. I have plenty of RAM (~32gb) and it only uses up to 20GB or so when it's running, so it doesn't seem to be a memory issue. The error output looks like a 32 bit integer is wrapping around and coming back negative:

Composition time offset atom found. Out of order samples possible.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Hellblade_Video_1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.84.100
  Duration: 01:50:19.03, start: 0.000000, bitrate: 20506 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 20368 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 122 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
found avcC after: 102
remaining len:50
parsing avcC ...
len_sps: 26
decoding SPS ...
log2_max_frame_num: 5
Info: avcC got decoded
i = 25078
offset = -2147278276
mdat->start = 40
mdat->length = 16953873145
offset - mdat->start = -2147278316
Invalid offset in track!

Looking at the code, I'm seeing lots of 32 bit addresses, particularly in bitmasking operations in codec.cpp, so I'm wondering if the current codebase just can't handle files over 0xFFFFFFFF in size? If that's the case, how much work do you think it would be to patch in support for bigger files?

unable to find image locally

Hey Anthwlock,

getting some strange language. Any ideas?

Benjamins-MBP:untrunc-latest bronco$ docker run -v ~/Videos/:/mnt untrunc ~/Downloads/Videos/C0003.mp4 ~/Downloads/Videos/C0002.mp4
Info: version '' using ffmpeg '3.4.6-0ubuntu0.18.04.1'
Info: reading /Users/bronco/Downloads/Videos/C0003.mp4
Could not open file: /Users/bronco/Downloads/Videos/C0003.mp4

invalid atom name: 'drm ' + skip audio

The space is clearly the issue. I removed the check and it went further.

Yet now there is another issue: "This audio codec is EVIL, there is no hope to guess it". Is there a way to skipp audio?

Stuttery video (guessed frame durations of 'avc1' will probably be wrong!)

Running master via Docker on macOS.

Info: version '56aee28-dirty' using ffmpeg '3.4.6-0ubuntu0.18.04.1'
Info: reading /mnt/ok.mp4
Info: parsing healthy moov atom ...
Composition time offset atom found. Out of order samples possible.

Info: reading mdat from truncated file ...
Info: Muted ffmpeg to reduce redundant warnings/errors. Use '-do' to see them.
Error: unable to find correct codec -> premature end (~100%)
try '-s' to skip unknown sequences

Warning: guessed frame durations of 'avc1' will probably be wrong!
Info: Found 142090 packets ( mp4a: 86640 avc1: 55450 avc1-keyframes: 617 )
Info: Duration of mp4a: 30min 48s 320ms (1848320 ms)
Info: Duration of avc1: 30min 48s 374ms (1848374 ms)
Info: saving /mnt/broken.mp4_fixed.mp4

2 warnings were hidden!

The broken.mp4_fixed.mp4 file plays, but stutters throughout in QuickTime Player. VLC plays it more smoothly, but with occasional pauses in the video and the audio is a little out-of-sync.

I'm guessing the “Warning: guessed frame durations of 'avc1' will probably be wrong!” is at the heart of the issue, here.

Error: bad track: 'mp4v'

I'm trying to fix a broken 3GP file. I have a couple of working files from the same camera. When I run untrunc I get this error.

Info: version '' using ffmpeg '4.1.3-0ubuntu1'
Info: reading /data/working.3GP
Info: parsing healthy moov atom ... 

Info: unknown track 'mp4v' found -> fallback to dynamic stats
Error: bad track: 'mp4v'

Any idea what I can do to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.