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

libav isn't enough to build untrunc on mac #57

Open chundongwang opened 8 years ago

chundongwang commented 8 years ago

I can do it after brew install ffmpeg --with-libvpx but not just with brew install libvpx. Not sure what exactly is blocking.

The error message was

g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil
track.cpp:40:10: fatal error: 'libavcodec/avcodec.h' file not found
#include "libavcodec/avcodec.h"
xdgc commented 8 years ago

Install libav from source: https://libav.org/. When configuring, add --arch=x86_64 to the ./configure command.

Apply this patch to untrunc, and make. untrunc.txt

jauling commented 7 years ago

I went ahead and installed a few packages using brew: libav 11.4_2 libvpx 1.6.1 ffmpeg 3.2.2

Not sure if I needed all of them or not. I also ran brew doctor to make sure things look good on my system.

I then applied the untrunc.txt patch:

$ patch < untrunc.txt 
patching file Makefile
patching file atom.cpp
patching file endian.h
patching file file.cpp
patching file track.cpp

Then I ran make, but I ran into the same error as the original poster of this issue.

$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -I/sw/include  -o main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -I/sw/include  -o atom.o atom.cpp
atom.cpp:17:9: warning: delete called on non-final 'Atom' that has virtual functions but non-virtual destructor
      [-Wdelete-non-virtual-dtor]
        delete children[i];
        ^
atom.cpp:46:27: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'long long'
      [-Wsign-compare]
        if(content.size() < length -8)
           ~~~~~~~~~~~~~~ ^ ~~~~~~~~~
atom.cpp:231:13: warning: delete called on non-final 'Atom' that has virtual functions but non-virtual destructor
      [-Wdelete-non-virtual-dtor]
            delete child;
            ^
atom.cpp:257:27: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'long long'
      [-Wsign-compare]
    assert(content.size() >= offset + 4);
           ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/assert.h:93:25: note: 
      expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
4 warnings generated.
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -I/sw/include  -o mp4.o mp4.cpp
mp4.cpp:29:10: fatal error: 'libavcodec/avcodec.h' file not found
#include "libavcodec/avcodec.h"
         ^
1 error generated.
make: *** [mp4.o] Error 1
jeffbski commented 7 years ago

@xdgc patch worked for me on Mac OS X 10.10.5.

I had previously installed libav from brew and just cloned the untrunc repo and run the g++ compile command.

Thanks!

shivanraptor commented 6 years ago

I'm using macOS 10.13.1.

The error I encountered is, endian.h not found. I have to replace:

#include <endian.h>

with:

#include <machine/endian.h>