Welcome.

Holo
โ† Back to Projects
๐Ÿ“

Subtitle & MP3 Extractor

Project Category: Individual Project (Personal Productivity Tool)

FFmpeg Python 3.13 Batch Automation
View Repo

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.

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

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