← Back to Projects

📝 Subtitle & MP3 Extractor

FFmpeg Python 3.13 Batch Automation

Project Category: Individual Project (Personal Productivity Tool)

I built a smart Python wrapper around FFmpeg that implements intelligent fallback logic: check for subtitles → extract if found → fallback to MP3 audio if not. My design philosophy: never fail empty - always produce usable output regardless of input video structure.

🧰 Technologies & Tools Used

FFmpeg

A complete cross-platform solution for recording, converting, and streaming audio/video. FFmpeg can decode virtually any media format, probe file metadata, extract individual streams (audio, video, subtitles), and transcode between formats. It's the industry-standard tool for media manipulation, used by YouTube, VLC, and thousands of applications. I use it for two operations: extracting SRT subtitle tracks from video containers, and converting audio streams to MP3 format.

Python Subprocess

Python's subprocess module allows me to spawn new processes and connect to their input/output/error pipes. I use it to execute FFmpeg commands, capture output, and parse results. This lets me integrate FFmpeg's powerful media processing into a Python workflow with error handling and conditional logic.

🔧 My Implementation Logic

1
Subtitle Stream Detection
I wrote code to probe video metadata using FFmpeg, parsing stream types to identify subtitle tracks
2
Conditional Extraction
My pipeline extracts SRT subtitles if found → Outputs to extracted_captions/
3
Intelligent Fallback I Designed
If no subtitles exist, my code automatically pivots to MP3 extraction @ 192kbps → Outputs to extracted_audio/
4
Guaranteed Output Philosophy
My error handling ensures the script never exits empty - you always get either subtitles OR audio

💡 Why I Built This

Problem I Solved

FFmpeg alone requires knowing if subtitles exist beforehand. My wrapper handles detection and decision-making automatically

My Fallback Architecture

I implemented try-except logic: attempt subtitle extraction → if fails → extract audio instead

UX Design Choice

I created drag-and-drop batch files for non-technical users - no command-line knowledge required

Output Organization I Designed

My code creates separate directories (extracted_captions/ vs extracted_audio/) for easy file management

💻 Usage

Batch File (Drag-and-Drop)

extract_cc.bat "path\to\video.mp4"

Python Script (Direct)

py cc_extractor.py "video.mp4"

Example Output

Video-subtitle&mp3-extractor/
├── extracted_captions/        # Created if subtitles found
│   └── video_name.srt
├── extracted_audio/           # Created if no subtitles
│   └── video_name.mp3

📁 Supported Formats

🔧 Requirements

💡 Use Cases

View on GitHub →