Automates the process of transcribing video files uploaded to a Google Drive folder using Google Cloud Platform (GCP), with optional AI-powered analysis.
- Automatic detection of new video files in Google Drive (including subfolders)
- Video transcription using Google Cloud Video Intelligence API
- AI Analysis using Vertex AI (Gemini 2.5 Flash) with customizable prompts
- Web Dashboard for viewing transcripts and configuring AI prompts
- Human-readable email notifications with timestamps, transcript, and AI analysis
- Idempotency - no duplicate emails on retries
- Auto-cleanup - source videos are deleted after transcription
- Duration limit - videos over 5 hours are automatically skipped
- Secure access - transcripts are accessible only to authorized users
The system is built on GCP using Cloud Functions (2nd Gen), Cloud Storage, Cloud Scheduler, Video Intelligence API, and Vertex AI.
graph TD
User[User] -->|Upload Video| Drive[Google Drive Folder + Subfolders]
Scheduler[Cloud Scheduler] -->|Trigger 2min| Poller[Function: Drive Poller]
Poller -->|Check New Files| Drive
Poller -->|Download Video| BucketIn["Bucket: audio-input"]
Poller -->|Save State| BucketState["Bucket: audio-input (state.json)"]
BucketIn -->|Event: New Object| Transcriber["Function: Transcriber"]
Transcriber -->|Email: Started| Gmail
Transcriber -->|Call API| VideoAPI["Video Intelligence API"]
VideoAPI -->|Output JSON| BucketOut["Bucket: transcripts"]
BucketOut -->|Event: New Object| Notifier["Function: Notifier"]
Notifier -->|Load Prompt| PromptConfig["GCS: _config/prompt.txt"]
Notifier -->|AI Analysis| VertexAI["Vertex AI (Gemini)"]
Notifier -->|Email: Transcript + Analysis| Gmail
Notifier -->|Delete Source| BucketIn
Dashboard["Function: Dashboard"] -->|View Transcripts| BucketOut
Dashboard -->|Configure Prompt| PromptConfig
- GCP Project with Billing Enabled.
- Google Drive Folder (created and ID copied).
- Gmail App Password (for sending notifications).
Create infra/terraform.tfvars:
project_id = "your-project-id"
region = "us-central1"
drive_folder_id = "your-drive-folder-id"
# Email Notifications
notification_email = "[email protected]" # Who gets the email?
gmail_user = "[email protected]" # Who sends it?
gmail_app_password = "your-16-char-app-password" # Gmail App Password
send_start_email = true # Send "Transcription Started" email?
# Dashboard
dashboard_password = "your-dashboard-password" # Password for dashboard accessRun the deployment script (wrapper around Terraform):
./deploy.shOr deploy directly with Terraform:
cd infra && terraform init && terraform applyAt the end of deployment, you will see outputs:
dashboard_url = "https://dashboard-xxx-uc.a.run.app"
service_account_email = "[email protected]"
You MUST share your Google Drive Folder with the service account email (Editor role).
The dashboard provides a web interface to:
- View all transcripts with links to transcript and analysis files
- Configure the AI prompt used for analysis
- Monitor processing status
URL with password (recommended for bookmarking):
https://dashboard-xxx-uc.a.run.app?p=your-password
Or use Basic Authentication:
- Username: anything
- Password: your configured
dashboard_password
- Open the dashboard
- Enter your analysis prompt in the "AI Analysis Prompt" textarea
- Click "Save Prompt"
- All future transcriptions will use this prompt
Example prompts:
- "Summarize this video transcript. List the main topics and any action items."
- "Extract key insights and quotes from this meeting transcript."
- "Identify the speakers and summarize what each person discussed."
- Trigger: Runs every 2 minutes (Cloud Scheduler).
- Logic:
- Reads
drive-poller-state.jsonfrom the Input Bucket to know the last check time. - Recursively scans the target folder and all subfolders for new video files.
- Filters for video files only (
.mp4,.mov,.avi,.mkv,.webm,.m4v,.wmv,.flv). - Skips videos longer than 5 hours (based on Drive metadata).
- Downloads new files and streams them to the Input Bucket.
- Updates
drive-poller-state.json.
- Reads
- Trigger: Eventarc (New file in Input Bucket).
- Logic:
- Skips non-video files (e.g., state.json).
- Idempotency check - skips if file was already processed (via GCS metadata).
- Calls Google Cloud Video Intelligence API (
annotateVideo). - Marks file as processed in GCS metadata.
- Sends "Transcription Started" email (configurable via
send_start_email). - Note: This is an async long-running operation. The function starts the job and exits.
- Trigger: Eventarc (New JSON file in Transcripts Bucket).
- Logic:
- Idempotency check - skips if notification was already sent.
- Reads and parses the Video Intelligence JSON output.
- Formats transcript with timestamps in human-readable format.
- AI Analysis (if prompt configured):
- First checks GCS for prompt (
_config/prompt.txt- set via dashboard) - Falls back to Google Drive (
_prompts/PROMPT.mdin watched folder) - Sends transcript to Vertex AI (Gemini 2.5 Flash) with prompt
- First checks GCS for prompt (
- Saves transcript and analysis to GCS.
- Sends email with formatted transcript and AI analysis as attachments.
- Marks transcript as notified in GCS metadata.
- Deletes the source video from the input bucket (cleanup).
- Trigger: HTTP requests.
- Logic:
- Authenticates via URL parameter (
?p=password) or Basic Auth. - Lists all transcript files from the Transcripts Bucket.
- Displays prompt configuration editor.
- Handles prompt save requests (stores to
_config/prompt.txtin GCS).
- Authenticates via URL parameter (
Subject: [Drive Automation] Transcription Started
Processing file: video.mp4
We'll notify you when it's done.
Subject: [Drive Automation] Analysis & Transcript: video.mp4
Your video "video.mp4" has been processed!
Video Duration: 5 min 32 sec
The transcript and AI analysis are attached to this email.
═══════════════════════════════════════════════════════
AI ANALYSIS
═══════════════════════════════════════════════════════
[Your AI analysis based on the configured prompt...]
═══════════════════════════════════════════════════════
LINKS
═══════════════════════════════════════════════════════
Raw JSON: https://storage.cloud.google.com/bucket/video.mp4.json
To view the full transcript or analysis, open the attached files.
Attachments:
video.mp4_TRANSCRIPT.txt- Full transcript with timestampsvideo.mp4_ANALYSIS.txt- AI analysis (if prompt configured)
If something isn't working, follow this trail:
Check the Poller.
gcloud functions logs read drive-poller --project=YOUR_PROJECT --region=us-central1 --limit=50Look for:
Monitoring X folders (including subfolders)-> Confirms subfolder scanning is working.Found X new files.-> If 0, check your Drive Folder ID and if the Service Account has access.Skipping file "X" - duration Xh exceeds 5h limit-> Video was too long.
Force a Rescan:
gcloud storage rm gs://YOUR_INPUT_BUCKET/drive-poller-state.json
gcloud scheduler jobs run trigger-drive-poller --location=us-central1Check the Transcriber.
gcloud functions logs read transcriber --project=YOUR_PROJECT --region=us-central1 --limit=50Look for:
Skipping non-video file: ...-> File was filtered out (expected for state.json).Skipping already-processed file: ...-> Idempotency kicked in (expected on retries).Starting Video Intelligence job for ...-> Job started successfully.- Errors: Quota exceeded? Invalid API key?
Check the Video Intelligence Operation.
- Video processing takes time (roughly 50-100% of video duration).
- Check the Transcripts Bucket:
gs://YOUR_TRANSCRIPTS_BUCKET/ - If the JSON file appears there, the API worked.
Check the Notifier.
gcloud functions logs read notifier --project=YOUR_PROJECT --region=us-central1 --limit=50Look for:
Found prompt in GCS config-> Dashboard prompt is being used.Found prompt template. Running AI analysis...-> AI analysis started.AI Analysis complete.-> AI analysis succeeded.NOTIFICATION for ...-> Email was sent.Cleaned up source file: ...-> Source video was deleted.- Errors:
Invalid login(Wrong App Password?), AI errors (check Vertex AI quota).
Common issues:
GCP_PROJECT environment variable not set-> Check Terraform deployment.response.text is not a function-> SDK version mismatch (should be fixed).Quota exceeded-> Check Vertex AI quotas in GCP Console.
| Limit | Value | Reason |
|---|---|---|
| Max video duration | 5 hours | Video Intelligence API processing time/cost |
| Polling frequency | 2 minutes | Cloud Scheduler interval |
| Supported formats | .mp4, .mov, .avi, .mkv, .webm, .m4v, .wmv, .flv |
Common video formats |
| AI Model | Gemini 2.5 Flash | Vertex AI model for analysis |
- Video Intelligence API: First 1000 minutes/month are Free. Then ~$0.048/min.
- Vertex AI (Gemini): Pay-per-token pricing (very low for text analysis).
- Cloud Functions: First 2 million invocations/month are Free.
- Cloud Storage: Standard rates (pennies for text/video).
To update code (e.g., change email text):
- Edit the code in
src/... - Run
terraform applyin theinfra/directory - Terraform detects the change and redeploys only the updated function.
To remove all resources:
cd infra && terraform destroy