Login

Generate video chapters

Imagine a viewer watching a long tutorial video on cooking. They want to jump directly to the section on how to prepare a specific dish, but without chapters, they’re left scrubbing through the timeline. This is where video chapters come into play. By creating chapters, you can significantly improve navigation, making it easier for viewers to access the information they need.


Getting started

To start using the Chapters feature, you can use FastPix’s create media from URL or upload media from device API endpoints. These endpoints analyze video or audio files and generate chapters automatically when uploading new media.

If you want to enable video chapter generation in your existing content that was previously uploaded, use the  generate video chapters  API endpoint. See how.


Generating chapters for new media

Step 1: Collect the URLs of the media files to upload to FastPix (using pull via URL method) for which you want to generate chapters.

Step 2: Create a JSON request and send a POST request to the /on-demand endpoint.


In the JSON configuration for the FastPix API request, the following parameters are required:

  • type: Specify whether the file is a video or audio file.
  • url: Provide the HTTPS URL of the file for chapter generation.
  • chapters: Set this to true to enable the generation of chapters.
  • accessPolicy: (Optional) Set to public or private based on your needs.
  • maxResolution: (Optional) Specify a resolution limit, e.g., 1080p.

Request body for creating new media from URL

{   
  "inputs": [   
    {   
      "type": "video",   
      "url": "https://static.fastpix.io/sample.mp4"   
    }   
  ],   
  "chapters": true,   
  "accessPolicy": "public",   
  "maxResolution": "1080p"   
}

Request body for creating new media by direct upload

If you are uploading media directly, the inputs section will contain the relevant upload details, and the structure would look like this:

{  
  "corsOrigin": "*",  
  "pushMediaSettings": {  
    "metadata": {  
      "key1": "value1"  
    },  
    "chapters": true,  
    "accessPolicy": "public",  
    "maxResolution": "1080p"  
  }  
}

Generating chapters for existing media

If you wish to generate chapters for media that has already been uploaded, use the generate video chapters API endpoint and follow these steps:


Step 1: Collect the mediaId of the content for which you want chapters.

Step 2: Create a JSON request and send a PATCH request to the /on-demand/<mediaId>/chapters endpoint. Replace <mediaId> with the actual mediaId of the already existing media.


Example request body

{   
  "chapters": true   
}

Accessing chapter results

To retrieve the generated chapters of your media (video/audio), you can find the data in the video.mediaAI.chapters.ready event.


Example of the event data:

{
  "type": "video.mediaAI.chapters.ready",
  "object": {
    "type": "mediaAI",
    "id": "69f82b00-151c-45d4-942c-6eab719143b2"
  },
  "id": "449ffaa5-ba84-452a-b368-53da62d4641e",
  "workspace": {
    "id": "fd717af6-a383-4739-8d8c-b49aa732a8c0"
  },
  "data": {
    "isChaptersGenerated": true,
    "chapters": [
      {
        "chapterNumber": 1,
        "title": "Introduction to Blockchain",
        "startTime": "00:00:00",
        "endTime": "00:02:30",
        "description": "Introduction to transactional problems and blockchain."
      },
      {
        "chapterNumber": 2,
        "title": "How Bitcoin Transactions Work",
        "startTime": "00:02:31",
        "endTime": "00:05:30",
        "description": "Explanation of bitcoin transactions and the mining process."
      },
      {
        "chapterNumber": 3,
        "title": "Real-Life Applications of Blockchain",
        "startTime": "00:05:31",
        "endTime": "00:07:00",
        "description": "Walmart's adoption of blockchain for quality control."
      }
    ]
  }
}

In this event, the chapters field contains the list of generated chapters for the media. You can access the individual chapters, including:

  • chapterNumber: The sequence of the chapter within the content.
  • title: A brief, descriptive title of the chapter.
  • startTime: Start time of the chapter in hh:mm:ss format.
  • endTime: End time of the chapter in hh:mm:ss format.
  • description: A short summary or key takeaway of the chapter.

You can use these fields to present chapters in a media player or other applications.


General considerations

  • Ensure that the mediaId is correctly obtained for existing media when using the /on-demand/<mediaId>/chapters endpoint.\
  • The accessPolicy and maxResolution parameters are optional, but they help manage access and media quality depending on your needs.\
  • Generated chapters are automatically time-stamped, ensuring precise navigation for viewers.