Sign in Get free API key
Home / Use cases / Video chapters / Video Chapters From Transcript
Use case

Create video chapters from a transcript

Generate chapter markers for long videos. Use TranscriptAPI timestamps to split a video into sections and title each one automatically.

Get API keyRead the docs
Request
curl "https://api.transcriptapi.org/v1/youtube/transcript?video=dQw4w9WgXcQ" \
  -H "X-API-Key: YOUR_API_KEY"
video chapters from transcript response example in JSON format
The problem

Why this is hard without an API

In practice, chapters make long videos easier to navigate and can improve watch time. Writing them by hand means watching the whole video.

Moreover, a timestamped transcript already marks where every sentence starts, which is exactly what chapters need.

How it works

Four steps with TranscriptAPI

1

video chapters from transcript: Fetch timestamped text

In short, get the transcript with start times for every segment.

2

video chapters from transcript: Split into windows

Group segments into time windows, for example five minutes each, or split where the topic changes.

3

video chapters from transcript: Title each section

Of course, ask your model for a short title for each section.

4

video chapters from transcript: Format the chapters

Overall, output a list of mm:ss timestamps and titles ready for your video description.

Example

video chapters from transcript: See it in code

In short, set your API key in the TRANSCRIPTAPI_KEY environment variable. Also, the helper below is used in the example.

Python
import os, requests

API = 'https://api.transcriptapi.org'
HEADERS = {'X-API-Key': os.environ['TRANSCRIPTAPI_KEY']}

def get_transcript(video, lang='en'):
    r = requests.get(API + '/v1/youtube/transcript',
                     params={'video': video, 'lang': lang}, headers=HEADERS)
    r.raise_for_status()
    return r.json()

data = get_transcript('dQw4w9WgXcQ')
window = 300  # seconds
sections = {}
for s in data['transcript']:
    k = int(s['start'] // window)
    sections.setdefault(k, []).append(s['text'])

for k, parts in sections.items():
    mm, ss = divmod(k * window, 60)
    text = ' '.join(parts)
    # ask your LLM for a short title for this section
    print('%02d:%02d' % (mm, ss), text[:60])

Of course, the transcript endpoint returns the video details and timed segments:

Response · 200
{
  "video_id": "dQw4w9WgXcQ",
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up",
  "author": "Rick Astley",
  "length_seconds": 213,
  "language_code": "en",
  "is_generated": false,
  "available_languages": [
    { "language_code": "en", "name": "English", "is_generated": false }
  ],
  "transcript": [
    { "text": "We're no strangers to love", "start": 18.64, "duration": 3.2 }
  ],
  "cached": false
}
What you get

video chapters from transcript: why teams use it for this

✓

Overall, chapters based on real timestamps, not guesses.

✓

Fast for long interviews, lectures and podcasts.

✓

In short, works with auto-generated and manual captions.

✓

Of course, re-run it whenever you edit the video.

Best practices

Tips for better results

Tip 1

Overall, start the first chapter at 00:00. Also, most platforms require it.

Tip 2

In fact, keep titles short and descriptive.

Tip 3

Merge very short sections to avoid dozens of tiny chapters.

What to plan before you build

First, list the formats you need and the people who will use them. Also, decide how often you will run the job. In addition, keep each output linked to its source video, so you can trace every claim back to the original words.

However, always review automatic output before it goes public. Meanwhile, keep a short style guide, so every result stays consistent. For example, set rules for chapter length and title style. Moreover, the JSON format guide is a useful reference when you design the data format. Finally, test the flow on a few short videos first. Then, scale up once the results look right. Besides, log every failed request, so you can retry it later without losing any work. Therefore, a small pilot saves time, and it shows early which settings need a change. As a result, your team spends less effort on fixes and more on useful output for readers.

FAQ

Frequently asked questions

Can I get captions as SRT or VTT?

Yes. Of course, use the format parameter to get subtitle formats where the platform supports them.

Does this work for Shorts?

Shorts are short, so chapters are rarely needed. Furthermore, the endpoint works the same way.

How accurate are the timestamps?

In short, they come from the video's captions, so they match the captions on the video.

Keep exploring

Related use cases

Podcast show notes

Generate podcast show notes from transcripts

Video summarizer

Of course, build a YouTube video summarizer

Lecture notes

Create lecture notes and study guides from videos

Start with an API key

billed per transcript. Also, failed requests are free.

Get API keyRead the docs