A Python tool that processes CSV files containing timestamps and generates FFmpeg commands to extract video clips based on START/STOP markers.
- Processes CSV files with timestamp data
- Generates FFmpeg commands for video clip extraction
- Creates executable shell scripts
- Handles errors gracefully
- Configurable output directory
- One-command execution with progress feedback
- Python 3.6 or higher
- FFmpeg installed on your system
- Required Python packages (install using requirements.txt)
- Clone this repository:
git clone <repository-url>
cd timestamp-clipper- Create and activate a virtual environment:
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# .\venv\Scripts\activate- Install the required Python packages:
python3 -m pip install -r requirements.txt- Ensure FFmpeg is installed on your system:
# On macOS (using Homebrew)
brew install ffmpeg
# On Ubuntu/Debian
sudo apt-get install ffmpeg
# On Windows (using Chocolatey)
choco install ffmpeg- Make the wrapper script executable:
chmod +x extract_clips.shUse the wrapper script for a one-command solution:
./extract_clips.sh input.csv input.mp4 [output_dir]Example:
./extract_clips.sh timestamps.csv video.mp4 clips/The wrapper script will:
- Generate the FFmpeg commands
- Execute them sequentially
- Show progress for each clip
- Handle errors gracefully
- Clean up temporary files
Alternatively, you can run the Python script directly:
python3 video_clip_extractor.py --csv input.csv --video input.mp4 --output-dir clips/This will generate a script with FFmpeg commands that you can execute manually.
csv_file: Path to the CSV file containing timestamps (required)video_file: Path to the input video file (required)output_dir: Directory where clips will be saved (default: "clips")
The CSV file should contain at least these columns:
Time In: Timestamp in HH:MM:SS formatComment: Text containing START/STOP markers
Example CSV format:
Time In,Comment
00:00:10,START - Scene 1
00:00:20,STOP
00:00:30,START - Scene 2
00:00:40,STOP
The script will:
- Create the specified output directory if it doesn't exist
- Generate video clips in the output directory
- Show progress for each clip being processed
- Provide a summary when complete
The script includes comprehensive error handling for:
- Missing or invalid input files
- Invalid timestamp formats
- Invalid START/STOP pairs
- File permission issues
- FFmpeg processing errors
[Your License Here]
Kevin von James