Drive disaster

I found this software project here Untrunc: recover a truncated Mp4 which looks promising but it needs to be compiled from source and some dependencies installed as well

Can you tell me if you think it’s worth a shot ?

Many thanks

Graeme

Build it from source in what OS/version/architecture ?

Build it from source in what OS/version/architecture ?

Peppermint 4 32bit

Many thanks

Graeme

Just tried it on my machine and it will not run. It is calling avcodec_open from ffmpeg, instead of avcodec_open2 which requires few more arguments than supplied.
It will not work unless it is re-factored against the replacement function call.
[EDIT]
Got it working and runs OK, but I could only test it with good videos.
The changes required on my machine:

In untrunc.pro make it to look like this:

INCLUDEPATH += -I/usr/local/lib
LIBS += -L/usr/local/lib -lavformat -lavcodec -lavutil

#INCLUDEPATH += -I../libav-0.8.7/libavformat -I../libav-0.8.7/libavcodec -I../libav-0.8.7/libavutil
#LIBS += ../libav-0.8.7/libavformat/libavformat.a ../libav-0.8.7/libavcodec/libavcodec.a ../libav-0.8.7/libavutil/libavutil.a
LIBS += -lz

then in track.cpp change:

if(!codec.codec) throw string("No codec found!");
    //if(avcodec_open(codec.context, codec.codec)<0)
        //throw string("Could not open codec: ") + codec.context->codec_name;
    if(avcodec_open2(codec.context, codec.codec,NULL)<0)
        throw string("Could not open codec: ") + codec.context->codec_name;
It will not work unless it is re-factored against the replacement function call.

Thanks for trying it out I just thought it might work and worth a look.

there is a Windows based program that looks useful Video Repair Tool - Grau GmbH Hardware & Software Solutions
but they want about £30 for 5 repairs and I’ve got over 300 corrupted files so that’s out of the question

Thanks again

Graeme

See edit above :slight_smile: 8)

Ok well first I have to get untruc installed and I’ve never compiled from source so I’ll need a little help with that and the code changes you posted look a little involved so if you’re prepared to help me through it I’ll have a go, but if you think I’m outta my depth I’ll understand

Many thanks

Graeme

There are only few steps to get it to run (part of the modifications).
The instructions are well written on the Github page (partially repeated here):

I did not do this step as I got all the developers bits already but you will probably need it.

sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev

Download the file:

wget https://github.com/ponchio/untrunc/archive/master.zip

Unzip it:

unzip master.zip

Change into the directory:

cd untrunc-master

You will need to modify the files at this stage.

Compile the source code using this command (all one line):

g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil

then run it:

./untrunc /path/to/working-video.m4v /path/to/broken-video.m4v

If you are game for that then lets begin…

OK I pre-empted a little and installed untrunc by following the instructions here GitHub - ponchio/untrunc: Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video. which look exactly the same as your instructions.

But there’s a few things I don’t understand about the last command

./untrunc /path/to/working-video.m4v /path/to/broken-video.m4v

(1) Does working-video.m4v mean any working video ?

(2) Does broken-video.m4v mean any broken video ?

(3) Where will untrunc put the result ?

(4) What will the result be called ?

Sorry if these are stupid questions

Graeme

which look exactly the same as your instructions.

Because they are the same (see link above) :wink:
(1) Does working-video.m4v mean any working video ?
Yes, as long it is of the same container (like .mp4 or .mov) and it will be used as a reference.
(2) Does broken-video.m4v mean any broken video ?
The broken video is the one you are trying to fix.
(3) Where will untrunc put the result ?
Same folder as the one you try to fix.
(4) What will the result be called ?
It will be called the same as the broken video except it will also contain “fixed” in the name.

graeme@Linux1 ~ $ ./untrunc /home/graeme/ref.mp4 /home/graeme/001.mp4
bash: ./untrunc: No such file or directory
graeme@Linux1 ~ $ ./untrunc /home/graeme/ref.mp4 /home/graeme/001.mp4
bash: ./untrunc: No such file or directory
graeme@Linux1 ~ $ /untrunc /home/graeme/ref.mp4 /home/graeme/001.mp4
bash: /untrunc: No such file or directory
graeme@Linux1 ~ $ 

Sorry there’s obviously something I’m not getting right :-[

Graeme

SeZo I missed out a stage in the installation process it my fault for getting ahead of myself once again sorry but I didn’t modify the files, can we fix this or start over ?

Graeme

It might not need the file fix, if you have managed to compile without errors.
Where did you extract the files to?

Where did you extract the files to?

/home

Did you cd into the untrunc-master folder before you run that command?

ls /home

on mine it is in /home//untrunc-master/

Did you cd into the untrunc-master folder before you run that command?

No :-[

So, just cd in first then run again:

./untrunc /home/graeme/ref.mp4 /home/graeme/001.mp4
So, just cd in first then run again:

Ok I did that and here’s the output

[aac @ 0x862e260] Sample rate index in program config element does not match the sample rate index configured by the container.
[aac @ 0x862e260] Not evaluating a further program_config_element as this construct is dubious at best.
[aac @ 0x862e260] channel element 0.10 is not allocated
Begin: a594173a 65b3f989
graeme@Linux1 ~/untrunc-master $ 

It placed a fiixed file in my home folder and when I ran it I got sound but no video, here’s the error message flagged up by VLC

No suitable decoder module: VLC does not support the audio or video format "h264". Unfortunately there is no way for you to fix this.

If nothing else it encouraging don’t you think ?

Graeme

That is encouraging.
You could try mplayer to play the file instead:

mplayer <filename>

or try to remux it with ffmpeg:

ffmpeg -y -i <oldfile.mp4> -acodec copy -vcodec copy <newfile.mp4>

or

ffmpeg -y -i <oldfile.mp4> -acodec copy -vcodec libx264 <newfile.mp4>

Ok I’ll try these things in the morning and post back, my eyes are getting heavy

I’m well pleased with what we’ve achieved tonight and if nothing else getting the sound back will allow me to identify the corrupted files and narrow it down to the ones that matter which is really only a few

Thank you so much for your help :slight_smile:

Graeme