Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions notebooks/video_chapters_creation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"id": "0a44bdf4",
"metadata": {},
"source": [
"\n",
"## Pre-requisites\n",
"1. Follow [README](../README.md#configure-azure-ai-service-resource) to create essential resource that will be used in this sample.\n",
"1. Install required packages"
"1. Please follow the [README](../README.md#configure-azure-ai-service-resource) to create the essential resource needed for this sample.\n",
"2. Install the required packages."
]
},
{
Expand All @@ -38,14 +37,14 @@
"source": [
"## Create Azure AI Content Understanding Client\n",
"\n",
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class providing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, it acts as a lightweight SDK. Please fill in the constants **AZURE_AI_ENDPOINT** and **AZURE_AI_API_VERSION** with your Azure AI Service information. Optionally, you may provide **AZURE_AI_API_KEY** if your setup requires key-based authentication.\n",
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class providing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, this acts as a lightweight SDK. Please fill in the constants **AZURE_AI_ENDPOINT** and **AZURE_AI_API_VERSION** with your Azure AI Service information. Optionally, you may provide **AZURE_AI_API_KEY** if your setup requires key-based authentication.\n",
"\n",
"> ⚠️ Important:\n",
"Please update the code below to match your Azure authentication method.\n",
"Look for the `# IMPORTANT` comments and modify those sections accordingly.\n",
"Look for the `# IMPORTANT` comments and kindly modify those sections accordingly.\n",
"Skipping this step may cause the sample to not run correctly.\n",
"\n",
"> ⚠️ Note: Using a subscription key works, but using a token provider with Azure Active Directory (AAD) is safer and highly recommended for production environments."
"> ⚠️ Note: While using a subscription key works, using a token provider with Azure Active Directory (AAD) is safer and highly recommended for production environments."
]
},
{
Expand All @@ -69,7 +68,7 @@
"\n",
"# For authentication, you can use either token-based authentication or a subscription key; only one method is required.\n",
"AZURE_AI_ENDPOINT = os.getenv(\"AZURE_AI_ENDPOINT\")\n",
"# IMPORTANT: Replace with your actual subscription key or set it in the \".env\" file if not using token authentication.\n",
"# IMPORTANT: Please replace with your actual subscription key or set it in the \".env\" file if not using token authentication.\n",
"AZURE_AI_API_KEY = os.getenv(\"AZURE_AI_API_KEY\")\n",
"AZURE_AI_API_VERSION = os.getenv(\"AZURE_AI_API_VERSION\", \"2025-05-01-preview\")\n",
"\n",
Expand Down Expand Up @@ -99,7 +98,7 @@
"source": [
"## File to Analyze\n",
"\n",
"Use the following variable to define what file to analyze. For this example, we will be examining a small tutorial. If you would like to try with your own videos, you could use a small video to get results faster."
"Use the following variable to define the file to analyze. For this example, we will be examining a small tutorial video. If you would like to try with your own videos, please use a small video to get faster results."
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • categories: [Grammar, Clarity]
    • change: Modified the sentence to "Use the following variable to define the file to analyze. For this example, we will be examining a small tutorial video. If you would like to try with your own videos, please use a small video to get faster results."
    • rationale: The changes improve sentence structure by removing unnecessary words ("what"), specifying "tutorial video" for clarity, and making the recommendation more direct and polite ("please use a small video").
    • impact: This refinement enhances readability and ensures the instructions are clearer and easier for users to follow.

},
{
Expand All @@ -119,11 +118,11 @@
"source": [
"# 1. Automated Chapter Discovery\n",
"\n",
"We will first use Content Understanding and let service interact with an LLM model to apply its own reasoning to segment the video into meaningful chapters, providing concise descriptions and timestamps.\n",
"We will first use Content Understanding and allow the service to interact with an LLM model, enabling it to apply its own reasoning to segment the video into meaningful chapters. It will provide concise descriptions with timestamps.\n",
"\n",
"The custom analyzer schema template for this approach is [video_chapters_dynamic.json](../analyzer_templates/video_chapters_dynamic.json). This file defines the schema and configuration for a custom video analyzer that uses AI to dynamically generate chapters and scenes based on its understanding of the video content. The service analyzes the video and determines the most meaningful chapter divisions, providing start and end timestamps for each. The configuration section allows flexible segmentation, enabling the model to reason about the content and organize chapters in a way that best fits.\n",
"The custom analyzer schema template for this approach is [video_chapters_dynamic.json](../analyzer_templates/video_chapters_dynamic.json). This file defines the schema and configuration for a custom video analyzer that uses AI to dynamically generate chapters and scenes based on its understanding of the video content. The service analyzes the video and identifies the most meaningful chapter divisions, providing start and end timestamps for each. The configuration section allows flexible segmentation, enabling the model to reason about the content and organize chapters appropriately.\n",
"\n",
"In this example, we will use the utility class `AzureContentUnderstandingClient` to load the analyzer schema from the template file and submit it to Azure Content Understanding service. Then, we will analyze the video and generate the desired chapter and scene structure."
"In this example, we will use the utility class `AzureContentUnderstandingClient` to load the analyzer schema from the template file and submit it to the Azure Content Understanding service. Then, we will analyze the video and generate the desired chapter and scene structure."
]
},
{
Expand Down Expand Up @@ -152,7 +151,7 @@
"id": "0c75e230",
"metadata": {},
"source": [
"### Create and Run Marketing Video Analyzer"
"### Create and Run Video Chapter Analyzer"
]
},
{
Expand Down Expand Up @@ -184,7 +183,7 @@
"metadata": {},
"source": [
"### Extract Video Content from Analyzed Result\n",
"Use the following utility to display results for visual review."
"Use the following utility to display results for your visual review."
]
},
{
Expand Down Expand Up @@ -213,7 +212,7 @@
"\n",
"The custom analyzer schema template for this approach is [video_chapters_structured.json](../analyzer_templates/video_chapters_structured.json). This file defines the schema and configuration for a custom video analyzer. In this example, it specifies how a video should be segmented into chapters and scenes, including three chapter types: **\"Topic Introduction\"**, **\"Details About the Work Done\"**, and **\"Conclusion or Results\"**. Each segment contains a list of scenes, with each scene described by a short description, start timestamp, and end timestamp. The configuration section controls segmentation behavior and other analysis options, while the fieldSchema section outlines the expected structure of the output, ensuring chapters and scenes are clearly organized and non-overlapping.\n",
"\n",
"We we will also be using the utility class `AzureContentUnderstandingClient` to load the analyzer schema from the template file and submit it to Azure Content Understanding service. Then, we will analyze the video and generate the desired chapter and scene structure."
"We will also be using the utility class `AzureContentUnderstandingClient` to load the analyzer schema from the template file and submit it to the Azure Content Understanding service. Then, we will analyze the video and generate the desired chapter and scene structure."
]
},
{
Expand Down Expand Up @@ -242,7 +241,7 @@
"id": "ee269be2",
"metadata": {},
"source": [
"### Create and Run Marketing Video Analyzer"
"### Create and Run Video Chapter Analyzer"
]
},
{
Expand All @@ -262,7 +261,7 @@
"print(f\"Analyzing chapter video: {VIDEO_FILE_PATH}\")\n",
"print(\"⏳ Note: Video analysis may take significantly longer than document analysis...\")\n",
"response = client.begin_analyze(video_analyzer_id, file_location=VIDEO_FILE_PATH)\n",
"result_json = client.poll_result(response, timeout_seconds=360) # Video analysis may take longer, please adjust timeout as needed\n",
"result_json = client.poll_result(response, timeout_seconds=360) # Video analysis may take longer, please adjust the timeout as needed\n",
"\n",
"print(\"Video Content Understanding result: \")\n",
"print(json.dumps(result, indent=2))"
Expand All @@ -274,7 +273,7 @@
"metadata": {},
"source": [
"### Extract Video Content from Analyzed Result\n",
"Use the following utility to display results for visual review."
"Use the following utility to display results for your visual review."
]
},
{
Expand All @@ -287,7 +286,7 @@
"from IPython.display import display, HTML\n",
"from python.chapters_utility import ChaptersFormatter\n",
"\n",
"# For structured chaptering, use default (dynamic=False)\n",
"# For structured chaptering, use the default (dynamic=False)\n",
"full_html = ChaptersFormatter.format_chapters_output(VIDEO_FILE_PATH, result_json)\n",
"display(HTML(full_html))"
]
Expand All @@ -299,7 +298,7 @@
"source": [
"# Conclusion\n",
"\n",
"This notebook has demonstrated how **Azure Content Understanding** can automatically generate meaningful chapters and scenes from video content. By leveraging AI-driven analysis, you can quickly create structured, searchable tables of contents for any video, making it easier to navigate and understand complex material. This approach streamlines video processing and enables new possibilities for content organization and discovery."
"This notebook has demonstrated how **Azure Content Understanding** can automatically generate meaningful chapters and scenes from video content. By leveraging AI-driven analysis, you can quickly create structured, searchable tables of contents for any video, making it easier to navigate and understand complex material. This approach streamlines video processing and enables exciting new possibilities for content organization and discovery."
]
}
],
Expand All @@ -324,4 +323,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}