npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mp4-combiner

v0.0.1

Published

Simple Node package to combine Mp4 files at the highest possible resolution, and framerate. Relies on some heavy weight packages, and some linux shell scripting to build a video file.

Downloads

8

Readme

MP4 Combiner - NPM Utility to Combine 2-N Mp4 files

npm package

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.now();

var combiner = Combiner({
	
	// Override the Minium FPS allowed (if no override set)
	min_fps: 24,

	// Override the Minimum Height allowed (if no override set)
	min_height: 360,

	// Override the Minimum Width allowed (if no override set)
	min_height: 600,

	// Override the processing speed (how slow/carefully FFMPEG does the video processing)
	encoding_speed: "fast",

	// Display the logs from FFMPEG
	display_logs: true,

	// Override the output FPS
	fps_override: 10,

	// Override the output Height
	height_override: 150,

	// Override the output Width
	width_override: 200,
});
combiner.Combine([files.sampleVideo1, files.sampleVideo2, files.sampleVideo1], ouputFileName)
.then(function() {
	console.log("You will now have a file at " + ouputFileName ".mp4");
})
.catch(function(err) {
	console.log("Error combining MP4 files: ", err);
});

Table of Contents

Setup and Configuration

Installing reddit-wrapper-v2

npm install mp4-combiner --save

Library usage and configuration

var Combiner = require('mp4-combiner');

var combiner = Combiner({
	min_fps: 24,
	min_height: 360,
	min_height: 600,
	encoding_speed: "fast",
	display_logs: true,
	fps_override: 10,
	height_override: 150,
	width_override: 200,
});

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.