Skip to content

ShortNaas/video_process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Video Processing Script

A powerful bash script for compressing video files and removing metadata using FFmpeg. Perfect for preparing videos for cloud upload with reduced file sizes and enhanced privacy.

Features

  • Video Compression: Reduce file sizes without noticeable quality loss using H.264 encoding
  • Metadata Removal: Strip all metadata for privacy (location, device info, timestamps)
  • Flexible Modes: Compress only, remove metadata only, or do both
  • Batch Processing: Handle multiple files at once
  • Quality Control: Adjustable compression settings
  • File Size Reporting: Shows compression percentage after processing
  • Safe Processing: Creates new files, preserves originals by default

Requirements

  • Linux/Unix system
  • FFmpeg installed (sudo apt install ffmpeg on Ubuntu/Debian)
  • Bash shell

Installation

System-Wide Installation (Recommended)

Make the script available to all users from anywhere:

# Download or create the script
chmod +x video_process.sh

# Install system-wide (requires sudo)
sudo cp video_process.sh /usr/local/bin/video_process

# Test installation
video_process --help

Personal Installation

Install for current user only:

# Create personal bin directory
mkdir -p ~/bin

# Install script
cp video_process.sh ~/bin/video_process
chmod +x ~/bin/video_process

# Add to PATH (if not already done)
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Test installation
video_process --help

Alternative: Use ~/.local/bin

Many distributions already include ~/.local/bin in PATH:

mkdir -p ~/.local/bin
cp video_process.sh ~/.local/bin/video_process
chmod +x ~/.local/bin/video_process

Usage

Basic Usage

# Compress and remove metadata (default)
video_process input.mp4

# Process multiple files
video_process *.mp4 *.mov *.avi

Options

Option Description Example
-c, --compress-only Only compress video (keep metadata) video_process -c video.mp4
-m, --metadata-only Only remove metadata (no compression) video_process -m video.mp4
-q, --quality CRF Set quality (CRF value, default: 22) video_process -q 18 video.mp4
-p, --preset PRESET Set encoding preset (default: slow) video_process -p fast video.mp4
-o, --output-dir DIR Output directory (default: processed) video_process -o compressed *.mp4
-r, --remove-original Remove original files after processing video_process -r video.mp4
-h, --help Show help message video_process --help

Quality Settings (CRF Values)

CRF Quality File Size Use Case
18-20 Excellent Large Archival, professional
22-24 High Medium General use, cloud upload
26-28 Good Small Web streaming, mobile

Encoding Presets

Preset Speed Efficiency Use Case
ultrafast Fastest Poor Real-time encoding
fast Fast Good Quick processing
slow Slow Best Best compression (default)
veryslow Slowest Excellent Maximum efficiency

Examples

Compress for Cloud Upload

# Default settings - good balance of quality and size
video_process vacation_video.mp4

# Higher compression for limited bandwidth
video_process -q 26 -p fast large_video.mov

Privacy-Focused Processing

# Remove metadata only (no compression)
video_process -m sensitive_video.mp4

# Compress and remove all metadata
video_process -o clean_videos *.mp4

Batch Processing

# Process all MP4 files in current directory
video_process *.mp4

# Custom output directory and remove originals
video_process -o compressed -r *.mov *.avi

# High quality compression for multiple files
video_process -q 20 -p slow *.mkv

Output

The script creates processed files in the specified output directory (default: processed/) with the suffix _processed added to the filename.

Example:

  • Input: my_video.mp4
  • Output: processed/my_video_processed.mp4

What It Does

Compression Mode

  • Re-encodes video using H.264 codec for better compression
  • Preserves original audio quality (no re-encoding)
  • Maintains metadata information

Metadata Removal Mode

  • Strips all metadata tags (location, device info, timestamps)
  • Copies video and audio streams without re-encoding
  • Fastest processing mode

Combined Mode (Default)

  • Compresses video for smaller file size
  • Removes all metadata for privacy
  • Most comprehensive processing

Troubleshooting

FFmpeg Not Found

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# CentOS/RHEL/Fedora
sudo dnf install ffmpeg

# Arch Linux
sudo pacman -S ffmpeg

Permission Denied

# Make script executable
chmod +x video_process.sh

# For system-wide installation
sudo cp video_process.sh /usr/local/bin/video_process

Script Not Found After Installation

# Check if directory is in PATH
echo $PATH

# Add to PATH permanently
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Technical Details

  • Video Codec: H.264 (libx264) for maximum compatibility
  • Audio Handling: Stream copy (no quality loss)
  • Metadata Removal: Uses FFmpeg's -map_metadata -1 flag
  • Quality Control: CRF (Constant Rate Factor) for consistent quality
  • File Safety: Creates new files, preserves originals by default

Contributing

Feel free to submit issues, feature requests, or improvements. The script is designed to be simple, reliable, and user-friendly.

License

This script is provided as-is for educational and practical use. Modify and distribute freely.

About

A simple script to compress and/or remove metadata from a vdieo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages