MP4 Combiner - NPM Utility to Combine 2-N Mp4 files
Simple to use
MP4 Combiner is designed to be as simple to use as possible, the minimum you need to do to get this utility working is pass a path to a list of mp4 files, and pass a final output path.
This utility uses the heavyweight FFMPEG linux library to do the actual video processing.
This utility uses FFProbe to determine media file properties, which can automatically determine the highest quality (Height/Width + FPS).
Users can also optionally pass in overrides to FPS, Height, and Width values.
Simple API usage:
var ouputFileName = outputFile + Date;var combiner =;combiner;
Table of Contents
Setup and Configuration
Installing reddit-wrapper-v2
npm install mp4-combiner --save
Library usage and configuration
var Combiner = ;var combiner =;
Options
Option | Default | Description |
---|---|---|
min_fps | 24 | The Minimum FPS allowed. If an FPS override is set, this has no effect. |
min_height | 600 | The Minimum Height allowed. If a Height override is set, this has no effect. |
min_width | 600 | The Minimum Width allowed. If a Width override is set, this has no effect. |
encoding_speed | medium | The FFMPEG Encoding Speed. Has to be one of the following presets: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. Be careful using faster encoding presets, this will potentially cause frame drops, or other issues. Use at your own risk. |
display_logs | false | Display the FFMPEG Logs during Encoding. Completely optional, for testing we would recommend keeping them on. |
fps_override | Sets the output FPS. | |
height_override | Sets the output Height. | |
width_override | Sets the output Width. |
Determining Output Media Info
If no Overrides are set for FPS, Width, and Height this utility will do its best to determine the optimal output video.
The process of determining this optimal video is looping through all of the input files, extracting media information with FFProbe, extracting the largest width (width and height are paired, so largest width video's height will be the chosen height), and extracting the highest FPS.
An example of how this would look is the following: Video #1: Width 600, Height: 600, FPS 15 Video #2: Width: 1280, Height: 720, FPS: 24 Video #3: Width: 1080, Height: 729, FPS: 30
The final video will have the following info: Width: 1280, Height: 720, FPS: 30
You can always override these values if you so choose, this is just our attempt to help reducing developer overhead if all the videos are similar dimensions.
Advice
We have the following advice for developers using this Utility:
- Try your best to make all of the video files be similar dimensions (width, height, fps)
- If you care a ton about video quality, but not as much about how quick the video encoding takes, you may choose to set the encoding preset to be closer to the veryslow side.
- If you care mostly about video encoding performance (ie. How quick it takes to combine mp4 files) you may choose to set the encoding preset to be closer to the ultrafast side.
- The more cores/the better your CPU is, the quicker your encoding will be. (You can also look into utilizing your GPU to process, however, that is out of the scope of this package)
- Processing large video files takes up RAM, so the the more RAM you have the better.
- We have found lots of value in offloading these processing jobs to AWS Batch.
Playing Around
If you just want to play around with this utility, to see how it works, to see what optimal settings may be, etc. Clone the underlying repository and update the testing directory.
Add a new test similar to the test called "Success #3 - with overrides", adding your own mp4 files you want to play around with.
To run the tests, in your linux shell type: mocha test
If you set everything up correctly, you will start seeing the tests being run sequentially, your test will execute at the end, once done, you can find the combined video file.
Final Notes
- This relies on Bluebird promises.
- Feel free to make feature requests, bugs, etc. I will try to be as prompt at fixing/getting back to you.