Feature: Auto-detect video chapters from metadata/transcription (#493)#494
Merged
filthyrake merged 2 commits intodevfrom Jan 3, 2026
Merged
Feature: Auto-detect video chapters from metadata/transcription (#493)#494filthyrake merged 2 commits intodevfrom
filthyrake merged 2 commits intodevfrom
Conversation
Add ability to automatically detect and generate chapter markers from
video metadata or transcription analysis.
## New Features
### API Endpoint
- POST /admin/videos/{video_id}/chapters/auto-detect
- source: 'metadata', 'transcription', or 'both'
- min_chapter_length: minimum seconds between chapters (10-600)
- replace_existing: whether to clear existing chapters
### Metadata Chapter Extraction
- Extract chapter markers embedded in video files via ffprobe
- Supports Matroska (MKV), MP4/MOV, and other container formats
- Graceful fallback when no chapters found
### Transcription-Based Generation
- Generate chapters from completed transcription text
- Sentence-based analysis for topic segmentation
- Configurable minimum chapter length
- Removes filler words from generated titles
## Implementation
- New module: api/chapter_detection.py with utility functions
- New schemas: ChapterDetectionSource, AutoDetectChaptersRequest,
AutoDetectChaptersResponse, DetectedChapter
- Comprehensive test coverage for all detection methods
Closes #493
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Security & reliability improvements: - Add HTML entity escaping for metadata-extracted titles (XSS prevention) - Add transaction retry logic with execute_with_retry() - Add SELECT FOR UPDATE for concurrency protection - Add endpoint-level 60s timeout for detection phase - Add timeout on process.wait() after kill signal Performance improvements: - Convert N+1 inserts to single batch INSERT RETURNING query - Pre-compile regex patterns at module level - Add named constants for magic numbers Code quality fixes: - Replace print() with logger.error() for proper logging - Remove unused video_slug parameter from function signature - Rename internal dataclass to avoid collision with Pydantic schema - Update tests for renamed class and removed parameter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Changes
POST /admin/videos/{video_id}/chapters/auto-detectapi/chapter_detection.pywith ffprobe and transcription utilitiesChapterDetectionSource,AutoDetectChaptersRequest,AutoDetectChaptersResponseFeatures
1. Import from Video Metadata
ffprobe -show_chapters2. Generate from Transcription
API Usage
Test plan
Closes #493
🤖 Generated with Claude Code