@mediaproc/video 1.0.0 → 1.1.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.
Files changed (62) hide show
  1. package/README.md +487 -89
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +14 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/compress.d.ts +3 -0
  7. package/dist/commands/compress.d.ts.map +1 -0
  8. package/dist/commands/compress.js +195 -0
  9. package/dist/commands/compress.js.map +1 -0
  10. package/dist/commands/extract.d.ts +3 -0
  11. package/dist/commands/extract.d.ts.map +1 -0
  12. package/dist/commands/extract.js +228 -0
  13. package/dist/commands/extract.js.map +1 -0
  14. package/dist/commands/merge.d.ts +3 -0
  15. package/dist/commands/merge.d.ts.map +1 -0
  16. package/dist/commands/merge.js +214 -0
  17. package/dist/commands/merge.js.map +1 -0
  18. package/dist/commands/resize.d.ts +3 -0
  19. package/dist/commands/resize.d.ts.map +1 -0
  20. package/dist/commands/resize.js +252 -0
  21. package/dist/commands/resize.js.map +1 -0
  22. package/dist/commands/transcode.d.ts +3 -0
  23. package/dist/commands/transcode.d.ts.map +1 -0
  24. package/dist/commands/transcode.js +108 -0
  25. package/dist/commands/transcode.js.map +1 -0
  26. package/dist/commands/trim.d.ts +3 -0
  27. package/dist/commands/trim.d.ts.map +1 -0
  28. package/dist/commands/trim.js +198 -0
  29. package/dist/commands/trim.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +2 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/register.d.ts +5 -0
  35. package/dist/register.d.ts.map +1 -0
  36. package/dist/register.js +18 -0
  37. package/dist/register.js.map +1 -0
  38. package/dist/types.d.ts +56 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +2 -0
  41. package/dist/types.js.map +1 -0
  42. package/dist/utils/ffmpeg-output.d.ts +9 -0
  43. package/dist/utils/ffmpeg-output.d.ts.map +1 -0
  44. package/dist/utils/ffmpeg-output.js +94 -0
  45. package/dist/utils/ffmpeg-output.js.map +1 -0
  46. package/dist/utils/ffmpeg.d.ts +46 -0
  47. package/dist/utils/ffmpeg.d.ts.map +1 -0
  48. package/dist/utils/ffmpeg.js +167 -0
  49. package/dist/utils/ffmpeg.js.map +1 -0
  50. package/dist/utils/ffmpegLogger.d.ts +16 -0
  51. package/dist/utils/ffmpegLogger.d.ts.map +1 -0
  52. package/dist/utils/ffmpegLogger.js +66 -0
  53. package/dist/utils/ffmpegLogger.js.map +1 -0
  54. package/dist/utils/helpFormatter.d.ts +51 -0
  55. package/dist/utils/helpFormatter.d.ts.map +1 -0
  56. package/dist/utils/helpFormatter.js +134 -0
  57. package/dist/utils/helpFormatter.js.map +1 -0
  58. package/dist/utils/pathValidator.d.ts +60 -0
  59. package/dist/utils/pathValidator.d.ts.map +1 -0
  60. package/dist/utils/pathValidator.js +207 -0
  61. package/dist/utils/pathValidator.js.map +1 -0
  62. package/package.json +12 -3
package/README.md CHANGED
@@ -23,9 +23,12 @@ Professional video processing CLI powered by [FFmpeg](https://ffmpeg.org/). Fast
23
23
  - 🎬 **6 Essential Commands** - Compress, transcode, trim, resize, merge, extract
24
24
  - 🔧 **Professional Features** - Quality control, dry-run mode, verbose logging
25
25
  - 📦 **Universal Format Support** - MP4, WebM, MKV, AVI and all major codecs
26
+ - 📁 **Folder Processing** - Process entire directories with single command
26
27
  - 🎯 **Simple CLI** - Intuitive command-line interface
27
28
  - 💡 **Helpful Documentation** - Built-in help for every command
28
29
  - ⚡ **Smart Processing** - Automatic format detection and optimization
30
+ - 🎨 **Advanced Effects** - Fade, speed, volume, transitions, and more
31
+ - 🔄 **Hardware Acceleration** - GPU support for faster encoding
29
32
 
30
33
  ## 📦 Installation & Usage
31
34
 
@@ -158,6 +161,29 @@ All video commands share a consistent set of common flags for unified behavior:
158
161
  mediaproc video compress video.mp4 -q high
159
162
  mediaproc video compress /path/to/video.mp4 -q high
160
163
  mediaproc video compress ../videos/video.mp4 -q high
164
+
165
+ # Process entire folders (recursively finds all video files)
166
+ mediaproc video compress videos/ -q high -o compressed/
167
+ mediaproc video resize ./input/ -s 720p -o ./output/
168
+
169
+ # Multiple files separated by commas
170
+ mediaproc video compress video1.mp4,video2.mp4,video3.mp4 -q medium
171
+ ```
172
+
173
+ **2. Folder Processing:**
174
+
175
+ ```bash
176
+ # Compress all videos in a folder
177
+ mediaproc video compress videos/ -q medium -o compressed/
178
+
179
+ # Resize all videos to 1080p
180
+ mediaproc video resize raw-footage/ -s 1080p -o processed/
181
+
182
+ # Trim all videos in folder
183
+ mediaproc video trim clips/ -s 5 -d 30 -o trimmed/
184
+
185
+ # Process maintains folder structure in output
186
+ # Input: videos/project1/clip.mp4 → Output: output/project1/clip-compressed.mp4
161
187
  ```
162
188
 
163
189
  **2. Output Naming:**
@@ -213,9 +239,21 @@ Each command has unique options for its specific operation:
213
239
 
214
240
  **Compress:**
215
241
 
216
- - `--quality` (`-q`): low, medium, high (CRF-based)
217
- - `--codec`: h264, h265, vp9
242
+ - `--quality` (`-q`): low, medium, high, extreme (CRF-based)
243
+ - `--codec` (`-c`): h264, h265, vp9, av1
218
244
  - `--crf`: Custom CRF value (0-51)
245
+ - `--preset`: Encoding preset (ultrafast, fast, medium, slow, veryslow)
246
+ - `--bitrate` (`-b`): Target bitrate (e.g., 2M, 5M)
247
+ - `--min-bitrate`: Minimum bitrate (e.g., 1M)
248
+ - `--max-bitrate`: Maximum bitrate (e.g., 8M)
249
+ - `--audio-bitrate`: Audio bitrate (default: 128k)
250
+ - `--audio-codec`: Audio codec (aac, mp3, opus)
251
+ - `--optimize-for`: Optimize for web, streaming, archive, mobile
252
+ - `--resize`: Also resize during compression (e.g., 720p, 1080p)
253
+ - `--threads`: Number of encoding threads
254
+ - `--hw-accel`: Enable hardware acceleration (GPU)
255
+ - `--strip-metadata`: Remove all metadata from output
256
+ - `--two-pass`: Use two-pass encoding for better quality
219
257
 
220
258
  **Transcode:**
221
259
 
@@ -227,21 +265,49 @@ Each command has unique options for its specific operation:
227
265
 
228
266
  **Trim:**
229
267
 
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)
268
+ - `--start` (`-s`): Start time (HH:MM:SS or seconds)
269
+ - `--end` (`-e`): End time (HH:MM:SS or seconds)
270
+ - `--duration` (`-d`): Duration (HH:MM:SS or seconds)
233
271
  - `--fast`: Fast mode (stream copy)
272
+ - `--accurate`: Accurate mode (re-encode for frame accuracy)
273
+ - `--codec` (`-c`): Video codec (h264, h265, copy)
274
+ - `--fade-in`: Add fade-in effect (seconds)
275
+ - `--fade-out`: Add fade-out effect (seconds)
276
+ - `--speed`: Adjust playback speed (0.5-2.0)
277
+ - `--volume`: Adjust audio volume (0.0-2.0)
278
+ - `--quality`: CRF quality if re-encoding (default: 23)
279
+ - `--no-audio`: Remove audio track from output
234
280
 
235
281
  **Resize:**
236
282
 
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)
283
+ - `--scale` (`-s`): 360p, 480p, 720p, 1080p, 1440p, 2160p (4K), 4320p (8K), or WxH
284
+ - `--codec` (`-c`): h264, h265, vp9, av1
285
+ - `--quality` (`-q`): CRF quality (0-51, lower=better, default: 23)
286
+ - `--preset`: Encoding preset (ultrafast, fast, medium, slow, veryslow)
287
+ - `--bitrate` (`-b`): Target bitrate (e.g., 5M, 10M)
288
+ - `--aspect` (`-a`): Aspect ratio (16:9, 4:3, 21:9, 1:1)
289
+ - `--fps`: Output frame rate (e.g., 24, 30, 60)
290
+ - `--scale-algo`: Scaling algorithm (bilinear, bicubic, lanczos, spline)
291
+ - `--deinterlace`: Deinterlace video (for interlaced sources)
292
+ - `--rotate`: Rotate video (90, 180, 270 degrees)
293
+ - `--flip`: Flip video (horizontal, vertical, both)
294
+ - `--crop`: Crop video (width:height:x:y or preset)
295
+ - `--threads`: Number of encoding threads
296
+ - `--hw-accel`: Enable hardware acceleration (GPU)
297
+ - `--no-audio`: Remove audio from output
298
+ - `--two-pass`: Use two-pass encoding for better quality
241
299
 
242
300
  **Merge:**
243
301
 
244
302
  - `--re-encode`: Force re-encoding
303
+ - `--transition`: Transition effect (fade, wipe, dissolve, none)
304
+ - `--transition-duration`: Transition duration in seconds (default: 1)
305
+ - `--codec` (`-c`): Video codec (h264, h265, vp9)
306
+ - `--quality`: CRF quality if re-encoding (default: 23)
307
+ - `--scale`: Scale all videos to same resolution (e.g., 1080p)
308
+ - `--audio-track`: Select audio track from videos (1-based)
309
+ - `--audio-codec`: Audio codec (aac, mp3, opus)
310
+ - `--normalize-audio`: Normalize audio levels across videos
245
311
 
246
312
  **Extract:**
247
313
 
@@ -383,7 +449,72 @@ done
383
449
 
384
450
  ---
385
451
 
386
- ## 📋 Commands Overview
452
+ ## Advanced Features
453
+
454
+ ### Hardware Acceleration
455
+
456
+ Enable GPU acceleration for significantly faster encoding:
457
+
458
+ ```bash
459
+ # Use GPU for faster encoding
460
+ mediaproc video resize input.mp4 -s 4K --hw-accel
461
+ mediaproc video compress input.mp4 -q high --hw-accel
462
+ ```
463
+
464
+ **Note:** Requires compatible GPU and drivers (NVIDIA NVENC, Intel Quick Sync, AMD VCE)
465
+
466
+ ### Optimization Presets
467
+
468
+ Compress with specific optimization targets:
469
+
470
+ ```bash
471
+ # Optimize for web delivery
472
+ mediaproc video compress input.mp4 --optimize-for web
473
+
474
+ # Optimize for streaming platforms
475
+ mediaproc video compress input.mp4 --optimize-for streaming
476
+
477
+ # Optimize for mobile devices
478
+ mediaproc video compress input.mp4 --optimize-for mobile --resize 720p
479
+
480
+ # Optimize for long-term archive
481
+ mediaproc video compress input.mp4 --optimize-for archive -c h265
482
+ ```
483
+
484
+ ### Multi-Threading
485
+
486
+ Control CPU usage for encoding:
487
+
488
+ ```bash
489
+ # Use 8 threads for faster encoding
490
+ mediaproc video resize input.mp4 -s 1080p --threads 8
491
+
492
+ # Use all available CPU cores (default)
493
+ mediaproc video compress input.mp4 -q high
494
+ ```
495
+
496
+ ### Two-Pass Encoding
497
+
498
+ Better quality at target bitrate (takes twice as long):
499
+
500
+ ```bash
501
+ # Two-pass encoding for optimal quality
502
+ mediaproc video compress input.mp4 --two-pass -b 5M
503
+ mediaproc video resize input.mp4 -s 1080p --two-pass
504
+ ```
505
+
506
+ ### Metadata Management
507
+
508
+ ```bash
509
+ # Strip all metadata to reduce file size
510
+ mediaproc video compress input.mp4 --strip-metadata
511
+
512
+ # Metadata is preserved by default in most operations
513
+ ```
514
+
515
+ ---
516
+
517
+ ## �📋 Commands Overview
387
518
 
388
519
  | Command | Description | Primary Use Case |
389
520
  | ------------------- | --------------------------- | -------------------------------- |
@@ -400,29 +531,51 @@ done
400
531
 
401
532
  ## 📖 Detailed Command Reference
402
533
 
534
+ ### compress
535
+
403
536
  Compress video files to reduce size while maintaining quality.
404
537
 
405
538
  ```bash
406
- # Basic compression
539
+ # Basic compression with default medium quality
407
540
  mediaproc video compress input.mp4
408
541
 
409
- # High quality compression
542
+ # High quality compression (larger file, better quality)
410
543
  mediaproc video compress input.mp4 -q high
411
544
 
412
- # Custom CRF value
413
- mediaproc video compress input.mp4 --crf 18
545
+ # Extreme quality compression (near lossless)
546
+ mediaproc video compress input.mp4 -q extreme
547
+
548
+ # Custom CRF value for fine control
549
+ mediaproc video compress input.mp4 --crf 20
550
+
551
+ # Use H.265 codec for better compression (50% smaller)
552
+ mediaproc video compress input.mp4 -c h265 -q high
553
+
554
+ # Compress with resize for mobile
555
+ mediaproc video compress input.mp4 --resize 720p --optimize-for mobile
414
556
 
415
- # Use H.265 codec for better compression
416
- mediaproc video compress input.mp4 --codec h265
557
+ # Two-pass encoding for best quality
558
+ mediaproc video compress input.mp4 -c h265 --preset slow --two-pass
559
+
560
+ # Compress folder of videos
561
+ mediaproc video compress videos/ -q medium -o compressed/
417
562
  ```
418
563
 
419
564
  **Quality Presets:**
420
565
 
421
- - `low` - CRF 28 (smaller file, lower quality)
422
- - `medium` - CRF 23 (balanced - default)
423
- - `high` - CRF 18 (larger file, better quality)
566
+ - `low` - CRF 28 (~60% size reduction, noticeable quality loss)
567
+ - `medium` - CRF 23 (~40% size reduction, minimal quality loss) - **Default**
568
+ - `high` - CRF 20 (~30% size reduction, near-identical quality)
569
+ - `extreme` - CRF 18 (~20% size reduction, visually lossless)
570
+
571
+ **Advanced Options:**
424
572
 
425
- **Supported Codecs:** h264, h265, vp9
573
+ - `--optimize-for`: Preset optimizations (web, streaming, archive, mobile)
574
+ - `--hw-accel`: Enable GPU acceleration for faster encoding
575
+ - `--threads`: Control CPU thread usage
576
+ - `--strip-metadata`: Remove all metadata to save space
577
+
578
+ **Supported Codecs:** h264, h265, vp9, av1
426
579
 
427
580
  ### transcode
428
581
 
@@ -448,70 +601,196 @@ mediaproc video transcode input.mp4 --bitrate 5M
448
601
 
449
602
  ### trim
450
603
 
451
- Cut video segments with precise timing.
604
+ Cut video segments with precise timing and effects.
452
605
 
453
606
  ```bash
454
- # Trim using start and end times
455
- mediaproc video trim input.mp4 --start 00:00:10 --end 00:01:30
607
+ # Trim using start and end times (HH:MM:SS format)
608
+ mediaproc video trim input.mp4 -s 00:00:10 -e 00:01:30
456
609
 
457
- # Trim using duration
458
- mediaproc video trim input.mp4 --start 10 --duration 80
610
+ # Trim using seconds (simpler)
611
+ mediaproc video trim input.mp4 -s 10 -e 90
459
612
 
460
- # Fast mode (stream copy - less accurate but faster)
461
- mediaproc video trim input.mp4 --start 00:00:05 --end 00:00:15 --fast
613
+ # Trim using duration instead of end time
614
+ mediaproc video trim input.mp4 -s 10 -d 80
615
+
616
+ # Fast mode (stream copy - very quick, may not be frame-accurate)
617
+ mediaproc video trim input.mp4 -s 00:00:05 -e 00:00:15 --fast
618
+
619
+ # Accurate mode (re-encode for perfect frame accuracy)
620
+ mediaproc video trim input.mp4 -s 10 -d 30 --accurate
621
+
622
+ # Trim with fade-in effect (3 seconds)
623
+ mediaproc video trim input.mp4 -s 60 -d 120 --fade-in 3
624
+
625
+ # Trim with fade-out effect (2 seconds)
626
+ mediaproc video trim input.mp4 -s 30 -d 60 --fade-out 2
627
+
628
+ # Trim with both fade effects
629
+ mediaproc video trim input.mp4 -s 0 -d 120 --fade-in 2 --fade-out 3
630
+
631
+ # Adjust playback speed (0.5x slow motion)
632
+ mediaproc video trim input.mp4 -s 10 -d 30 --speed 0.5
633
+
634
+ # Adjust playback speed (2x fast forward)
635
+ mediaproc video trim input.mp4 -s 10 -d 30 --speed 2.0
636
+
637
+ # Adjust audio volume (50%)
638
+ mediaproc video trim input.mp4 -s 10 -d 30 --volume 0.5
639
+
640
+ # Remove audio from clip
641
+ mediaproc video trim input.mp4 -s 10 -d 30 --no-audio
642
+
643
+ # Trim folder of videos
644
+ mediaproc video trim videos/ -s 5 -d 30 -o clips/
462
645
  ```
463
646
 
464
647
  **Time Formats:**
465
648
 
466
- - HH:MM:SS (e.g., 00:01:30)
467
- - Seconds (e.g., 90)
649
+ - **Seconds**: `90` (1 minute 30 seconds)
650
+ - **MM:SS**: `01:30` (1 minute 30 seconds)
651
+ - **HH:MM:SS**: `00:01:30` (1 minute 30 seconds)
652
+
653
+ **Duration Options:**
654
+
655
+ - Use `--end` for absolute end time
656
+ - Use `--duration` for relative duration from start
657
+ - Cannot use both `--end` and `--duration` together
658
+
659
+ **Modes:**
660
+
661
+ - **Default**: Stream copy (fast and accurate for most cases)
662
+ - **Fast (`--fast`)**: Stream copy without re-encoding (very quick, may cut at nearest keyframe)
663
+ - **Accurate (`--accurate`)**: Re-encode for perfect frame accuracy (slower but precise)
664
+
665
+ **Effects:**
666
+
667
+ - `--fade-in`: Add fade-in effect at the beginning
668
+ - `--fade-out`: Add fade-out effect at the end
669
+ - `--speed`: Adjust playback speed (0.5 = 50% slower, 2.0 = 2x faster)
670
+ - `--volume`: Adjust audio volume (0.5 = 50%, 1.0 = 100%, 2.0 = 200%)
468
671
 
469
672
  ### resize
470
673
 
471
- Change video resolution with quality preservation.
674
+ Change video resolution with quality preservation and advanced transformations.
472
675
 
473
676
  ```bash
474
- # Use preset scale
475
- mediaproc video resize input.mp4 --scale 720p
677
+ # Use preset scale (recommended)
678
+ mediaproc video resize input.mp4 -s 720p
679
+
680
+ # Resize to 4K with high quality
681
+ mediaproc video resize input.mp4 -s 2160p -c h265 --preset slow
682
+
683
+ # Resize to 8K (4320p)
684
+ mediaproc video resize input.mp4 -s 4320p
685
+
686
+ # Custom dimensions (WIDTHxHEIGHT)
687
+ mediaproc video resize input.mp4 -s 1920x1080
688
+
689
+ # Change aspect ratio to 16:9
690
+ mediaproc video resize input.mp4 -s 1080p -a 16:9
691
+
692
+ # Resize with custom frame rate
693
+ mediaproc video resize input.mp4 -s 1080p --fps 60
694
+
695
+ # Rotate video 90 degrees clockwise
696
+ mediaproc video resize input.mp4 --rotate 90
697
+
698
+ # Flip video horizontally
699
+ mediaproc video resize input.mp4 --flip horizontal
700
+
701
+ # Crop to 16:9 aspect ratio
702
+ mediaproc video resize input.mp4 --crop 16:9
476
703
 
477
- # Custom dimensions
478
- mediaproc video resize input.mp4 -w 1280 -h 720
704
+ # Deinterlace old footage
705
+ mediaproc video resize input.mp4 -s 1080p --deinterlace
479
706
 
480
- # Calculate height automatically
481
- mediaproc video resize input.mp4 -w 1920
707
+ # Use Lanczos scaling algorithm (best quality)
708
+ mediaproc video resize input.mp4 -s 1080p --scale-algo lanczos
482
709
 
483
- # Don't maintain aspect ratio
484
- mediaproc video resize input.mp4 -w 1920 -h 1080 --no-aspect
710
+ # Hardware accelerated resize
711
+ mediaproc video resize input.mp4 -s 4K --hw-accel
712
+
713
+ # Resize folder of videos
714
+ mediaproc video resize videos/ -s 1080p -o output/
485
715
  ```
486
716
 
487
717
  **Scale Presets:**
488
718
 
489
- - `480p` - 854x480
490
- - `720p` - 1280x720 (HD)
491
- - `1080p` - 1920x1080 (Full HD)
492
- - `1440p` - 2560x1440 (2K)
493
- - `4k` - 3840x2160 (4K UHD)
719
+ - `360p` - 640x360 (Low quality, mobile)
720
+ - `480p` - 854x480 (SD quality)
721
+ - `720p` - 1280x720 (HD ready) - **Recommended for web**
722
+ - `1080p` - 1920x1080 (Full HD) - **Recommended for distribution**
723
+ - `1440p` - 2560x1440 (2K/QHD)
724
+ - `2160p` - 3840x2160 (4K/UHD)
725
+ - `4320p` - 7680x4320 (8K/UHD)
726
+ - `WxH` - Custom (e.g., 1920x1080)
727
+
728
+ **Advanced Transformations:**
729
+
730
+ - `--rotate`: Rotate video (90, 180, 270 degrees)
731
+ - `--flip`: Flip horizontally, vertically, or both
732
+ - `--crop`: Crop video to specific dimensions or aspect ratio
733
+ - `--deinterlace`: Remove interlacing artifacts
734
+ - `--scale-algo`: Choose scaling algorithm (lanczos recommended)
494
735
 
495
736
  ### merge
496
737
 
497
- Concatenate multiple videos into one.
738
+ Concatenate multiple videos into one with transitions and effects.
498
739
 
499
740
  ```bash
500
- # Merge videos (auto-detect if re-encode needed)
741
+ # Simple merge (auto-detect if re-encode needed)
501
742
  mediaproc video merge video1.mp4 video2.mp4 video3.mp4
502
743
 
744
+ # Merge with custom output name
745
+ mediaproc video merge part1.mp4 part2.mp4 part3.mp4 -o complete.mp4
746
+
503
747
  # Force re-encoding for compatibility
504
748
  mediaproc video merge *.mp4 --re-encode
505
749
 
506
- # Custom output path
507
- mediaproc video merge part1.mp4 part2.mp4 -o final.mp4
750
+ # Merge with fade transitions between clips
751
+ mediaproc video merge clip1.mp4 clip2.mp4 --transition fade --transition-duration 2
752
+
753
+ # Merge with specific codec and quality
754
+ mediaproc video merge video1.mp4 video2.mp4 -c h265 --quality 20
755
+
756
+ # Scale all videos to same resolution before merging
757
+ mediaproc video merge *.mp4 --scale 1080p
758
+
759
+ # Merge with normalized audio levels
760
+ mediaproc video merge video1.mp4 video2.mp4 --normalize-audio
761
+
762
+ # Select specific audio track (for multi-track videos)
763
+ mediaproc video merge video1.mp4 video2.mp4 --audio-track 2
764
+
765
+ # Merge to different format
766
+ mediaproc video merge *.mp4 -o output.mkv --format mkv
508
767
  ```
509
768
 
510
- **Notes:**
769
+ **Merge Methods:**
770
+
771
+ - **Fast Concatenation**: No re-encoding, very fast, requires same codec/format/resolution
772
+ - **Re-encoding (`--re-encode`)**: Slower but handles any format/codec combination
773
+ - **Auto Detection**: Automatically chooses best method based on input files
774
+
775
+ **Transitions:**
776
+
777
+ - `none` - No transition (default)
778
+ - `fade` - Crossfade between clips
779
+ - `wipe` - Wipe transition
780
+ - `dissolve` - Dissolve transition
511
781
 
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
782
+ **Requirements:**
783
+
784
+ - At least 2 videos required for merging
785
+ - Videos with different resolutions can be scaled to match using `--scale`
786
+ - Audio tracks will be merged in order
787
+ - Videos are processed in the order specified
788
+
789
+ **Advanced Options:**
790
+
791
+ - `--normalize-audio`: Normalize audio levels across all videos for consistent volume
792
+ - `--audio-track`: Select which audio track to use from multi-track videos
793
+ - `--scale`: Resize all videos to same resolution before merging
515
794
 
516
795
  ### extract
517
796
 
@@ -567,71 +846,190 @@ All commands support these options:
567
846
  - `-v, --verbose` - Show detailed FFmpeg output
568
847
  - `--help` - Show command help
569
848
 
570
- ## Common Use Cases
849
+ ## 🎯 Real-World Workflows
850
+
851
+ ### Workflow 1: Social Media Content
852
+
853
+ Prepare videos for Instagram, TikTok, YouTube Shorts:
854
+
855
+ ```bash
856
+ # 1. Trim to desired length (60 seconds for Instagram)
857
+ mediaproc video trim long-video.mp4 -s 00:01:00 -d 60 -o clip.mp4
858
+
859
+ # 2. Resize to 1080x1080 (square for Instagram)
860
+ mediaproc video resize clip.mp4 -s 1080x1080 -o square.mp4
861
+
862
+ # 3. Add fade effects
863
+ mediaproc video trim square.mp4 -s 0 -d 60 --fade-in 1 --fade-out 1 -o final.mp4
864
+
865
+ # 4. Compress for upload
866
+ mediaproc video compress final.mp4 -q high --optimize-for web
867
+ ```
868
+
869
+ ### Workflow 2: YouTube Video Production
571
870
 
572
- ### 1. Prepare Video for Web
871
+ Professional YouTube video workflow:
573
872
 
574
873
  ```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
874
+ # 1. Merge multiple clips
875
+ mediaproc video merge intro.mp4 main.mp4 outro.mp4 --transition fade -o raw.mp4
876
+
877
+ # 2. Resize to 1080p if needed
878
+ mediaproc video resize raw.mp4 -s 1080p --fps 60 -o hd.mp4
879
+
880
+ # 3. Compress for upload (maintain quality)
881
+ mediaproc video compress hd.mp4 -q extreme -c h264 --two-pass -o final.mp4
578
882
  ```
579
883
 
580
- ### 2. Create Social Media Clips
884
+ ### Workflow 3: Batch Process Raw Footage
885
+
886
+ Process entire folders of raw footage:
581
887
 
582
888
  ```bash
583
- # Trim to 60 seconds
584
- mediaproc video trim long-video.mp4 --start 00:01:00 --duration 60
889
+ # 1. Convert all MOV files to MP4
890
+ mediaproc video transcode raw-footage/ -f mp4 -o converted/
585
891
 
586
- # Resize to 1080p
587
- mediaproc video resize trimmed.mp4 --scale 1080p
892
+ # 2. Resize all to 1080p
893
+ mediaproc video resize converted/ -s 1080p -o resized/
588
894
 
589
- # Compress for smaller file
590
- mediaproc video compress resized.mp4 -q medium
895
+ # 3. Compress all files
896
+ mediaproc video compress resized/ -q high --hw-accel -o final/
591
897
  ```
592
898
 
593
- ### 3. Extract Highlights
899
+ ### Workflow 4: Create Video Highlight Reel
900
+
901
+ Extract and combine best moments:
594
902
 
595
903
  ```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
904
+ # 1. Extract multiple highlight clips
905
+ mediaproc video trim game.mp4 -s 300 -d 15 -o highlight1.mp4
906
+ mediaproc video trim game.mp4 -s 850 -d 20 -o highlight2.mp4
907
+ mediaproc video trim game.mp4 -s 1200 -d 12 -o highlight3.mp4
908
+
909
+ # 2. Add speed effects to create excitement
910
+ mediaproc video trim highlight2.mp4 -s 0 -d 20 --speed 1.5 -o fast.mp4
599
911
 
600
- # Merge highlights
601
- mediaproc video merge highlight1.mp4 highlight2.mp4 -o best-moments.mp4
912
+ # 3. Merge with transitions
913
+ mediaproc video merge highlight1.mp4 fast.mp4 highlight3.mp4 \
914
+ --transition fade --transition-duration 1.5 -o reel.mp4
915
+
916
+ # 4. Final compress
917
+ mediaproc video compress reel.mp4 -q extreme -o final-reel.mp4
602
918
  ```
603
919
 
604
- ### 4. Create Video Thumbnails
920
+ ### Workflow 5: Archive Old Videos
921
+
922
+ Convert and compress old videos for storage:
605
923
 
606
924
  ```bash
607
- # Extract thumbnail from middle of video
608
- mediaproc video extract-thumbnail video.mp4 --time 00:00:30
925
+ # 1. Deinterlace old interlaced footage
926
+ mediaproc video resize old-video.avi -s 720p --deinterlace -o progressive.mp4
609
927
 
610
- # Create multiple thumbnails
611
- mediaproc video extract-frames video.mp4 --fps 0.1 --format jpg
928
+ # 2. Compress with H.265 for 50% space savings
929
+ mediaproc video compress progressive.mp4 -c h265 -q high --optimize-for archive
930
+
931
+ # 3. Extract thumbnail for catalog
932
+ mediaproc video extract-thumbnail progressive-compressed.mp4 --time 5
612
933
  ```
613
934
 
614
- ### 5. Batch Processing
935
+ ### Workflow 6: Prepare Course/Training Videos
936
+
937
+ Educational content optimization:
615
938
 
616
939
  ```bash
617
- # Compress all MP4 files
618
- for file in *.mp4; do
619
- mediaproc video compress "$file" -o "compressed_$file"
620
- done
940
+ # 1. Trim intro and outro
941
+ mediaproc video trim raw-recording.mp4 -s 10 -e 3600 -o main.mp4
621
942
 
622
- # Convert all AVI to MP4
623
- for file in *.avi; do
624
- mediaproc video transcode "$file" -f mp4
625
- done
943
+ # 2. Resize to standard resolution
944
+ mediaproc video resize main.mp4 -s 1080p --fps 30 -o standard.mp4
945
+
946
+ # 3. Compress for web delivery
947
+ mediaproc video compress standard.mp4 --optimize-for web -q high
626
948
  ```
627
949
 
628
- ## Performance Tips
950
+ ### Workflow 7: Create Slow Motion Effects
951
+
952
+ ```bash
953
+ # 1. Extract clip
954
+ mediaproc video trim action.mp4 -s 120 -d 5 -o clip.mp4
955
+
956
+ # 2. Apply 50% slow motion
957
+ mediaproc video trim clip.mp4 -s 0 -d 5 --speed 0.5 -o slow.mp4
958
+
959
+ # 3. Add fade-in and fade-out
960
+ mediaproc video trim slow.mp4 -s 0 -e end --fade-in 0.5 --fade-out 0.5
961
+ ```
962
+
963
+ ---
964
+
965
+ ## 💡 Usage Tips
966
+
967
+ ### Best Practices
968
+
969
+ 1. **Use `--dry-run` first** - Preview operations before processing
970
+ ```bash
971
+ mediaproc video compress input.mp4 -q high --dry-run
972
+ ```
973
+
974
+ 2. **Enable hardware acceleration** - 3-5x faster encoding with GPU
975
+ ```bash
976
+ mediaproc video resize input.mp4 -s 4K --hw-accel
977
+ ```
978
+
979
+ 3. **Process folders efficiently** - Batch process entire directories
980
+ ```bash
981
+ mediaproc video compress videos/ -q medium -o output/
982
+ ```
983
+
984
+ 4. **Use CRF over bitrate** - Better quality/size ratio
985
+ ```bash
986
+ mediaproc video compress input.mp4 --crf 23 # Better than --bitrate
987
+ ```
988
+
989
+ 5. **Choose the right codec** - H.265 for 50% better compression
990
+ ```bash
991
+ mediaproc video compress input.mp4 -c h265 -q high
992
+ ```
993
+
994
+ 6. **Fast trim for quick cuts** - Use stream copy for instant trimming
995
+ ```bash
996
+ mediaproc video trim input.mp4 -s 10 -d 30 --fast
997
+ ```
998
+
999
+ 7. **Two-pass for best quality** - Worth it for final renders
1000
+ ```bash
1001
+ mediaproc video compress input.mp4 -q extreme --two-pass
1002
+ ```
1003
+
1004
+ ### Performance Tips
629
1005
 
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
1006
+ - **Fast Mode**: Use `--fast` with trim for instant cuts (no re-encoding)
1007
+ - **Presets**: Use ultrafast/fast presets for quick processing, slow/veryslow for final output
1008
+ - **Threading**: More threads = faster (but diminishing returns beyond 8)
1009
+ - **GPU Acceleration**: Enable `--hw-accel` for 3-5x speed boost (requires compatible GPU)
1010
+ - **Format Selection**: H.264 is fastest, AV1 is slowest but best compression
1011
+
1012
+ ### Quality Guidelines
1013
+
1014
+ **For Distribution (recommended):**
1015
+ - Quality: `-q high` or `--crf 20-23`
1016
+ - Codec: h264 or h265
1017
+ - Resolution: 1080p or 1440p
1018
+
1019
+ **For Web/Streaming:**
1020
+ - Quality: `-q medium` or `--crf 23-28`
1021
+ - Optimization: `--optimize-for web`
1022
+ - Resolution: 720p or 1080p
1023
+
1024
+ **For Archive:**
1025
+ - Quality: `-q extreme` or `--crf 18`
1026
+ - Codec: h265 (best compression)
1027
+ - Options: `--two-pass --optimize-for archive`
1028
+
1029
+ **For Mobile:**
1030
+ - Quality: `-q medium`
1031
+ - Resolution: 720p or lower
1032
+ - Optimization: `--optimize-for mobile`
635
1033
 
636
1034
  ## Technical Details
637
1035