@mediaproc/video 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +712 -0
- package/bin/cli.js +5 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
# 🎬 MediaProc Video Plugin
|
|
2
|
+
|
|
3
|
+
Professional video processing CLI powered by [FFmpeg](https://ffmpeg.org/). Fast, efficient, and comprehensive video manipulation toolkit with **6 essential commands** covering 90% of video processing use cases.
|
|
4
|
+
|
|
5
|
+
## 📑 Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Features](#-features)
|
|
8
|
+
- [Installation & Usage](#-installation--usage)
|
|
9
|
+
- [Requirements](#-requirements)
|
|
10
|
+
- [Quick Start](#-quick-start)
|
|
11
|
+
- [Global Options & Common Flags](#-global-options--common-flags)
|
|
12
|
+
- [Commands Overview](#-commands-overview)
|
|
13
|
+
- [Detailed Command Reference](#-detailed-command-reference)
|
|
14
|
+
- [Real-World Workflows](#-real-world-workflows)
|
|
15
|
+
- [Usage Tips](#-usage-tips)
|
|
16
|
+
- [Troubleshooting](#-troubleshooting)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ✨ Features
|
|
21
|
+
|
|
22
|
+
- 🚀 **High Performance** - Built on FFmpeg for industry-standard processing
|
|
23
|
+
- 🎬 **6 Essential Commands** - Compress, transcode, trim, resize, merge, extract
|
|
24
|
+
- 🔧 **Professional Features** - Quality control, dry-run mode, verbose logging
|
|
25
|
+
- 📦 **Universal Format Support** - MP4, WebM, MKV, AVI and all major codecs
|
|
26
|
+
- 🎯 **Simple CLI** - Intuitive command-line interface
|
|
27
|
+
- 💡 **Helpful Documentation** - Built-in help for every command
|
|
28
|
+
- ⚡ **Smart Processing** - Automatic format detection and optimization
|
|
29
|
+
|
|
30
|
+
## 📦 Installation & Usage
|
|
31
|
+
|
|
32
|
+
### Option 1: Universal CLI (Recommended)
|
|
33
|
+
|
|
34
|
+
Install the universal CLI and add the video plugin:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install universal CLI
|
|
38
|
+
npm install -g @mediaproc/cli
|
|
39
|
+
|
|
40
|
+
# Add video plugin (downloaded on-demand)
|
|
41
|
+
mediaproc add video
|
|
42
|
+
|
|
43
|
+
# Use commands with "video" prefix
|
|
44
|
+
mediaproc video compress input.mp4 -q high
|
|
45
|
+
mediaproc video transcode input.avi -f mp4
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Note:** All commands use the `video` namespace: `mediaproc video <command>`
|
|
49
|
+
|
|
50
|
+
### Option 2: Standalone Plugin
|
|
51
|
+
|
|
52
|
+
Install and use the video plugin independently:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Install standalone
|
|
56
|
+
npm install -g @mediaproc/video
|
|
57
|
+
|
|
58
|
+
# Use commands directly (no "video" prefix)
|
|
59
|
+
mediaproc-video compress input.mp4 -q high
|
|
60
|
+
mediaproc-video transcode input.avi -f mp4
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** Standalone mode uses `mediaproc-video` command without the `video` prefix.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🛠 Requirements
|
|
68
|
+
|
|
69
|
+
This plugin requires **FFmpeg** to be installed on your system:
|
|
70
|
+
|
|
71
|
+
### macOS
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
brew install ffmpeg
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Ubuntu/Debian
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
sudo apt update
|
|
81
|
+
sudo apt install ffmpeg
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Windows
|
|
85
|
+
|
|
86
|
+
Download from [ffmpeg.org](https://ffmpeg.org/download.html) or use chocolatey:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
choco install ffmpeg
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Verify Installation
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
ffmpeg -version
|
|
96
|
+
ffprobe -version
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Both `ffmpeg` and `ffprobe` are required for full functionality.
|
|
100
|
+
|
|
101
|
+
## 🎯 Quick Start
|
|
102
|
+
|
|
103
|
+
**With Universal CLI:**
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Compress a video
|
|
107
|
+
mediaproc video compress input.mp4 -q high
|
|
108
|
+
|
|
109
|
+
# Convert format
|
|
110
|
+
mediaproc video transcode input.avi -f mp4
|
|
111
|
+
|
|
112
|
+
# Trim video segment
|
|
113
|
+
mediaproc video trim input.mp4 --start 00:01:00 --end 00:02:30
|
|
114
|
+
|
|
115
|
+
# Resize to 720p
|
|
116
|
+
mediaproc video resize input.mp4 --scale 720p
|
|
117
|
+
|
|
118
|
+
# Merge videos
|
|
119
|
+
mediaproc video merge video1.mp4 video2.mp4 video3.mp4
|
|
120
|
+
|
|
121
|
+
# Extract audio
|
|
122
|
+
mediaproc video extract-audio input.mp4
|
|
123
|
+
|
|
124
|
+
# Get help for any command
|
|
125
|
+
mediaproc video compress --help
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**With Standalone Plugin:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Same commands, different prefix
|
|
132
|
+
mediaproc-video compress input.mp4 -q high
|
|
133
|
+
mediaproc-video transcode input.avi -f mp4
|
|
134
|
+
mediaproc-video trim input.mp4 --start 00:01:00 --end 00:02:30
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🌐 Global Options & Common Flags
|
|
140
|
+
|
|
141
|
+
All video commands share a consistent set of common flags for unified behavior:
|
|
142
|
+
|
|
143
|
+
### Standard Flags (Available on All Commands)
|
|
144
|
+
|
|
145
|
+
| Flag | Alias | Description | Default |
|
|
146
|
+
| ----------------- | ----- | --------------------------------- | ------------------------- |
|
|
147
|
+
| `--output <path>` | `-o` | Output file path | `<input>-<command>.<ext>` |
|
|
148
|
+
| `--dry-run` | - | Preview changes without executing | `false` |
|
|
149
|
+
| `--verbose` | `-v` | Show detailed FFmpeg output | `false` |
|
|
150
|
+
| `--help` | - | Display command-specific help | - |
|
|
151
|
+
|
|
152
|
+
### How Commands Work
|
|
153
|
+
|
|
154
|
+
**1. Input Processing:**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Commands accept file paths (relative or absolute)
|
|
158
|
+
mediaproc video compress video.mp4 -q high
|
|
159
|
+
mediaproc video compress /path/to/video.mp4 -q high
|
|
160
|
+
mediaproc video compress ../videos/video.mp4 -q high
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**2. Output Naming:**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Default: <input>-<command>.<ext>
|
|
167
|
+
mediaproc video compress input.mp4 # → input-compressed.mp4
|
|
168
|
+
|
|
169
|
+
# Custom output path:
|
|
170
|
+
mediaproc video compress input.mp4 -o output.mp4
|
|
171
|
+
|
|
172
|
+
# Change format:
|
|
173
|
+
mediaproc video transcode input.avi -f mp4 -o output.mp4
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**3. Metadata Analysis:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Commands automatically analyze input video
|
|
180
|
+
# Shows: duration, resolution, codec, bitrate, file size
|
|
181
|
+
mediaproc video compress input.mp4 -v
|
|
182
|
+
|
|
183
|
+
# FFprobe is used for metadata extraction
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**4. Dry-Run Mode:**
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Preview what will happen without processing
|
|
190
|
+
mediaproc video resize input.mp4 --scale 1080p --dry-run
|
|
191
|
+
|
|
192
|
+
# Shows: input details, operation parameters, output path
|
|
193
|
+
# FFmpeg command preview
|
|
194
|
+
# Useful for testing before batch processing
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**5. Verbose Output:**
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Show detailed FFmpeg processing information
|
|
201
|
+
mediaproc video compress input.mp4 -q high -v
|
|
202
|
+
|
|
203
|
+
# Displays:
|
|
204
|
+
# - Input video metadata
|
|
205
|
+
# - FFmpeg command being executed
|
|
206
|
+
# - Real-time encoding progress
|
|
207
|
+
# - Output statistics and comparison
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Command-Specific Options
|
|
211
|
+
|
|
212
|
+
Each command has unique options for its specific operation:
|
|
213
|
+
|
|
214
|
+
**Compress:**
|
|
215
|
+
|
|
216
|
+
- `--quality` (`-q`): low, medium, high (CRF-based)
|
|
217
|
+
- `--codec`: h264, h265, vp9
|
|
218
|
+
- `--crf`: Custom CRF value (0-51)
|
|
219
|
+
|
|
220
|
+
**Transcode:**
|
|
221
|
+
|
|
222
|
+
- `--format` (`-f`): mp4, webm, mkv, avi
|
|
223
|
+
- `--codec`: h264, h265, vp9, av1
|
|
224
|
+
- `--bitrate`: Target bitrate (e.g., 2M, 5000k)
|
|
225
|
+
- `--audio-codec`: aac, opus, mp3
|
|
226
|
+
- `--audio-bitrate`: Audio bitrate (e.g., 128k)
|
|
227
|
+
|
|
228
|
+
**Trim:**
|
|
229
|
+
|
|
230
|
+
- `--start`: Start time (HH:MM:SS or seconds)
|
|
231
|
+
- `--end`: End time (HH:MM:SS or seconds)
|
|
232
|
+
- `--duration`: Duration (HH:MM:SS or seconds)
|
|
233
|
+
- `--fast`: Fast mode (stream copy)
|
|
234
|
+
|
|
235
|
+
**Resize:**
|
|
236
|
+
|
|
237
|
+
- `--scale`: 480p, 720p, 1080p, 1440p, 4k
|
|
238
|
+
- `--width` (`-w`): Custom width in pixels
|
|
239
|
+
- `--height` (`-h`): Custom height in pixels
|
|
240
|
+
- `--aspect`: Maintain aspect ratio (default: true)
|
|
241
|
+
|
|
242
|
+
**Merge:**
|
|
243
|
+
|
|
244
|
+
- `--re-encode`: Force re-encoding
|
|
245
|
+
|
|
246
|
+
**Extract:**
|
|
247
|
+
|
|
248
|
+
- `extract-audio --format`: mp3, aac, wav, opus
|
|
249
|
+
- `extract-audio --bitrate`: Audio bitrate
|
|
250
|
+
- `extract-frames --fps`: Frames per second
|
|
251
|
+
- `extract-frames --format`: jpg, png
|
|
252
|
+
- `extract-thumbnail --time`: Time to extract
|
|
253
|
+
- `extract-thumbnail --width`: Thumbnail width
|
|
254
|
+
|
|
255
|
+
### Getting Help
|
|
256
|
+
|
|
257
|
+
**View all available commands:**
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Universal CLI
|
|
261
|
+
mediaproc video --help
|
|
262
|
+
|
|
263
|
+
# Standalone plugin
|
|
264
|
+
mediaproc-video --help
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Get command-specific help:**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Shows detailed usage, options, examples
|
|
271
|
+
mediaproc video compress --help
|
|
272
|
+
mediaproc video transcode --help
|
|
273
|
+
mediaproc video trim --help
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Help includes:**
|
|
277
|
+
|
|
278
|
+
- 📝 Description and purpose
|
|
279
|
+
- 🎯 Usage syntax
|
|
280
|
+
- ⚙️ Available options and flags
|
|
281
|
+
- 💡 Practical examples
|
|
282
|
+
- 📚 Use cases and workflows
|
|
283
|
+
- 💪 Tips and best practices
|
|
284
|
+
|
|
285
|
+
### Format Support
|
|
286
|
+
|
|
287
|
+
**Input Formats:**
|
|
288
|
+
|
|
289
|
+
- MP4 (`.mp4`)
|
|
290
|
+
- AVI (`.avi`)
|
|
291
|
+
- MKV (`.mkv`)
|
|
292
|
+
- MOV (`.mov`)
|
|
293
|
+
- WebM (`.webm`)
|
|
294
|
+
- FLV (`.flv`)
|
|
295
|
+
- WMV (`.wmv`)
|
|
296
|
+
- MPEG (`.mpg`, `.mpeg`)
|
|
297
|
+
- And all formats supported by FFmpeg
|
|
298
|
+
|
|
299
|
+
**Output Formats:**
|
|
300
|
+
|
|
301
|
+
- **MP4** - Best for universal compatibility (H.264/H.265)
|
|
302
|
+
- **WebM** - Best for web with VP9/VP8 codec
|
|
303
|
+
- **MKV** - Best for high quality archival
|
|
304
|
+
- **AVI** - Legacy format support
|
|
305
|
+
|
|
306
|
+
**Video Codecs:**
|
|
307
|
+
|
|
308
|
+
- **H.264 (libx264)** - Universal, fast encoding, good compression
|
|
309
|
+
- **H.265 (libx265)** - Better compression, slower encoding
|
|
310
|
+
- **VP9 (libvpx-vp9)** - Open source, WebM format
|
|
311
|
+
- **AV1 (libaom-av1)** - Best compression, very slow encoding
|
|
312
|
+
|
|
313
|
+
**Audio Codecs:**
|
|
314
|
+
|
|
315
|
+
- **AAC** - Universal, good quality
|
|
316
|
+
- **MP3** - Legacy, wide support
|
|
317
|
+
- **Opus** - Best for low bitrates
|
|
318
|
+
- **WAV** - Lossless audio
|
|
319
|
+
|
|
320
|
+
### Performance Tips
|
|
321
|
+
|
|
322
|
+
**1. Format Selection:**
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Use MP4 with H.264 for universal compatibility
|
|
326
|
+
mediaproc video transcode input.avi -f mp4 --codec h264
|
|
327
|
+
|
|
328
|
+
# Use WebM with VP9 for web delivery
|
|
329
|
+
mediaproc video transcode input.mp4 -f webm --codec vp9
|
|
330
|
+
|
|
331
|
+
# Use H.265 for maximum compression (slower)
|
|
332
|
+
mediaproc video transcode input.mp4 --codec h265
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**2. Quality vs Size (CRF):**
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# High quality (minimal compression)
|
|
339
|
+
mediaproc video compress input.mp4 --crf 18 # Large file
|
|
340
|
+
|
|
341
|
+
# Balanced (recommended)
|
|
342
|
+
mediaproc video compress input.mp4 -q medium # CRF 23
|
|
343
|
+
|
|
344
|
+
# Aggressive (maximum compression)
|
|
345
|
+
mediaproc video compress input.mp4 --crf 28 # Small file
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**CRF Guide:**
|
|
349
|
+
|
|
350
|
+
- **0-17**: Visually lossless (very large)
|
|
351
|
+
- **18-23**: High quality (archival)
|
|
352
|
+
- **23-28**: Good quality (distribution) ← Recommended
|
|
353
|
+
- **28-51**: Lower quality (streaming)
|
|
354
|
+
|
|
355
|
+
**3. Fast Trimming:**
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# Use --fast for quick cuts (no re-encode)
|
|
359
|
+
mediaproc video trim input.mp4 --start 00:01:00 --end 00:02:00 --fast
|
|
360
|
+
|
|
361
|
+
# Accurate mode re-encodes (slower but precise)
|
|
362
|
+
mediaproc video trim input.mp4 --start 00:01:00 --end 00:02:00
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**4. Batch Processing:**
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Compress multiple videos
|
|
369
|
+
for file in *.mp4; do
|
|
370
|
+
mediaproc video compress "$file" -q medium
|
|
371
|
+
done
|
|
372
|
+
|
|
373
|
+
# Convert all AVI to MP4
|
|
374
|
+
for file in *.avi; do
|
|
375
|
+
mediaproc video transcode "$file" -f mp4 -o "${file%.avi}.mp4"
|
|
376
|
+
done
|
|
377
|
+
|
|
378
|
+
# Extract audio from all videos
|
|
379
|
+
for file in *.mp4; do
|
|
380
|
+
mediaproc video extract-audio "$file"
|
|
381
|
+
done
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 📋 Commands Overview
|
|
387
|
+
|
|
388
|
+
| Command | Description | Primary Use Case |
|
|
389
|
+
| ------------------- | --------------------------- | -------------------------------- |
|
|
390
|
+
| `compress` | Reduce video file size | File size optimization |
|
|
391
|
+
| `transcode` | Convert format/codec | Format conversion, codec change |
|
|
392
|
+
| `trim` | Cut video segments | Remove unwanted parts |
|
|
393
|
+
| `resize` | Change video resolution | Resolution scaling, aspect ratio |
|
|
394
|
+
| `merge` | Concatenate multiple videos | Join clips together |
|
|
395
|
+
| `extract-audio` | Extract audio track | Get audio from video |
|
|
396
|
+
| `extract-frames` | Extract image sequence | Create thumbnails, analysis |
|
|
397
|
+
| `extract-thumbnail` | Extract single frame | Generate video thumbnail |
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 📖 Detailed Command Reference
|
|
402
|
+
|
|
403
|
+
Compress video files to reduce size while maintaining quality.
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
# Basic compression
|
|
407
|
+
mediaproc video compress input.mp4
|
|
408
|
+
|
|
409
|
+
# High quality compression
|
|
410
|
+
mediaproc video compress input.mp4 -q high
|
|
411
|
+
|
|
412
|
+
# Custom CRF value
|
|
413
|
+
mediaproc video compress input.mp4 --crf 18
|
|
414
|
+
|
|
415
|
+
# Use H.265 codec for better compression
|
|
416
|
+
mediaproc video compress input.mp4 --codec h265
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**Quality Presets:**
|
|
420
|
+
|
|
421
|
+
- `low` - CRF 28 (smaller file, lower quality)
|
|
422
|
+
- `medium` - CRF 23 (balanced - default)
|
|
423
|
+
- `high` - CRF 18 (larger file, better quality)
|
|
424
|
+
|
|
425
|
+
**Supported Codecs:** h264, h265, vp9
|
|
426
|
+
|
|
427
|
+
### transcode
|
|
428
|
+
|
|
429
|
+
Convert videos between formats and codecs.
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Convert to MP4
|
|
433
|
+
mediaproc video transcode input.avi -f mp4
|
|
434
|
+
|
|
435
|
+
# Use H.265 codec
|
|
436
|
+
mediaproc video transcode input.mp4 --codec h265
|
|
437
|
+
|
|
438
|
+
# Convert to WebM with VP9
|
|
439
|
+
mediaproc video transcode input.mp4 -f webm --codec vp9
|
|
440
|
+
|
|
441
|
+
# Set custom bitrate
|
|
442
|
+
mediaproc video transcode input.mp4 --bitrate 5M
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Supported Formats:** mp4, webm, mkv, avi
|
|
446
|
+
|
|
447
|
+
**Supported Codecs:** h264, h265, vp9, av1
|
|
448
|
+
|
|
449
|
+
### trim
|
|
450
|
+
|
|
451
|
+
Cut video segments with precise timing.
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Trim using start and end times
|
|
455
|
+
mediaproc video trim input.mp4 --start 00:00:10 --end 00:01:30
|
|
456
|
+
|
|
457
|
+
# Trim using duration
|
|
458
|
+
mediaproc video trim input.mp4 --start 10 --duration 80
|
|
459
|
+
|
|
460
|
+
# Fast mode (stream copy - less accurate but faster)
|
|
461
|
+
mediaproc video trim input.mp4 --start 00:00:05 --end 00:00:15 --fast
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Time Formats:**
|
|
465
|
+
|
|
466
|
+
- HH:MM:SS (e.g., 00:01:30)
|
|
467
|
+
- Seconds (e.g., 90)
|
|
468
|
+
|
|
469
|
+
### resize
|
|
470
|
+
|
|
471
|
+
Change video resolution with quality preservation.
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
# Use preset scale
|
|
475
|
+
mediaproc video resize input.mp4 --scale 720p
|
|
476
|
+
|
|
477
|
+
# Custom dimensions
|
|
478
|
+
mediaproc video resize input.mp4 -w 1280 -h 720
|
|
479
|
+
|
|
480
|
+
# Calculate height automatically
|
|
481
|
+
mediaproc video resize input.mp4 -w 1920
|
|
482
|
+
|
|
483
|
+
# Don't maintain aspect ratio
|
|
484
|
+
mediaproc video resize input.mp4 -w 1920 -h 1080 --no-aspect
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**Scale Presets:**
|
|
488
|
+
|
|
489
|
+
- `480p` - 854x480
|
|
490
|
+
- `720p` - 1280x720 (HD)
|
|
491
|
+
- `1080p` - 1920x1080 (Full HD)
|
|
492
|
+
- `1440p` - 2560x1440 (2K)
|
|
493
|
+
- `4k` - 3840x2160 (4K UHD)
|
|
494
|
+
|
|
495
|
+
### merge
|
|
496
|
+
|
|
497
|
+
Concatenate multiple videos into one.
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# Merge videos (auto-detect if re-encode needed)
|
|
501
|
+
mediaproc video merge video1.mp4 video2.mp4 video3.mp4
|
|
502
|
+
|
|
503
|
+
# Force re-encoding for compatibility
|
|
504
|
+
mediaproc video merge *.mp4 --re-encode
|
|
505
|
+
|
|
506
|
+
# Custom output path
|
|
507
|
+
mediaproc video merge part1.mp4 part2.mp4 -o final.mp4
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Notes:**
|
|
511
|
+
|
|
512
|
+
- Videos with same format/codec use fast concat (no re-encode)
|
|
513
|
+
- Mixed formats automatically re-encode for compatibility
|
|
514
|
+
- Use `--re-encode` to force re-encoding
|
|
515
|
+
|
|
516
|
+
### extract
|
|
517
|
+
|
|
518
|
+
Extract audio, frames, or thumbnails from video.
|
|
519
|
+
|
|
520
|
+
#### Extract Audio
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
# Extract as MP3
|
|
524
|
+
mediaproc video extract-audio input.mp4
|
|
525
|
+
|
|
526
|
+
# Extract as AAC with custom bitrate
|
|
527
|
+
mediaproc video extract-audio input.mp4 --format aac --bitrate 192k
|
|
528
|
+
|
|
529
|
+
# Extract as WAV (lossless)
|
|
530
|
+
mediaproc video extract-audio input.mp4 --format wav
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**Audio Formats:** mp3, aac, wav, opus
|
|
534
|
+
|
|
535
|
+
#### Extract Frames
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
# Extract 1 frame per second
|
|
539
|
+
mediaproc video extract-frames input.mp4 --fps 1
|
|
540
|
+
|
|
541
|
+
# Extract frames from specific time range
|
|
542
|
+
mediaproc video extract-frames input.mp4 --start 00:00:10 --end 00:00:20 --fps 5
|
|
543
|
+
|
|
544
|
+
# Extract as PNG
|
|
545
|
+
mediaproc video extract-frames input.mp4 --format png
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
#### Extract Thumbnail
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
# Extract thumbnail at 1 second
|
|
552
|
+
mediaproc video extract-thumbnail input.mp4
|
|
553
|
+
|
|
554
|
+
# Extract at specific time
|
|
555
|
+
mediaproc video extract-thumbnail input.mp4 --time 00:01:30
|
|
556
|
+
|
|
557
|
+
# Resize thumbnail
|
|
558
|
+
mediaproc video extract-thumbnail input.mp4 --width 640
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## Global Options
|
|
562
|
+
|
|
563
|
+
All commands support these options:
|
|
564
|
+
|
|
565
|
+
- `-o, --output <path>` - Specify output file/directory
|
|
566
|
+
- `--dry-run` - Preview command without executing
|
|
567
|
+
- `-v, --verbose` - Show detailed FFmpeg output
|
|
568
|
+
- `--help` - Show command help
|
|
569
|
+
|
|
570
|
+
## Common Use Cases
|
|
571
|
+
|
|
572
|
+
### 1. Prepare Video for Web
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
# Compress and convert to web-friendly format
|
|
576
|
+
mediaproc video transcode input.mov -f mp4 --codec h264
|
|
577
|
+
mediaproc video compress output.mp4 -q medium
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### 2. Create Social Media Clips
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
# Trim to 60 seconds
|
|
584
|
+
mediaproc video trim long-video.mp4 --start 00:01:00 --duration 60
|
|
585
|
+
|
|
586
|
+
# Resize to 1080p
|
|
587
|
+
mediaproc video resize trimmed.mp4 --scale 1080p
|
|
588
|
+
|
|
589
|
+
# Compress for smaller file
|
|
590
|
+
mediaproc video compress resized.mp4 -q medium
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### 3. Extract Highlights
|
|
594
|
+
|
|
595
|
+
```bash
|
|
596
|
+
# Extract multiple segments
|
|
597
|
+
mediaproc video trim full-game.mp4 --start 00:05:30 --end 00:06:00 -o highlight1.mp4
|
|
598
|
+
mediaproc video trim full-game.mp4 --start 00:12:15 --end 00:12:45 -o highlight2.mp4
|
|
599
|
+
|
|
600
|
+
# Merge highlights
|
|
601
|
+
mediaproc video merge highlight1.mp4 highlight2.mp4 -o best-moments.mp4
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### 4. Create Video Thumbnails
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
# Extract thumbnail from middle of video
|
|
608
|
+
mediaproc video extract-thumbnail video.mp4 --time 00:00:30
|
|
609
|
+
|
|
610
|
+
# Create multiple thumbnails
|
|
611
|
+
mediaproc video extract-frames video.mp4 --fps 0.1 --format jpg
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### 5. Batch Processing
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
# Compress all MP4 files
|
|
618
|
+
for file in *.mp4; do
|
|
619
|
+
mediaproc video compress "$file" -o "compressed_$file"
|
|
620
|
+
done
|
|
621
|
+
|
|
622
|
+
# Convert all AVI to MP4
|
|
623
|
+
for file in *.avi; do
|
|
624
|
+
mediaproc video transcode "$file" -f mp4
|
|
625
|
+
done
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
## Performance Tips
|
|
629
|
+
|
|
630
|
+
1. **Use fast trim mode** for quick cuts without quality loss
|
|
631
|
+
2. **Avoid re-encoding** when merging videos with same format
|
|
632
|
+
3. **Use CRF over bitrate** for better quality/size ratio
|
|
633
|
+
4. **Choose H.265** for better compression (slower encoding)
|
|
634
|
+
5. **Use presets** for common resolutions to save time
|
|
635
|
+
|
|
636
|
+
## Technical Details
|
|
637
|
+
|
|
638
|
+
### Quality Settings (CRF)
|
|
639
|
+
|
|
640
|
+
CRF (Constant Rate Factor) controls quality:
|
|
641
|
+
|
|
642
|
+
- **0-17**: Visually lossless (very large files)
|
|
643
|
+
- **18-23**: High quality (recommended for archival)
|
|
644
|
+
- **23-28**: Good quality (recommended for distribution)
|
|
645
|
+
- **28-51**: Lower quality (streaming/small files)
|
|
646
|
+
|
|
647
|
+
### Codec Comparison
|
|
648
|
+
|
|
649
|
+
| Codec | Compression | Speed | Browser Support |
|
|
650
|
+
| ----- | ----------- | --------- | --------------- |
|
|
651
|
+
| H.264 | Good | Fast | Excellent |
|
|
652
|
+
| H.265 | Better | Slow | Modern only |
|
|
653
|
+
| VP9 | Better | Slow | Good (WebM) |
|
|
654
|
+
| AV1 | Best | Very Slow | Limited |
|
|
655
|
+
|
|
656
|
+
### Container Formats
|
|
657
|
+
|
|
658
|
+
- **MP4**: Universal, best compatibility
|
|
659
|
+
- **WebM**: Web-optimized, used with VP9
|
|
660
|
+
- **MKV**: Feature-rich, large file support
|
|
661
|
+
- **AVI**: Legacy, avoid for new projects
|
|
662
|
+
|
|
663
|
+
## Error Handling
|
|
664
|
+
|
|
665
|
+
The plugin provides clear error messages:
|
|
666
|
+
|
|
667
|
+
- **FFmpeg not found**: Install FFmpeg first
|
|
668
|
+
- **Invalid input file**: Check file path and permissions
|
|
669
|
+
- **Codec not supported**: Use different codec or format
|
|
670
|
+
- **Out of range**: Check start/end times against video duration
|
|
671
|
+
|
|
672
|
+
## Development
|
|
673
|
+
|
|
674
|
+
### Building
|
|
675
|
+
|
|
676
|
+
```bash
|
|
677
|
+
pnpm install
|
|
678
|
+
pnpm build
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Testing
|
|
682
|
+
|
|
683
|
+
```bash
|
|
684
|
+
# Test compress
|
|
685
|
+
mediaproc video compress test-video.mp4 --dry-run -v
|
|
686
|
+
|
|
687
|
+
# Test all commands
|
|
688
|
+
pnpm test
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
## Contributing
|
|
692
|
+
|
|
693
|
+
Contributions welcome! Please:
|
|
694
|
+
|
|
695
|
+
1. Follow existing code style
|
|
696
|
+
2. Add tests for new features
|
|
697
|
+
3. Update documentation
|
|
698
|
+
4. Submit PR with clear description
|
|
699
|
+
|
|
700
|
+
## License
|
|
701
|
+
|
|
702
|
+
MIT
|
|
703
|
+
|
|
704
|
+
## Support
|
|
705
|
+
|
|
706
|
+
- 📖 [Full Documentation](https://mediaproc.dev/docs/plugins/video)
|
|
707
|
+
- 🐛 [Report Issues](https://github.com/0xshariq/mediaproc-cli/issues)
|
|
708
|
+
- 💬 [Discussions](https://github.com/0xshariq/mediaproc-cli/discussions)
|
|
709
|
+
|
|
710
|
+
## Credits
|
|
711
|
+
|
|
712
|
+
Built with [FFmpeg](https://ffmpeg.org/) - the leading multimedia framework.
|
package/bin/cli.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mediaproc/video",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Video processing plugin for mediaproc - powered by FFmpeg",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mediaproc-video": "./bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "bin"],
|
|
18
|
+
"keywords": ["mediaproc", "video", "ffmpeg", "transcode", "compress"],
|
|
19
|
+
"author": "Sharique Chaudhary",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"dev": "tsx src/cli.ts",
|
|
27
|
+
"watch": "tsc --watch",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"prepublishOnly": "pnpm build"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"chalk": "^5.3.0",
|
|
33
|
+
"commander": "^11.1.0",
|
|
34
|
+
"ora": "^8.0.1",
|
|
35
|
+
"fluent-ffmpeg": "^2.1.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.10.0",
|
|
39
|
+
"@types/fluent-ffmpeg": "^2.1.24",
|
|
40
|
+
"typescript": "^5.3.3",
|
|
41
|
+
"tsx": "^4.7.0"
|
|
42
|
+
}
|
|
43
|
+
}
|