Skip to content

iamEvanYT/mp4-compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MP4 Compressor

A simple Bun script to compress MP4 video files using ffmpeg.

Features

  • Compresses all .mp4 files found in the input directory.
  • Outputs compressed files to the output directory.
  • Uses fluent-ffmpeg for interacting with ffmpeg.
  • Provides a progress bar using cli-progress.
  • Configurable ffmpeg settings (codec, quality, preset, etc.).

Prerequisites

  • Bun (a fast all-in-one JavaScript runtime)
  • ffmpeg installed and accessible in your system's PATH.

Installation

  1. Clone this repository or download the script.
  2. Navigate to the project directory in your terminal.
  3. Install the dependencies:
    bun install

Configuration

You can configure the compression settings directly within the index.ts file:

  • inputDir: Directory to read input MP4 files from (default: ./input).
  • outputDir: Directory to save compressed MP4 files to (default: ./output).
  • video_codec: Video codec (default: libx264).
  • audio_codec: Audio codec (default: aac).
  • quality: Constant Rate Factor (CRF) for video quality (default: 23). Lower values mean higher quality and larger file size.
  • tune: Tune setting for libx264 (default: animation). Other options include film, grain, stillimage, fastdecode, zerolatency.
  • preset: Encoding speed preset (default: veryslow). Faster presets result in lower quality/larger file size for the same CRF. Options range from ultrafast to veryslow.
  • profile: H.264 profile (default: high).
  • audioBitrate: Audio bitrate (default: 192k).

Usage

  1. Create an input directory in the project root (if it doesn't exist).
  2. Place the MP4 files you want to compress into the input directory.
  3. Run the script:
    bun run index.ts
  4. The script will process each .mp4 file and save the compressed version in the output directory (which will be created if it doesn't exist). A progress bar will be displayed for each file.

Dependencies

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published