Giter Site home page Giter Site logo

newhouseb / untrunc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ponchio/untrunc

0.0 2.0 0.0 186 KB

Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video.

License: GNU General Public License v2.0

C++ 77.08% QMake 0.82% C 21.31% Dockerfile 0.79%

untrunc's Introduction

Untrunc

Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video. And some luck. Also works the same way with audio like m4a.

You need:

  • Another video file which isn't broken
  • Libav
  • Basic ability to use a command line

Installing on Ubuntu

If you have an old Ubuntu version or other operational system, you might need to manually install a recent Libav version, go to the bottom of the page for instructions.

Install some pre-requisite libraries with this command:

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

Download the source code from GitHub at https://github.com/ponchio/untrunc

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

Unzip the source code:

unzip master.zip

Go into the directory where it's been unzipped:

cd untrunc-master

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

Installing on other operating systems (Manual Libav installation)

Because Untrunc uses Libav internal headers and internal headers are not included in application development packages, you must build Libav from source.

Download the Untrunc source code from GitHub:

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

Download the Libav sources from either the download page or its GitHub mirror:

wget https://libav.org/releases/libav-12.3.tar.xz
[or:  wget https://github.com/libav/libav/archive/v12.3.zip ]

Unzip the Untrunc source code:

unzip master.zip

Unzip the Libav source code into the Untrunc source directory with either:

tar -xJf libav-12.3.tar.xz -C untrunc-master
[or:  unzip v12.3.zip -d untrunc-master ]

Go into the directory where it's been unzipped:

cd untrunc-master

Build the Libav library:

cd libav-12.3/
./configure
make
cd ..

Depending on your system you may need to install additional packages if configure complains about them. If configure complains about nasm/yasm not found, you can either install Nasm or Yasm or tell configure not to use a stand-alone assembler with --disable-yasm.

Build the untrunc executable:

g++ -o untrunc -I./libav-12.3 file.cpp main.cpp track.cpp atom.cpp mp4.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

Depending on your system and Libav configure options you might need to add extra flags to the command line:

  • add -lbz2 for errors like undefined reference to 'BZ2_bzDecompressInit',
  • add -llzma for errors like undefined reference to 'lzma_stream_decoder',
  • add -lX11 for errors like undefined reference to 'XOpenDisplay',
  • add -lvdpau for errors like undefined reference to 'VDPAU...',
  • add -ldl for errors like undefined reference to 'dlopen'.

On macOS add the following (tested on OSX 10.12.6):

  • add -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration.

Mac OSX

Follow the above steps for "Installing on other operating system", but use the following g++ command:

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 -lz -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration -lbz2 -DOSX

Arch package

Jose1711 kindly provides an arch package here: https://aur.archlinux.org/packages/untrunc-git/

Docker container

You can use the included Dockerfile to build and execute the package as a container

docker build -t untrunc .
docker run -v /path/to/files/:/files untrunc /files/working_video /files/broken_video

Using

You need both the broken video and an example working video (ideally from the same camera, if not the chances to fix it are slim).

Run this command in the folder where you have unzipped and compiled Untrunc but replace the /path/to/... bits with your 2 video files:

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

Then it should churn away and hopefully produce a playable file called broken-video_fixed.m4v.

That's it you're done!

(Thanks to Tom Sparrow for providing the guide)

Help/Support

If you managed to recover the video, help me to find time to keep working on this software and make other people happy. If you didn't, I need more corrupted samples to improve the program and I might solve the issue, who knows... so write me.

Donations can be made at my page, http://vcg.isti.cnr.it/~ponchio/untrunc.php, and promptly converted into beer.

Thank you.

untrunc's People

Contributors

ponchio avatar hacklin avatar hexluthor avatar brandon-dacrib avatar sebix avatar dirceu-jr avatar jensp avatar ianwelsh avatar teknoraver avatar simpod avatar

Watchers

James Cloos avatar  avatar

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.