@codedimension/video-editor
v1.1.0
Published
Video Editor CLI merges .mkv files to a single .mp4 file
Readme
Video Editor CLI
A simple Node.js CLI tool for common video editing tasks, primarily focused on .mkv files.
This tool provides three main commands:
trim-silence: Detects and removes silence from the beginning and end of.mkvfiles.merge-videos: Merges multiple.mkvfiles sequentially into a single.mp4file.process-course: Orchestrates the processing of an entire folder structure, merging videos per class and copying auxiliary files.
Prerequisites
This tool relies 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
Installation
You can run the CLI directly if you are inside the project folder:
Install dependencies
npm install
Build the project
npm run build
## How to use locally
To use the `video-editor` command directly from any directory in your terminal (like a global system command), you need to link it using npm.
1. Ensure you have built the latest version of the code:
```bash
npm run build- Link the package globally:
npm link
Now you can open a new terminal anywhere on your computer and run commands directly, for example:
cd /my/course/directory
video-editor process-course ./MyCourseNote: Whenever you modify the TypeScript source code, you only need to run npm run build again. Because the package is linked, the global video-editor command will automatically use the newly built files in the dist folder.
Usage
If you linked the package, you can run video-editor directly from any directory. Otherwise, run node dist/index.js or npx video-editor instead.
1. Trim Silence (trim-silence)
Automatically detects silence (below -30dB) at the start and end of your video recordings and trims it out. This is useful for removing the 1-2 seconds of dead air when starting or stopping a recording.
Options:
--input <path>: The path to a single.mkvfile, or a directory containing multiple.mkvfiles. (Required)--output <path>: The path where the trimmed file(s) should be saved. Can be a directory or a specific file name. (Required)
Examples:
Process a single file:
video-editor trim-silence --input my-recording.mkv --output ./trimmed-recording.mkvBatch process an entire directory of .mkv files (saves them to a folder named trimmed_videos):
video-editor trim-silence --input ./raw_videos/ --output ./trimmed_videos/2. Merge Videos (merge-videos)
Merges all .mkv files within a specified directory into a single .mp4 output file. The files are merged in alphabetical order. As part of this process, the command automatically detects and trims silence from the beginning and end of each .mkv file before merging them.
Options:
--videosDir <path>: The directory containing the.mkvfiles you want to merge. (Required)--outputFile <path>: The exact path and filename for the resulting.mp4file. (Required)
Example:
Merge all MKV files in the raw_clips directory into final_video.mp4:
video-editor merge-videos --videosDir ./raw_clips/ --outputFile ./final_video.mp43. Process Course (process-course)
Orchestrates the video editing workflow across a defined directory structure. It expects a course directory containing a nao-editado folder, which in turn contains a two-level structure: module/class.
For each class, the tool merges all .mkv files into a .mp4 named after the class folder itself, and copies any auxiliary files (like .pdf or .txt) to an editado folder, preserving the structure.
Options:
<coursePath>: The path to the root course directory containing thenao-editadofolder. (Required)--skip-existing: Skip classes that already have a generated.mp4file in theeditadofolder. Useful for resuming an interrupted process. (Optional)
Example Structure:
/MyCourse
/nao-editado
/Module-1
/Class-A
- video1.mkv
- video2.mkv
- notes.pdfOutput Structure:
/MyCourse
/editado
/Module-1
/Class-A
- Class-A.mp4
- notes.pdfExample:
Process a whole course:
video-editor process-course /path/to/MyCourseResume processing by skipping existing files:
video-editor process-course /path/to/MyCourse --skip-existingTroubleshooting
- FFmpeg not installed/found: Ensure
ffmpegis accessible from your terminal by runningffmpeg -version. - No silence detected: The
trim-silencecommand looks for audio below -30dB lasting at least 0.5 seconds. If your background noise is louder than -30dB, it might not detect the start/end as "silence".
