-
Notifications
You must be signed in to change notification settings - Fork 41
Review chienyuanchang/add_chapter_notebook-notebooks/video_chapters_creation.ipynb
#105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chienyuanchang
merged 1 commit into
chienyuanchang/add_chapter_notebook
from
review-chienyuanchang/add_chapter_notebook-notebooks-video_chapters_creation.ipynb-1758580005
Sep 22, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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." | ||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -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", | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "> ⚠️ 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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -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", | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "AZURE_AI_API_VERSION = os.getenv(\"AZURE_AI_API_VERSION\", \"2025-05-01-preview\")\n", | ||
| "\n", | ||
|
|
@@ -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." | ||
| ] | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }, | ||
| { | ||
|
|
@@ -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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -152,7 +151,7 @@ | |
| "id": "0c75e230", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Create and Run Marketing Video Analyzer" | ||
| "### Create and Run Video Chapter Analyzer" | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -242,7 +241,7 @@ | |
| "id": "ee269be2", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Create and Run Marketing Video Analyzer" | ||
| "### Create and Run Video Chapter Analyzer" | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -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", | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "print(\"Video Content Understanding result: \")\n", | ||
| "print(json.dumps(result, indent=2))" | ||
|
|
@@ -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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
|
|
@@ -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", | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "display(HTML(full_html))" | ||
| ] | ||
|
|
@@ -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." | ||
| ] | ||
chienyuanchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| ], | ||
|
|
@@ -324,4 +323,4 @@ | |
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
| } | ||
chienyuanchang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.