HomeBlog

Ollama: Summarize YouTube Videos Without Paying for Tokens

Terminal pipeline piping a YouTube transcript through jq into a local Ollama model

You can make Ollama summarize YouTube videos with one shell pipe: fetch the transcript over HTTP, extract the text with jq, feed it to a local model. No OpenAI bill, no data leaving your machine except the transcript fetch itself. Here's the pipe, the context-window math that makes it work, and where it falls short.

The one-liner

Grab the shared demo key first (or bring your own — more on that below):

API_KEY=$(curl -s https://youtube2text.org/api/demo-key | jq -r .apiKey)

Then:

curl -s "https://youtube2text.org/api/transcribe?url=https://www.youtube.com/watch?v=VIDEO_ID&maxChars=12000" \
  -H "x-api-key: $API_KEY" \
  | jq -r .result.content \
  | ollama run llama3.1 "Summarize this video transcript in five bullet points:"

The API returns {"result": {"videoId", "title", "pubDate", "content", ...}}; jq -r .result.content strips it down to the raw text, and Ollama appends the piped stdin to the prompt argument. Thirty seconds later you have bullet points and YouTube never saw a request from your IP — the transcript fetch goes through youtube2text.org, which handles the part that gets blocked when you scrape from your own machine.

Why maxChars=12000

This is the number people get wrong. Ollama runs models with a 4096-token context by default, and everything competes for it: your prompt, the transcript, and the model's output. At roughly 4 characters per token, 12,000 characters of transcript is ~3,000 tokens, leaving headroom for the summary. Pipe in a full 90-minute podcast at the API's default cap of 150,000 characters and Ollama silently truncates from the front — the model summarizes the last ten minutes and confidently ignores the rest. No error, just a wrong answer.

If your hardware has RAM to spare, raise both ends together:

OLLAMA_CONTEXT_LENGTH=16384 ollama serve

then bump maxChars to around 50000. Scale the two numbers in lockstep or you're back to silent truncation.

Make it a shell function

yt-summary() {
  curl -s "https://youtube2text.org/api/transcribe?url=$1&maxChars=12000" \
    -H "x-api-key: $API_KEY" \
    | jq -r .result.content \
    | ollama run llama3.1 "Summarize this video transcript in five bullet points:"
}

yt-summary "https://www.youtube.com/watch?v=VIDEO_ID"

Swap the prompt for whatever you actually need — "extract every tool mentioned", "list the action items", "translate to German". Same pipe, different instruction. For turning lectures into structured notes there's a longer workflow in study notes from lecture videos.

The privacy and cost case

Only one thing leaves your machine: the transcript request to youtube2text.org. The video's content, your prompts, and the model's output all stay local. For anyone summarizing internal training videos, competitor research, or content they'd rather not ship to a cloud LLM, that's the entire pitch. Cost side: the LLM inference is free forever; the only metered piece is the transcript fetch.

Where it falls short

Honest limitation: an 8B model summarizing a capped slice of an hour-long video will miss things. maxChars truncates from a fixed budget, and llama3.1 at 4k context is not doing deep synthesis — it's doing competent compression of what fits. For quick "is this video worth my time" triage it's excellent. For research-grade extraction across long content, either run a bigger model with a real context window or index everything properly — see RAG over a YouTube channel for that route.

Also: the demo key is shared and capped at 5 videos per month per IP. It exists so the one-liner above works before you've signed up for anything. Once you're past kicking the tires, get your own key — free tier is also 5 videos/month but it's yours, and $5.99 buys 50.