Mac OS - bash: ./untrunc: No such file or directory
I have compiled untrunc as per README doc guide on Mac OS
wget https://github.com/ponchio/untrunc/archive/master.zip
unzip master.zip
cd untrunc-master
wget http://libav.org/releases/libav-0.8.7.tar.xz
tar xvf libav-0.8.7.tar.xz
cd libav-0.8.7
./configure
make
cd ..
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -I./libav-0.8.7 -L./libav-0.8.7/libavformat -lavformat -L./libav-0.8.7/libavcodec -lavcodec -L./libav-0.8.7/libavutil -lavutil -lpthread
but I get this error when I try to use it:
-bash: ./untrunc: No such file or directory
I have tried changing my working directory by cd /Users/Home/untrunc-master but I still get the same error.
When I open up untrunc-master folder to check, I see untrunc.pro file, so I tried using that and got -bash: ./untrunc.pro: Permission denied
Please help me
can you do file /path/to/untrunc?
I once had this issue because I tried to run a 32bit executable on a 64bit system.
@anthwlock Hi, I've tried your suggestion, typed this into terminal file /path/to/untrunc
but got this error msg
/path/to/untrunc: cannot open '/path/to/untrunc' (No such file or directory)
Maybe replace '/path/to/untrunc' with the path to untrunc?
@anthwlock The folder where I ran the command unzip master.zip and then cd untrunc-master, is that the path to untrunc?
You are then in the folder containing the untrunc executable.
You can do pwd to print the working/current directory.
@anthwlock
This is my untrunc-master folder. I can only see one file named untrunc which is the untrunc.pro file. Is that the untrunc executable? Or my untrunc executable is missing?

Also at the https://github.com/ponchio/untrunc page, I see the same untrunc.pro but not untrunc.

untrunc.pro is a project file used by qtcreator.
Maybe your compilation failed? If so, try to compile my fork, the compilation is way easier there.
@anthwlock sorry for the late reply.
Mac OS doesn't support apt-get, so I googled for a way around it, the suggestion was to use homebrew. Tried brew install libavformat-dev libavcodec-dev libavutil-dev but it doesn't work.
I think brew install ffmpeg should do.
@anthwlock I've actually had ffmpeg installed long ago. Please guide me along step by step to install and compile untrunc using your fork, taking into consideration my Mac OS already has ffmpeg installed.
The only step needed after you have ffmpeg and its public headers is make.
If it fails please post it's output
@anthwlock sorry please bear with me, I'm really lost. I'm not familiar with command line, if it's a step by step guide, I can follow it to a T.
What's public headers?
and
Do I just type make and enter? Do I need any prefix or suffix to it?
The public headers are what tells the c/c++ compiler what the ffmpeg library has to offer. You don't need these in order to run applications using ffmpeg, but only in order to build them.
I assume that brew install ffmpeg also installs these public headers, and that you used brew to install ffmpeg.
Yes, just typing make should suffice. It won't install anything, it will just create the untrunc executable in the directory where the Makefile is, which should be the current directory.
@anthwlock I think it failed to compile at make, this is the output:
make untrunc: ffmpeg: shared
c++ -MMD -MP -DUNTR_VERSION="" -std=c++11 -g -o .build_shared/src/atom.o -c src/atom.cpp
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:41:12: error: unknown type name 'off64_t'; did you mean 'off_t'?
void seek(off64_t p);
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:42:16: error: unknown type name 'off64_t'; did you mean 'off_t'?
void seekSafe(off64_t p);
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:43:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t pos();
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:45:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t length() { return size; }
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:57:24: error: unknown type name 'off64_t'; did you mean 'off_t'?
const uchar* getPtrAt(off64_t pos, int size_requested);
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:63:20: error: unknown type name 'off64_t'; did you mean 'off_t'?
size_t fillBuffer(off64_t location);
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:65:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t size;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:67:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t buf_begin = 0;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:68:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t buf_off = 0;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:77:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t pos();
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
src/atom.h:49:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
static off64_t findNextAtomOff(FileRead& file, const Atom* start...
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
src/atom.cpp:88:1: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t Atom::findNextAtomOff(FileRead& file, const Atom* start_atom, bo...
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef darwin_off_t off_t;
^
src/atom.cpp:90:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t next_off = start_atom->start + start_atom->length;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
src/atom.cpp:101:6: error: unknown type name 'off64_t'; did you mean 'off_t'?
for(off64_t off=start_atom->start+8; off < file.length();) {
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
src/atom.cpp:117:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t off = findNextAtomOff(file, &atom);
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
src/atom.cpp:128:4: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t next_off = off + length;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
src/atom.cpp:395:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t start = output.pos();
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
src/atom.cpp:399:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t offset = file_begin;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here
typedef _darwin_off_t off_t;
^
src/atom.cpp:416:2: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t end = output.pos();
^~~~~~~
off_t
/usr/include/sys/types/off_t.h:31:25: note: 'off_t' declared here
typedef darwin_off_t off_t;
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:9:
src/common.h:31:2: warning: expression result unused [-Wunused-value]
creator{ 0, ( std::cout << (std::forward<Args>(args)), 0) ... };
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/common.h:46:2: note: in instantiation of function template specialization
'logg<char const (&)[10], long long &, char>' requested here
logg(std::forward<Args>(x)...);
^
src/atom.cpp:36:2: note: in instantiation of function template specialization
'logg<char const (&)[10], long long &, char>' requested here
logg(VV, "start = ", start, '\n');
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:9:
src/common.h:31:2: warning: expression result unused [-Wunused-value]
creator{ 0, ( std::cout << (std::forward<Args>(args)), 0) ... };
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/common.h:46:2: note: in instantiation of function template specialization
'logg<char const (&)[11], long long &, char>' requested here
logg(std::forward<Args>(x)...);
^
src/atom.cpp:37:2: note: in instantiation of function template specialization
'logg<char const (&)[11], long long &, char>' requested here
logg(VV, "length = ", length, '\n');
^
In file included from src/atom.cpp:2:
In file included from src/atom.h:9:
src/common.h:31:2: warning: expression result unused [-Wunused-value]
creator{ 0, ( std::cout << (std::forward<Args>(args)), 0) ... };
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/common.h:46:2: note: in instantiation of function template specialization
'logg<char const (&)[9], std::1::basic_string
Please try this branch.
The problem was that g++ defines _LARGEFILE64_SOURCE, but clang++ does not.
@anthwlock sorry I got busy suddenly and couldn't try it out earlier. using the branch you recommended, I still have some errors:
make untrunc: ffmpeg: shared
c++ -MMD -MP -DUNTR_VERSION="" -std=c++11 -Doff64_t=__off64_t -g -o .build_shared/src/atom.o -c src/atom.cpp
In file included from src/atom.cpp:2:
In file included from src/atom.h:10:
src/file.h:41:12: error: unknown type name '__off64_t'; did you mean
'__int64_t'?
void seek(off64_t p);
^~~~~~~
__int64_t
Ok, does it work now?
@anthwlock sorry it still doesn't work, it looks like a different set of errors
make untrunc: ffmpeg: shared
c++ -MMD -MP -DUNTR_VERSION="" -std=c++11 -D_LARGEFILE64_SOURCE -g -o .build_shared/src/atom.o -c src/atom.cpp In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:41:12: error: unknown type name 'off64_t'; did you mean 'off_t'? void seek(off64_t p); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:42:16: error: unknown type name 'off64_t'; did you mean 'off_t'? void seekSafe(off64_t p); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:43:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t pos(); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:45:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t length() { return size; } ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:57:24: error: unknown type name 'off64_t'; did you mean 'off_t'? const uchar* getPtrAt(off64_t pos, int size_requested); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:63:20: error: unknown type name 'off64_t'; did you mean 'off_t'? size_t fillBuffer(off64_t location); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:65:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t size; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:67:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t buf_begin = 0; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:68:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t buf_off = 0; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: In file included from src/atom.h:10: src/file.h:77:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t pos(); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ In file included from src/atom.cpp:2: src/atom.h:49:9: error: unknown type name 'off64_t'; did you mean 'off_t'? static off64_t findNextAtomOff(FileRead& file, const Atom* start... ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ src/atom.cpp:88:1: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t Atom::findNextAtomOff(FileRead& file, const Atom* start_atom, bo... ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef darwin_off_t off_t; ^ src/atom.cpp:90:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t next_off = start_atom->start + start_atom->length; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ src/atom.cpp:101:6: error: unknown type name 'off64_t'; did you mean 'off_t'? for(off64_t off=start_atom->start+8; off < file.length();) { ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ src/atom.cpp:117:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t off = findNextAtomOff(file, &atom); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ src/atom.cpp:128:4: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t next_off = off + length; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ src/atom.cpp:395:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t start = output.pos(); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef _darwin_off_t off_t; ^ src/atom.cpp:399:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t offset = file_begin; ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ src/atom.cpp:416:2: error: unknown type name 'off64_t'; did you mean 'off_t'? off64_t end = output.pos(); ^~~~~~~ off_t /usr/include/sys/_types/_off_t.h:31:25: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ 19 errors generated. make: *** [.build_shared/src/atom.o] Error 1
Replaced all off64_t with off_t and instead used -D_FILE_OFFSET_BITS=64.
Now it should work!
Yes, it worked now! THANK YOU SO MUCH! You have no idea how you have saved my life. That damaged video meant a lot to me, and now it's finally repaired. Thank you again for your patience to help me with all the technical issues that I have no clue about. You are a saint @anthwlock !
no problem :)