Crates.io | mp4-merge |
lib.rs | mp4-merge |
version | 0.1.10 |
source | src |
created_at | 2022-08-23 17:51:07.162704 |
updated_at | 2024-08-27 07:55:53.438896 |
description | A tool and library to losslessly join multiple .mp4 files shot with same camera and settings |
homepage | |
repository | https://github.com/gyroflow/mp4-merge |
max_upload_size | |
id | 651133 |
size | 53,623 |
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.
See the Releases page.
The easiest way is to just drag & drop multiple .mp4 files onto the mp4_merge
executable.
Usage from command line:
IN_FILE1.mp4_joined.mp4
mp4_merge IN_FILE1.mp4 IN_FILE2.mp4 IN_FILE3.mp4 ...
result.mp4
mp4_merge IN_FILE1.mp4 IN_FILE2.mp4 IN_FILE3.mp4 ... --out result.mp4
[dependencies]
mp4-merge = "0.1.10"
let files = ["IN_FILE1.mp4", "IN_FILE2.mp4"];
mp4_merge::join_files(&files, "out.mp4", |progress| {
println!("Merging... {:.2}%", progress * 100.0);
}).unwrap();
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:
mdat
offset and sizemvhd
, tkhd
, mdhd
boxesstbl
descriptions: stts
, stsz
, stss
, stsc
, stco
/co64
stbl
lists to each other and add chunk offsets based on previous file mdat
size.mdat
: write raw data from all mdat
boxes from all files, and store it as a large box (64-bit)mvhd
, tkhd
or mdhd
: patch the duration value to the sum of all durationsstbl
: write these boxes from scratch, using merged lists from the descriptionstco
: rewrite to co64
to be able to fit more than 4 GB of data.