@codedimension/video-editor
v1.2.2
Published
Video Editor CLI merges .mkv files to a single .mp4 file
Readme
Video Editor CLI
A powerful Node.js command-line interface (CLI) tool for automated video editing tasks, primarily focused on .mkv files. It optimizes common workflows such as silence removal, batch merging, and course processing with high-quality output.
Key Features
- Automatic Silence Removal: Detects and removes silence (start, end, or middle) using FFmpeg filters.
- Natural Sorting: Intelligently sorts files numerically (e.g.,
part2.mkvcomes beforepart10.mkv). - High-Quality Output: Default encoding uses
libx264withCRF 18andslowpreset for visually lossless results. - Batch Processing: Orchestrates complex folder structures for courses or large collections.
Prerequisites
This tool depends on FFmpeg. You must have FFmpeg installed and available in your system's PATH.
- Ubuntu/Debian:
sudo apt install ffmpeg - macOS:
brew install ffmpeg - Windows: Download from the official website or use
winget install ffmpeg
Global Installation (Recommended)
To install and use video-editor from anywhere in your terminal without downloading the source code:
npm install -g @codedimension/video-editorAfter installation, you can run the video-editor command directly.
Development Installation
If you want to run the CLI from source code:
# Install dependencies
npm install
# Build the project
npm run buildTo use the video-editor command locally during development:
Build the latest version:
npm run buildLink the package globally:
npm link
Source code changes will be reflected after each npm run build.
Commands
1. Remove Silence from Videos (remove-silence-of-videos or rsov)
The most advanced trimming command. It removes all silence sections from a batch of videos, including silence in the middle of a recording.
Arguments:
[directory]: The directory containing.mkvfiles (Defaults to the current directory).
Options:
--start <number>: Manual start time in seconds (overrides silence detection).--end <number>: Manual end time in seconds (overrides silence detection).
Features:
- Removes middle silence by default.
- Automatically skips files containing
[skip]in their name. - Exports processed files to a
trimmed-videossubfolder as.mp4.
Example:
video-editor rsov ./raw_recordings --start 5 --end 1202. Trim Silence (trim-silence)
A simpler version that focuses on removing silence only from the start and end of files.
Options:
--input <path>: The path to a single.mkvfile or a directory. (Required)--output <path>: The path where the trimmed file(s) should be saved. (Required)
Example:
video-editor trim-silence --input recording.mkv --output ./trimmed/3. Merge Videos (merge-videos)
Merges multiple .mkv files into a single high-quality .mp4 file.
Options:
--videosDir <path>: The directory containing the.mkvvideo files. (Required)--outputFile <path>: The exact path and filename for the resulting.mp4. (Required)
Features:
- Automatic Trimming: Detects and removes silence at the ends of each clip before merging.
- Natural Order: Merges files in numerical/natural order.
- High Quality: Uses
CRF 18andslowpreset for the final export.
Example:
video-editor merge-videos --videosDir ./parts/ --outputFile final.mp44. Process Course (process-course)
Orchestrates a complete course editing workflow through a defined directory structure.
Input Structure:
/MyCourse
/nao-editado
/Module-1
/Lesson-A
- 1_intro.mkv
- 2_demo.mkv
- materials.pdfOutput Structure (/editado folder):
/MyCourse
/editado
/Module-1
/Lesson-A
- Lesson-A.mp4 (Merged and trimmed)
- materials.pdf (Automatically copied)Options:
<coursePath>: Path to the course root folder. (Required)--skip-existing: Skips lessons that already have an output.mp4file.
Example:
video-editor process-course /path/to/MyCourse --skip-existingTechnical Details
- Silence Detection: Threshold set at
-30dBfor at least0.5s. - Encoding Settings:
- Video:
libx264,pix_fmt yuv420p - Audio:
aac - Quality:
CRF 18, Preset:slow(optimized for high quality and reasonable file size).
- Video:
Troubleshooting
- FFmpeg not found: Make sure the
ffmpeg -versioncommand works in your terminal. - No silence detected: If the background noise is higher than -30dB, the tool might not detect silence correctly.
