A tool and library to losslessly join multiple .mp4 files shot with same camera and settings

Overview

mp4-merge

A tool and library to losslessly join multiple .mp4 files shot with same camera and settings.

This is useful to merge multiple files that are created by the camera because of the 4GB limit on the SD Card.

This tool can merge all these separate files to a new one without transcoding or losing any data.

All original tracks are preserved, all metadata is kept as in the original.

It was created to help stabilizing such files in Gyroflow.

Download:

See the Releases page.

Usage:

The easiest way is to just drag & drop multiple .mp4 files onto the mp4_merge executable.

Usage from command line:

  • Merge specified files and output to IN_FILE1.mp4_joined.mp4
mp4_merge IN_FILE1.mp4 IN_FILE2.mp4 IN_FILE3.mp4 ...
  • Merge specified files and output to result.mp4
mp4_merge IN_FILE1.mp4 IN_FILE2.mp4 IN_FILE3.mp4 ... --out result.mp4

Use as a Rust library:

[dependencies]
mp4-merge = "0.1.3"
let files = ["IN_FILE1.mp4", "IN_FILE2.mp4"];
mp4_merge::join_files(&files, "out.mp4", |progress| {
    println!("Merging... {:.2}%", progress * 100.0);
}).unwrap();

How does this work?

The idea is to merge the raw track data together, and then rewrite the stbl box (which is the descriptor of the raw data) to account for the additional data. In order to do this this library does the following:

  1. Scan every provided file and collect:
    • mdat offset and size
    • Duration stored in mvhd, tkhd, mdhd boxes
    • stbl descriptions: stts, stsz, stss, stsc, stco/co64
  2. Merge all these descriptions: sum durations, append stbl lists to each other and add chunk offsets based on previous file mdat size.
  3. Take the first file, go through every box and write it to the output file, while:
    • If mdat: write raw data from all mdat boxes from all files, and store it as a large box (64-bit)
    • If mvhd, tkhd or mdhd: patch the duration value to the sum of all durations
    • If stbl: write these boxes from scratch, using merged lists from the description
    • If stco: rewrite to co64 to be able to fit more than 4 GB of data.
  4. Done
You might also like...
A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!
A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!

cabal-pack A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library! To generate bindings, you need to annotate the Rust

An open source WCH-Link library/command line tool written in Rust.

wlink - WCH-Link command line tool NOTE: This tool is still in development and not ready for production use. Known Issue: Only support binary firmware

Create archives of files within Garry's Mod

gm_zip Create archives of files within Garry's Mod. Note: The scope of this module only works accross the gmod installation files e.g from GarrysMod/g

CLI program written in Rust to anonymize DICOM files

dicom-anonymizer CLI program written in Rust to anonymize DICOM files anonymizer 0.1.0 Domenic Melcher USAGE: anonymizer [OPTIONS] FILE ARGS:

Send Youtube videos as audio podcasts to your personal Pocket Casts files section.

yttopocketcasts Send Youtube videos as audio podcasts to your personal Pocket Casts files section. Quick Start Prerequisites: Docker and Make must be

A simple path traversal checker made with Rust. Useful for APIs that serve dynamic files.

Path trav A simple path traversal checker made with Rust. Useful for APIs that serve dynamic files. Note: this is a security tool. If you see somethin

Generate rust structs & query functions from diesel schema files

dsync A utility to generate database structs and querying code from diesel schema files. Primarily built for create-rust-app. Currently, it's more adv

Code sample for "Reading files the hard way Part 3"

read-raw-ext4 Rust code sample to read an ext4 partition from Rust, for: https://fasterthanli.me/series/reading-files-the-hard-way/part-3 Usage Don't.

Convert PNG image files to binary for use with AgonLight (TM)

image2agon Converts PNG files to binary data for AgonLight (TM) usage. This document is for version V1.0 of the program. V1.0 - initial upload NOTE: T

Owner
Gyroflow
Tools for Advanced Video Stabilization
Gyroflow
Type erased vector. All elements have the same type.

Type erased vector. All elements have the same type. Designed to be type-erased as far as possible - most of the operations does not know about concre

null 7 Dec 3, 2022
Rust language from simple to deep, and then to strengthen learning in multiple module

Rust Library This project is used to learn rust language from simple to deep, and then to strengthen learning in multiple module. It is used to help n

Summer 1 Sep 19, 2022
Custom deserialization for fields that can be specified as multiple types.

serde-this-or-that Custom deserialization for fields that can be specified as multiple types. This crate works with Cargo with a Cargo.toml like: [dep

Ritvik Nag 7 Aug 25, 2022
A minimal boilerplate for Astro / Vite with the Nannou creative framework (Rust → WASM). Supports multiple sketches + hot-reload.

Astro x Nannou Starter astro-nannou-demo-1c.mov ?? Try it online! # 0a. Rust language tools open https://www.rust-lang.org/tools/install # 0b. wasm-p

Julian Cataldo 4 Jan 4, 2023
Repo for apps for the Pocket RISC-V core for Analogue Pocket/OpenFPGA. Multiple branches.

This is a repo meant to host Rust programs for agg23's Pocket RISC-V platform. While Rust can be built out of the openfpga-litex repo directly, this r

null 3 Dec 12, 2023
Rust command-line tool to encrypt and decrypt files or directories with age

Bottle A Rust command-line tool that can compress and encrypt (and decrypt and extract) files or directories using age, gzip, and tar. Bottle has no c

Sam Schlinkert 1 Aug 1, 2022
Rust library for concurrent data access, using memory-mapped files, zero-copy deserialization, and wait-free synchronization.

mmap-sync mmap-sync is a Rust crate designed to manage high-performance, concurrent data access between a single writer process and multiple reader pr

Cloudflare 97 Jun 26, 2023
Checks Crusader Kings 3 user mod files for common mistakes and warns about them.

ck3-tiger Pounces on bugs. Checks Crusader Kings 3 user mod files for common mistakes and warns about them. For example: missing localizations, or usi

Richard Braakman 8 Jan 5, 2023
A tiny service that downloads files over HTTP links, with resume and restart support.

Http Drogue Http Drogue is a tiny service that downloads files over HTTP from links you provide. It can restart and resume interrupted downloads. Http

Kaan Barmore-Genç 4 Feb 27, 2023
A tool & library to help you with the compiler course.

Compiler Course Helper Support: eliminate left recursion (require grammar with no cycles or ϵ-production) calculate nullable, first sets, follow, sets

水夕 4 May 2, 2022