Coder Social home page Coder Social logo

movrepair's Introduction

movrepair

Movrepair is a script that attempts to repair a broken .mov file. In my specific use-case, the video files appeared to be truncated in the middle of the Movie Data atom (mdat), rendering the size of the mdat atom header too large, and all following atoms were missing (e.g. the important Movie Atom moov with all metadata).

This script will take a working reference video file and copy all atoms except for the mdat atom, which will be used from the broken input file.

Usage

To show the atoms of a (here broken) file:

$ python movrepair.py 0A3C0B00.MOV
file size: 297.5MiB
* ftyp (24.0B)
* wide (0.0B)
* mdat (1.4GiB)

Attempt to repair the file:

$ python movrepair.py reference.MOV --repair 0A3C0B00.MOV
Output file: 0A3C0B00-fixed.MOV
Broken file's mdat size adjusted from 1.4GiB to 297.5MiB
Adjusting "mvhd" duration from 4.5045s to 13.540166666666666s.
Adjusting "mdhd" duration from 4.5045s to 13.540166666666666s.
Adjusting "mdhd" duration from 4.5045s to 13.540166666666666s.
Adjusting "mdhd" duration from 4.5045s to 13.540166666666666s.
Adjusting sample count from 216216 to 649928
Extending b'in24' chunk offset table
Adjusting sample count from 135 to 405
Extending b'AVdh' chunk offset table
Extending b'AVdh' sample size table
stsz count: 405
Removing tmcd track
Updated moov atoms: mvhd, tkhd, tkhd, tkhd, elst, elst, elst, mdhd, mdhd, mdhd, stts, stco, stts, stco, stsz

If the "repaired" file still does not work, try using a video file that is at least as long as the file you're trying to repair and pass the --no-fix-metadata option.

$ python movrepair.py reference.MOV --repair 0A3C0B00.MOV --no-fix-metadata
Output file: 0A3C0B00-fixed.MOV
Broken file's mdat size adjusted from 1.4GiB to 297.5MiB

Disclaimer: Use at your own risk.

Synopsis

usage: movrepair.py [-h] [-o OUTPUT] [-R REPAIR] [--no-fix-metadata]
                    [--dump-moov]
                    file

positional arguments:
  file                  A working video file. If no additional options are
                        specified, the to-level atoms of this file will be
                        displayed.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        The repaired output filename.
  -R REPAIR, --repair REPAIR
                        A file to repair using the working input file.
  --no-fix-metadata     Don't try to fix the `moov` atom metadata duration and
                        sample counts. This will require the input FILE to be
                        the same length or longer than the REPAIR file.
  --dump-moov           Dump the input FILE's `moov` atom to stdout.

movrepair's People

Contributors

niklasrosenstein 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.