Skip to main content

ytranscript

Fetch YouTube video transcripts from the command line. Uses YouTube's caption API when available, falls back to local Whisper transcription for videos without captions.

Installation

pip install ytranscript

System requirement: ffmpeg must be installed for the Whisper fallback.

# macOS
brew install ffmpeg

# Ubuntu/Debian
apt install ffmpeg

Usage

# Basic — auto-detect language
ytranscript 'https://www.youtube.com/watch?v=VIDEO_ID'

# Markdown output with metadata
ytranscript URL -f md

# JSON output (for pipelines)
ytranscript URL -f json

# Include timestamps
ytranscript URL --timestamps

# Force Whisper transcription
ytranscript URL --whisper

# Specify language
ytranscript URL --lang zh

# Choose Whisper model (tiny/base/small/medium/large)
ytranscript URL --model small

Batch processing

# Multiple URLs at once
ytranscript URL1 URL2 URL3 --output-dir ./transcripts/

# From a file (one URL per line)
ytranscript --batch urls.txt --output-dir ./transcripts/

# Entire playlist or channel
ytranscript 'https://www.youtube.com/playlist?list=PLAYLIST_ID' --output-dir ./transcripts/

Options

Flag Description
-f plain|json|md Output format (default: plain)
--lang CODE Language code, e.g. en, zh, ja (default: auto-detect)
--timestamps Prefix each line with [MM:SS]
--whisper Force local Whisper transcription
--model SIZE Whisper model: tiny, base, small, medium, large (default: base)
--no-metadata Skip title/channel/duration fetch
--no-cache Bypass disk cache
--batch FILE Read URLs from a file
--output-dir DIR Write each transcript to DIR/{video_id}.{ext}

Caching

Transcripts are cached at ~/.cache/ytranscript/ by default. Subsequent calls for the same video are instant. Use --no-cache to force a fresh fetch.

Environment variables

Variable Description
YT_TRANSCRIPT_MODEL Default Whisper model size (e.g. small)

How it works

  1. Tries youtube-transcript-api — fast, no download needed
  2. If no captions exist, downloads audio via yt-dlp and transcribes locally with faster-whisper

This covers ~100% of videos, including those without any captions.

License

MIT

Metadata

Release files for ytranscript 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ytranscript 0.1.0
File Size Uploaded
ytranscript-0.1.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ytranscript 0.1.0
File Interpreter ABI Platform
ytranscript-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / ytranscript-0.1.0.tar.gz

Download URL ytranscript-0.1.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3dc69a0b6ac6c81bd580da8ed3d9f3566e4baeed995752204898750da04d1658
BLAKE2b-256 checksum
How to use checksums
e701580c61f2acbb2dc2bccf09021bfa3a621e40c9f790f43c6a51343d2bde4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / ytranscript-0.1.0-py3-none-any.whl

Download URL ytranscript-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc989842995516e18c5142d31cd3a7a2f847b0ff86fde76e05868f6216507627
BLAKE2b-256 checksum
How to use checksums
166caedc4a361227ba7c82564c5ffbaf69439b48eb65c32f4532cfd01a6ba8b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page