> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidnavigator.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyzing Videos

> Learn how to analyze videos to extract summaries, topics, and other insights.

## Overview

VidNavigator's analysis capabilities allow you to go beyond simple transcription and understand the content of a video at a deeper level. You can get an AI-generated summary, identify key topics and speakers, and even ask specific questions about the video's content.

Every analysis returns a `transcript_analysis` object with:

- `summary`: an overview of the content
- `people`: people mentioned, with the context they appear in
- `places`: locations referenced
- `key_subjects`: important topics, with a description and importance
- `query_answer`: when you pass a `query`, the direct `answer` plus the `relevant_segments` of the transcript that support it

## Prerequisites

- A valid VidNavigator API key.
- The [Python](https://docs.vidnavigator.com/sdks/python.md) or [JavaScript](https://docs.vidnavigator.com/sdks/javascript.md) SDK, version 2.1.0 (`pip install vidnavigator==2.1.0` or `npm install vidnavigator@2.1.0`).

## Billing

AI analysis consumes `analysis_request` units based on context size. One unit covers up to **15,000 total tokens**, and longer contexts are billed with `ceil(total_tokens / 15000)`. For example, a video that takes 17,000 total tokens costs 2 `analysis_request` units.

Pass `include_usage=True` (Python) or `include_usage: true` (JavaScript) to receive a `usage` block with the exact charges and LLM token counts.

## Analyzing a Video

```python Python
from vidnavigator import VidNavigatorClient, VidNavigatorError

client = VidNavigatorClient()  # reads VIDNAVIGATOR_API_KEY

try:
    resp = client.analyze_video(
        video_url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        query="What is the main theme of this song?",
    )
    analysis = resp.data.transcript_analysis

    print("Summary:", analysis.summary)
    print("Answer to your query:", analysis.query_answer.answer)

    # people, places and key_subjects are lists of plain dicts
    for person in analysis.people or []:
        print("Person:", person)    # {"name": ..., "context": ...}
    for subject in analysis.key_subjects or []:
        print("Subject:", subject)  # {"name": ..., "description": ..., "importance": ...}
except VidNavigatorError as e:
    print(f"An error occurred: {e}")
```

```javascript JavaScript
import { VidNavigatorClient, VidNavigatorError } from 'vidnavigator';

const vn = new VidNavigatorClient({
  apiKey: process.env.VIDNAVIGATOR_API_KEY,
});

try {
  const { transcript_analysis } = await vn.analyzeVideo({
    video_url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
    query: 'What is the main theme of this song?',
  });

  console.log('Summary:', transcript_analysis.summary);
  console.log('Answer to your query:', transcript_analysis.query_answer?.answer);
  console.log('Supporting excerpts:', transcript_analysis.query_answer?.relevant_segments);

  for (const person of transcript_analysis.people ?? []) {
    console.log(`Person: ${person.name} -- ${person.context}`);
  }
  for (const subject of transcript_analysis.key_subjects ?? []) {
    console.log(`Subject: ${subject.name} -- ${subject.description}`);
  }
} catch (error) {
  if (error instanceof VidNavigatorError) {
    console.error(`An error occurred: ${error.message}`);
  } else {
    throw error;
  }
}
```

`query` is optional. Without it you still get the summary, people, places and key subjects.

## Analyzing an Uploaded File

Files you have [uploaded](https://docs.vidnavigator.com/guides/uploading-videos.md) are analyzed the same way, by `file_id`:

```python Python
resp = client.analyze_file(
    file_id="your_file_id",
    query="What are the key action items from this meeting?",
)
print(resp.data.transcript_analysis.summary)
print(resp.data.transcript_analysis.query_answer.answer)
```

```javascript JavaScript
const { transcript_analysis } = await vn.analyzeFile({
  file_id: 'your_file_id',
  query: 'What are the key action items from this meeting?',
});
console.log(transcript_analysis.summary);
console.log(transcript_analysis.query_answer?.answer);
```

## Next Steps

- Need specific fields rather than a free-form summary? Use [structured data extraction](https://docs.vidnavigator.com/guides/data-extraction.md).
- See the [Analyze Video](https://docs.vidnavigator.com/api-reference/endpoint/analyze-video.md) and [Analyze File](https://docs.vidnavigator.com/api-reference/endpoint/analyze-file.md) API references.
