Skip to content

Gorachand22/splitvid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🎬 SplitVid for WSL2

Split Large Video Files into Smaller Chunks — Fast, Simple, and Lossless

A powerful video splitter designed for Windows users running WSL2 Ubuntu

Python FFmpeg WSL2 License


FeaturesQuick StartInstallationUsageFAQ


🎯 What is SplitVid?

SplitVid for WSL2 is a Python script that splits large video files into smaller, manageable chunks. It's specifically designed for users who:

  • 📁 Have large video files on Windows drives (F:, D:, etc.)
  • 🐧 Run Python and FFmpeg in WSL2 Ubuntu
  • ⚡ Want fast, lossless video splitting without re-encoding
  • 🎓 Need to upload videos with size limits (Moodle, Google Drive, LMS platforms)

Why WSL2? WSL2 (Windows Subsystem for Linux) provides a lightweight Linux environment inside Windows. Your files stay on Windows drives, but processing happens in Linux — giving you the best of both worlds!


✨ Features

Feature Description
🚀 Blazing Fast Uses FFmpeg stream copy — no re-encoding, splits in seconds
📏 Precise Splitting Accurately divides videos into your specified chunk size
🔄 Auto Path Conversion Automatically converts Windows paths (F:\folder) to WSL paths (/mnt/f/folder)
Tool Verification Checks for FFmpeg/FFprobe before running
👀 Dry Run Mode Preview what will happen before actual splitting
📊 Progress Tracking Real-time progress with timestamps and file sizes
🎨 Beautiful Output Colorful, emoji-rich terminal output
📁 Batch Processing Process multiple videos in one run

🖥️ Supported Video Formats

.mp4  .mkv  .avi  .mov  .flv  .wmv  .webm  .m4v

📋 Requirements

What You Need

Requirement How to Check Install Command
WSL2 Ubuntu Open PowerShell, type wsl Microsoft WSL Guide
Python 3 In WSL: python3 --version sudo apt install python3
FFmpeg In WSL: ffmpeg -version sudo apt install ffmpeg -y

🚀 Quick Start

Step 1: Open WSL2 Ubuntu

Press Win + X and select "Ubuntu" or open PowerShell and type:

wsl

Step 2: Download the Script

# Navigate to your preferred directory
cd ~

# Download the script (or copy it manually)
# Save as: video_splitter.py

Step 3: Run the Script

# Basic usage - split videos in a Windows folder
python3 video_splitter.py "F:\new_course\splitsource"

That's it! Your split videos will be in F:\new_course\splitsource\output\


📖 Installation

Installing WSL2 Ubuntu (One-Time Setup)

If you don't have WSL2 installed yet, follow these steps:

1. Enable WSL2 in Windows

Open PowerShell as Administrator and run:

wsl --install

This will:

  • Enable WSL2
  • Download and install Ubuntu
  • Set up everything automatically

2. Restart Your Computer

After the installation completes, restart Windows.

3. Complete Ubuntu Setup

  • Open Ubuntu from the Start menu
  • Create a username and password when prompted

Installing Required Tools in WSL2

Open your WSL2 Ubuntu terminal and run:

# Update package lists
sudo apt update

# Install FFmpeg (includes ffprobe)
sudo apt install ffmpeg -y

# Verify installations
python3 --version
ffmpeg -version

Getting the Script

Option A: Direct Download

Save the video_splitter.py file to any location in your WSL2 filesystem.

Option B: Clone from GitHub

git clone https://github.com/Gorachand22/splitvid.git cd splitvid

# Split all videos in a folder (default: 1.8 GB chunks)
python3 video_splitter.py "F:\new_course\splitsource"

Advanced Options

# Custom chunk size (2 GB)
python3 video_splitter.py "F:\new_course\splitsource" --size 2.0

# Preview mode - see what would happen without splitting
python3 video_splitter.py "F:\new_course\splitsource" --dry-run

# Custom output folder
python3 video_splitter.py "F:\new_course\splitsource" --output "F:\processed_videos"

# Specify custom video extensions
python3 video_splitter.py "F:\new_course\splitsource" --ext ".mp4,.mkv,.avi"

Command Line Arguments

Argument Short Default Description
source - Required Folder containing video files
--size -s 1.8 Split size in GB
--output -o source/output Output folder path
--dry-run -n False Preview without splitting
--ext -e .mp4,.mkv,... Video extensions to process

⚙️ Configuration Explained

Path Formats

The script accepts both Windows and WSL path formats:

Windows Path WSL Equivalent Notes
F:\videos /mnt/f/videos ✅ Both work
D:\Movies\BigFiles /mnt/d/Movies/BigFiles ✅ Both work
C:\Users\Name\Videos /mnt/c/Users/Name/Videos ✅ Both work

How WSL2 Mounts Work: Windows drives are automatically mounted under /mnt/ in WSL2. Drive F: becomes /mnt/f/, drive D: becomes /mnt/d/, etc.

Understanding Split Size

Setting Use Case
--size 1.8 Default, fits most upload limits (Moodle, LMS)
--size 2.0 For platforms with 2GB limit
--size 0.7 For CD burning (700MB)
--size 4.7 For DVD burning (4.7GB)

How Splitting Works

Original: 12 GB video
Target: 1.8 GB per file

┌─────────────────────────────────────────────────┐
│  Original Video (12 GB)                         │
└─────────────────────────────────────────────────┘
                    ↓ SPLIT ↓
┌──────────┐ ┌──────────┐ ┌──────────┐     ┌──────────┐
│ Part 001 │ │ Part 002 │ │ Part 003 │ ... │ Part 007 │
│  1.7 GB  │ │  1.7 GB  │ │  1.7 GB  │     │  1.7 GB  │
└──────────┘ └──────────┘ └──────────┘     └──────────┘

The script:

  1. Calculates the number of parts needed: ceil(12GB ÷ 1.8GB) = 7 parts
  2. Divides the total duration equally among parts
  3. Splits using FFmpeg stream copy (fast, lossless)

📁 Project Structure

splitvid-wsl2/
│
├── video_splitter.py    # Main script
├── README.md                 # This documentation
└── LICENSE                   # MIT License

❓ FAQ

General Questions

🔴 Do I need to copy videos to WSL2?

No! Your videos stay on your Windows drives. The script reads and writes directly to Windows paths via WSL2's /mnt/ mounts. This saves disk space since WSL2's virtual disk would grow if you copied files into it.

🔴 Will splitting reduce video quality?

No! The script uses FFmpeg's -c copy option, which copies the video/audio streams without re-encoding. It's like cutting a rope — the pieces are made of the same material.

🔴 How long does splitting take?

Very fast! Since there's no re-encoding, a 12GB video typically splits in 1-2 minutes. The speed depends mainly on your disk read/write speed.

🔴 Can I split other file types?

The script is designed for video files. However, since it uses FFmpeg stream copy, it can technically split any media file that FFmpeg supports (audio files, etc.). Add custom extensions with --ext.

Troubleshooting

🔴 "ffmpeg not found" error

Install FFmpeg in WSL2:

sudo apt update
sudo apt install ffmpeg -y

Verify installation:

ffmpeg -version
🔴 "Source directory does not exist" error

Make sure:

  1. The drive letter is correct — Check in Windows Explorer first
  2. The path exists — Verify the folder exists
  3. WSL can access the drive — Run ls /mnt/f/ in WSL

If WSL can't see a drive, try remounting:

sudo mkdir -p /mnt/f
sudo mount -t drvfs F: /mnt/f
🔴 Split videos have slight size variations

This is normal. The script splits by time, not exact bytes. FFmpeg splits at keyframes to avoid corruption, which can cause small size variations. The differences are usually negligible.

🔴 Some parts won't play in my player

Try using VLC Media Player — it handles split videos better than most players. The first few seconds might be black due to keyframe alignment.

For perfect playback, consider re-encoding (slower but frame-accurate):

# Replace -c copy with re-encoding (slower)
# This is not recommended for large files

🛠️ Technical Details

Dependencies

  • Python 3.6+ — For running the script
  • FFmpeg — For video processing
  • FFprobe — For video analysis (included with FFmpeg)

How It Works

  1. Scan — Finds all video files in the source directory
  2. Analyze — Gets duration and file size using FFprobe
  3. Calculate — Determines optimal number of parts
  4. Split — Uses FFmpeg stream copy for fast, lossless splitting
  5. Verify — Checks output files exist with proper size

FFmpeg Command Used

ffmpeg -y \
  -ss [START_TIME] \      # Start position
  -i [INPUT_FILE] \       # Input video
  -t [DURATION] \         # Part duration
  -c copy \               # Stream copy (no re-encoding)
  -avoid_negative_ts 1 \  # Fix timing issues
  -map 0 \                # Include all streams
  [OUTPUT_FILE]           # Output path

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

🌟 Support the Project

If this tool saved you time, consider:

  • Starring the repository
  • 🐛 Reporting bugs via Issues
  • 💡 Suggesting new features
  • 📢 Sharing with others who might find it useful

Made with ❤️ for the WSL2 community

Split large videos. Upload anywhere. No quality loss.


⬆ Back to Top

About

Split Large Video Files into Smaller Chunks — Fast, Simple, and Lossless

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages