askrobots / dbbasic-video
Public
Video analysis: download, keyframes, transcripts, thumbnail grids and AI summaries of what's on screen.
quick_start.py · 1.2 KB · 43 lines
| 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | Quick start example for dbbasic-video |
| 4 | |
| 5 | This example shows how to: |
| 6 | 1. Download a YouTube video |
| 7 | 2. Extract keyframes |
| 8 | 3. Create a thumbnail grid |
| 9 | 4. Get the transcript |
| 10 | 5. Analyze with AI |
| 11 | """ |
| 12 | |
| 13 | from dbbasic_video.download_video import download_video |
| 14 | from dbbasic_video.extract_keyframes import extract_keyframes |
| 15 | from dbbasic_video.make_grid import create_thumbnail_sheet |
| 16 | from dbbasic_video.get_transcript import download_transcript |
| 17 | from dbbasic_video.analyze_visuals import analyze_grid |
| 18 | |
| 19 | # Configuration |
| 20 | YOUTUBE_URL = "https://www.youtube.com/watch?v=VIDEO_ID" |
| 21 | VIDEO_ID = "VIDEO_ID" |
| 22 | |
| 23 | # Step 1: Download video |
| 24 | print("Downloading video...") |
| 25 | video_file = download_video(YOUTUBE_URL, "my_video.mp4") |
| 26 | |
| 27 | # Step 2: Extract keyframes |
| 28 | print("\nExtracting keyframes...") |
| 29 | extract_keyframes(video_file, "keyframes/") |
| 30 | |
| 31 | # Step 3: Create thumbnail grid |
| 32 | print("\nCreating thumbnail grid...") |
| 33 | create_thumbnail_sheet("keyframes/", "thumbnail_grid.jpg") |
| 34 | |
| 35 | # Step 4: Download transcript |
| 36 | print("\nDownloading transcript...") |
| 37 | download_transcript(VIDEO_ID, "transcript.json") |
| 38 | |
| 39 | # Step 5: Analyze visuals (requires OPENAI_API_KEY in .env) |
| 40 | print("\nAnalyzing visuals with AI...") |
| 41 | analyze_grid("thumbnail_grid.jpg", "analysis.txt") |
| 42 | |
| 43 | print("\n✓ Done! Check the output files.") |