Summarize this article with:
- Detecting shot changes in video content is a crucial task in video analysis, enabling tasks like scene segmentation, content extraction, and video editing.
- Eden AI provides a platform where you can test different AI models before integrating them, allowing you to evaluate and select the provider that best aligns with your needs.
- Shot change detection now goes through a multimodal LLM that returns the list of shots as JSON.
- EdenAI provides a robust, easy-to-use API that integrates multiple AI providers for background removal, shot detection, and other video analysis tasks.
- By leveraging EdenAI's APIs, you can quickly integrate advanced video analysis features, such as shot change detection, into your applications.
Detecting shot changes in video content is a crucial task in video analysis, enabling tasks like scene segmentation, content extraction, and video editing.
In this tutorial, we'll walk through how to use the EdenAI API to perform shot change detection in a video using JavaScript.
What is Video Shot Change Detection?

Video Shot Change Detection annotates a video with segments that are generated by detecting abrupt shot changes within the video.
This process helps break the video into distinct sections, making it easier to analyze and edit.
How to Detect Shot Changes in Videos
Get Access to Eden AI API
1. Sign up: Visit Eden AI and sign up for a free account to get started. Once registered, navigate to the API section to find your personal API key—this key gives you access to a wide range of AI services, including Shot Change Detection.

2. Navigate to Video Technologies – Log in and head to the Video Technologies section.
3. Select Shot Change Detection– From there, select the Shot Change Detection option, or dive into more advanced features based on your requirements.
Live Test Models on Eden AI
Eden AI provides a platform where you can test different AI models before integrating them, allowing you to evaluate and select the provider that best aligns with your needs.
Implementing the Shot Change Detection in JavaScript
Shot change detection now goes through a multimodal LLM that accepts video as input, called with Eden AI’s OpenAI-compatible chat completions endpoint. It works in two steps:
- Sending the request: you send the video URL, your instruction and the JSON format you expect for the answer.
- Reading the results: the shots come back in the same response, as JSON, so there is no job to poll.
A 10-second clip is processed in a few seconds. For long videos, set a generous timeout on your HTTP client.
Install JavaScript Requests Module
To make HTTP requests from your JavaScript code, we'll be using axios, a promise-based HTTP client that works in both the browser and Node.js.
It’s easy to use, highly customizable, and simplifies sending requests and handling responses. To install axios, run the following command:
npm install axios
Making the Request
We send a POST request to Eden AI’s chat completions endpoint, passing in the URL of the video you want to analyze.
The request also tells the model what to do and which JSON format to use for its answer.
Code Example: Request
const axios = require('axios');
const API_KEY = 'your_api_key_here'; // Replace with your actual EdenAI API key
const url = 'https://api.edenai.run/v3/chat/completions';
// The JSON format expected for the answer: one entry per shot
const schema = {
type: 'object',
properties: {
shots: {
type: 'array',
items: {
type: 'object',
properties: {
start_time: { type: 'number' },
end_time: { type: 'number' },
description: { type: 'string' }
},
required: ['start_time', 'end_time', 'description']
}
}
},
required: ['shots']
};
const json_payload = {
model: 'google/gemini-2.5-flash', // Any model that accepts video input
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'List every shot in this video. A new shot starts at each camera cut. Give start and end times in seconds.' },
{ type: 'image_url', image_url: { url: '🔗 URL of your video' } } // Replace with the actual video URL
]
}],
response_format: { type: 'json_schema', json_schema: { name: 'shots', schema: schema } }
};
axios.post(url, json_payload, {
headers: {
Authorization: `Bearer ${API_KEY}`
}
})
.then(response => {
showShots(response.data); // See the next step
})
.catch(error => {
console.error('Error:', error.response ? error.response.data : error.message);
});
Explanation of Code:
- API_KEY: This is your unique API key for authenticating with the EdenAI platform. You should replace it with your actual API key.
- url: Eden AI’s OpenAI-compatible chat completions endpoint, https://api.edenai.run/v3/chat/completions.
- json_payload: The parameters sent to Eden AI:
- model: The multimodal LLM to use, in the provider/model format. It must accept video: check for video in input_modalities at https://api.edenai.run/v3/models (for example google/gemini-2.5-flash or amazon/amazon.nova-2-lite-v1:0).
- messages: Your instruction in a text block, and the public URL of your video in an image_url block.
- response_format: The JSON schema the answer must follow, here a list of shots with start and end times and a short description.
- model: The multimodal LLM to use, in the provider/model format. It must accept video: check for video in input_modalities at https://api.edenai.run/v3/models (for example google/gemini-2.5-flash or amazon/amazon.nova-2-lite-v1:0).
- Authorization: This header includes your API key for authentication.
What Happens in the Request?
- Request: The POST request sends the video and the instruction to the model.
- Response: Eden AI returns the model’s answer, with the shots as JSON, and the cost of the request.
Reading the Results
The shots are in the same response: the showShots function called in the previous step reads them.
Code Example: Reading the Results
function showShots(result) {
// The shots are in the model's answer, as a JSON string
const { shots } = JSON.parse(result.choices[0].message.content);
shots.forEach((shot, i) => {
console.log(`Shot ${i + 1}: ${shot.start_time}s to ${shot.end_time}s, ${shot.description}`);
});
console.log('Cost:', result.cost, 'USD');
}
Explanation of Code:
- JSON.parse: Turns the answer, a JSON string that follows your schema, into an object.
- forEach: Prints each shot with its start time, end time and description.
- result.cost: The cost of the request, in USD.
Example Output
The model’s answer, read from choices[0].message.content, contains the shots detected in the video. You can expect it to be similar to this:
{
"shots": [
{"start_time": 0.0, "end_time": 1.76, "description": "A red-haired woman sits in a snowy, desolate landscape, looking up with a worried expression as snow falls."},
{"start_time": 1.76, "end_time": 2.13, "description": "An overhead shot shows the red-haired woman running across a snowy field."},
{"start_time": 2.13, "end_time": 3.2, "description": "A close-up of a large, muscular man's arm and torso as he runs towards the camera, his hand extended."},
...
]
}
Explanation of the Output Fields
- shots: An array of the shots detected in the video.
- start_time: The timestamp (in seconds) where a shot begins.
- end_time: The timestamp where that shot ends.
- description: A short description of the shot.
- start_time: The timestamp (in seconds) where a shot begins.
Each object in the shots array represents a segment of the video between two shot changes, ideal for scene detection, trimming, or further analysis.
This data can be used to split the video into scenes or to highlight changes for further processing. The timestamps are estimated by the model: check them on a few of your own videos before relying on them in production.
Managing Your Video Files
To analyze a video stored on your machine, upload it first with POST https://api.edenai.run/v3/upload, then send a file block with the returned file_id instead of the image_url block. Eden AI provides additional optional endpoints to manage these files:
1. List Files (GET Request)
GET Request:
https://api.edenai.run/v3/upload
This lists the files you uploaded, with their file_id and expiration date.
2. Delete Files (POST Request)
POST Request:
https://api.edenai.run/v3/upload/delete
Send the list of file_ids you no longer need in the file_ids field to delete them.
Why EdenAI is the Best Tool for Shot Change Detection
EdenAI provides a robust, easy-to-use API that integrates multiple AI providers for background removal, shot detection, and other video analysis tasks.
The unified platform allows you to choose the best provider for your needs while offering a seamless interface.

Multiple Providers
You can use different AI models (like Google) based on your requirements.
Easy Integration
The API is simple to integrate with your application using standard HTTP requests.
Scalability
EdenAI’s infrastructure supports both small and large-scale requests, making it suitable for various use cases.
Reliable Results
EdenAI consistently delivers accurate and timely results, backed by leading AI technology.
Conclusion
In this article, we’ve shown how to implement shot change detection using the EdenAI API in JavaScript.
This process is highly scalable and can be integrated into web applications, content management systems, or any platform requiring video analysis.
By leveraging EdenAI's APIs, you can quickly integrate advanced video analysis features, such as shot change detection, into your applications.
Whether you're working on video editing, content analysis, or media management, EdenAI offers a powerful and accessible solution to enhance your workflow.
.jpeg)
.jpg)
