fix: Face processor now saves status and total_faces to face.json
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
---
|
||||
title: File Status API - Timestamp Fields
|
||||
version: 1.0
|
||||
date: 2026-09-22
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
# File Status API - Timestamp Fields
|
||||
|
||||
## Overview
|
||||
|
||||
Added timestamp fields to file status API for better tracking and comparison.
|
||||
|
||||
## API Endpoint
|
||||
|
||||
```
|
||||
GET /api/v1/stats/file/{file_uuid}?api_key={api_key}
|
||||
```
|
||||
|
||||
## New Fields
|
||||
|
||||
### Response Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "44c37c078d6562d226003d9a44c72eca",
|
||||
"file_name": "Charade_YouTube_24fps.mp4",
|
||||
"status": "completed",
|
||||
"created_at": "2026-05-28T10:30:00Z",
|
||||
"updated_at": "2026-05-28T12:45:30Z",
|
||||
"processing_completed_at": "2026-05-28T12:45:30Z",
|
||||
"processors": [...],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Field Descriptions
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `created_at` | ISO 8601 string | File registration time |
|
||||
| `updated_at` | ISO 8601 string | Last status update time |
|
||||
| `processing_completed_at` | ISO 8601 string | Processing completion time (only when status="completed") |
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Display Completion Time
|
||||
|
||||
```typescript
|
||||
interface FileStatus {
|
||||
file_uuid: string;
|
||||
file_name: string;
|
||||
status: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
processing_completed_at?: string;
|
||||
}
|
||||
|
||||
function StatusDisplay({ status }: { status: FileStatus }) {
|
||||
return (
|
||||
<div>
|
||||
<span>Status: {status.status}</span>
|
||||
{status.processing_completed_at && (
|
||||
<span className="timestamp">
|
||||
Completed: {formatDate(status.processing_completed_at)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function formatDate(isoString: string): string {
|
||||
const date = new Date(isoString);
|
||||
return date.toLocaleString('zh-TW', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Compare Processing Time
|
||||
|
||||
```typescript
|
||||
function getProcessingDuration(status: FileStatus): number | null {
|
||||
if (!status.created_at || !status.processing_completed_at) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const start = new Date(status.created_at).getTime();
|
||||
const end = new Date(status.processing_completed_at).getTime();
|
||||
|
||||
return (end - start) / 1000; // seconds
|
||||
}
|
||||
|
||||
// Usage
|
||||
const duration = getProcessingDuration(fileStatus);
|
||||
if (duration) {
|
||||
console.log(`Processing took ${duration} seconds`);
|
||||
}
|
||||
```
|
||||
|
||||
### Detect Stale Files
|
||||
|
||||
```typescript
|
||||
function isStatusStale(status: FileStatus, maxAgeHours: number): boolean {
|
||||
if (!status.updated_at) return true;
|
||||
|
||||
const lastUpdate = new Date(status.updated_at).getTime();
|
||||
const now = Date.now();
|
||||
const ageHours = (now - lastUpdate) / (1000 * 60 * 60);
|
||||
|
||||
return ageHours > maxAgeHours;
|
||||
}
|
||||
|
||||
// Check if status hasn't been updated in 24 hours
|
||||
if (isStatusStale(fileStatus, 24)) {
|
||||
console.warn('File status is stale, may need refresh');
|
||||
}
|
||||
```
|
||||
|
||||
## Time Format
|
||||
|
||||
All timestamps use **ISO 8601** format:
|
||||
- Format: `YYYY-MM-DDTHH:MM:SSZ`
|
||||
- Timezone: UTC (indicated by `Z` suffix)
|
||||
- Example: `2026-09-22T15:30:45Z`
|
||||
|
||||
## Studio Integration
|
||||
|
||||
### Recommended Display
|
||||
|
||||
**Status Line with Timestamp**:
|
||||
```typescript
|
||||
<div className="file-status">
|
||||
<Badge status={status.status} />
|
||||
{status.processing_completed_at && (
|
||||
<span className="completion-time">
|
||||
✓ {formatRelativeTime(status.processing_completed_at)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
```
|
||||
|
||||
**Format Relative Time**:
|
||||
```typescript
|
||||
function formatRelativeTime(isoString: string): string {
|
||||
const date = new Date(isoString);
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - date.getTime();
|
||||
const diffMins = Math.floor(diffMs / 60000);
|
||||
const diffHours = Math.floor(diffMs / 3600000);
|
||||
const diffDays = Math.floor(diffMs / 86400000);
|
||||
|
||||
if (diffMins < 60) return `${diffMins} minutes ago`;
|
||||
if (diffHours < 24) return `${diffHours} hours ago`;
|
||||
if (diffDays < 7) return `${diffDays} days ago`;
|
||||
|
||||
return date.toLocaleDateString();
|
||||
}
|
||||
```
|
||||
|
||||
## Status Change Tracking
|
||||
|
||||
### When Timestamps Update
|
||||
|
||||
| Event | `created_at` | `updated_at` | `processing_completed_at` |
|
||||
|-------|-------------|--------------|---------------------------|
|
||||
| File registration | ✅ Set | ✅ Set | ❌ null |
|
||||
| Status → processing | ❌ No change | ✅ Update | ❌ null |
|
||||
| Status → completed | ❌ No change | ✅ Update | ✅ Set |
|
||||
| Status → failed | ❌ No change | ✅ Update | ❌ null |
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Backend Changes
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/scan.rs`
|
||||
- Added `created_at`, `updated_at`, `processing_completed_at` fields
|
||||
- Query from `videos` table
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/core/db/postgres_db.rs`
|
||||
- `update_video_status()` now updates `updated_at` automatically
|
||||
|
||||
### Database Schema
|
||||
|
||||
```sql
|
||||
-- videos table already has these columns
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
# Get file status with timestamps
|
||||
curl -s "http://localhost:3002/api/v1/stats/file/{uuid}?api_key={key}" \
|
||||
| python3 -m json.tool | grep -E "created_at|updated_at|processing_completed"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- All times are in UTC
|
||||
- `processing_completed_at` is only set when status="completed"
|
||||
- Timestamps may be `null` for files registered before this feature
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-09-22 | Initial implementation |
|
||||
|
||||
---
|
||||
|
||||
**For Studio Team**: Use these timestamps to show processing duration and completion time in the UI.
|
||||
@@ -0,0 +1,240 @@
|
||||
---
|
||||
title: Scene VLM API Integration
|
||||
version: 1.0
|
||||
date: 2026-09-22
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
# Scene VLM API Integration for Momentry Studio
|
||||
|
||||
## Overview
|
||||
|
||||
Scene VLM (Visual Language Model) provides scene descriptions for video moment chunks. This document describes how Studio can integrate with the Scene VLM status API.
|
||||
|
||||
## API Endpoint
|
||||
|
||||
### Get File Stats with Scene VLM Status
|
||||
|
||||
```
|
||||
GET /api/v1/stats/file/{file_uuid}?api_key={api_key}
|
||||
```
|
||||
|
||||
**Response Structure:**
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d1e18fa4994aae32d9a63852a80c5a2a",
|
||||
"file_name": "dedicatoria.mp4",
|
||||
"status": "completed",
|
||||
"processors": [...],
|
||||
"scene_vlm": {
|
||||
"total_scenes": 11,
|
||||
"vlm_done": 11,
|
||||
"vlm_total": 11,
|
||||
"status": "ready"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Scene VLM Field Description
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total_scenes` | i64 | Total number of scene chunks extracted |
|
||||
| `vlm_done` | i64 | Number of scenes with completed VLM descriptions |
|
||||
| `vlm_total` | i64 | Total scenes (same as total_scenes) |
|
||||
| `status` | string | Overall status: "pending", "ready", "error" |
|
||||
|
||||
## Status Values
|
||||
|
||||
### `status` Field
|
||||
|
||||
- **pending**: Scene extraction in progress or VLM not started
|
||||
- **ready**: All scenes extracted and VLM descriptions completed
|
||||
- **error**: Scene VLM processing failed
|
||||
|
||||
### VLM Progress
|
||||
|
||||
- `vlm_done == vlm_total`: All scene descriptions completed
|
||||
- `vlm_done < vlm_total`: VLM processing in progress
|
||||
- `vlm_done == 0 && vlm_total > 0`: Scenes extracted, VLM pending
|
||||
|
||||
## Studio UI Integration
|
||||
|
||||
### Recommended Display
|
||||
|
||||
**When `status === "ready"` and `vlm_done === vlm_total`:**
|
||||
|
||||
```typescript
|
||||
// Scene VLM indicator
|
||||
<div className="scene-vlm-status">
|
||||
<Icon name="vlm" />
|
||||
<span>{scene_vlm.vlm_done}/{scene_vlm.vlm_total} scenes analyzed</span>
|
||||
<StatusBadge status="completed" />
|
||||
</div>
|
||||
```
|
||||
|
||||
**When VLM in progress:**
|
||||
|
||||
```typescript
|
||||
<div className="scene-vlm-progress">
|
||||
<ProgressBar
|
||||
current={scene_vlm.vlm_done}
|
||||
total={scene_vlm.vlm_total}
|
||||
/>
|
||||
<span>Analyzing scenes...</span>
|
||||
</div>
|
||||
```
|
||||
|
||||
### Example Usage (React/TypeScript)
|
||||
|
||||
```typescript
|
||||
interface SceneVlmStats {
|
||||
total_scenes: number;
|
||||
vlm_done: number;
|
||||
vlm_total: number;
|
||||
status: 'pending' | 'ready' | 'error';
|
||||
}
|
||||
|
||||
interface FileStatsResponse {
|
||||
file_uuid: string;
|
||||
file_name: string;
|
||||
status: string;
|
||||
scene_vlm: SceneVlmStats;
|
||||
// ... other fields
|
||||
}
|
||||
|
||||
async function getFileStats(fileUuid: string, apiKey: string): Promise<FileStatsResponse> {
|
||||
const response = await fetch(
|
||||
`/api/v1/stats/file/${fileUuid}?api_key=${apiKey}`
|
||||
);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Component
|
||||
function SceneVlmIndicator({ fileUuid, apiKey }: Props) {
|
||||
const [stats, setStats] = useState<FileStatsResponse | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchStats = async () => {
|
||||
const data = await getFileStats(fileUuid, apiKey);
|
||||
setStats(data);
|
||||
};
|
||||
|
||||
fetchStats();
|
||||
const interval = setInterval(fetchStats, 5000); // Poll every 5s during processing
|
||||
return () => clearInterval(interval);
|
||||
}, [fileUuid, apiKey]);
|
||||
|
||||
if (!stats) return <Loading />;
|
||||
|
||||
const { scene_vlm } = stats;
|
||||
|
||||
return (
|
||||
<div className="processor-status scene-vlm">
|
||||
<h4>Scene Analysis</h4>
|
||||
|
||||
{scene_vlm.status === 'ready' && (
|
||||
<div className="status-completed">
|
||||
✅ {scene_vlm.vlm_done}/{scene_vlm.vlm_total} scenes analyzed
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scene_vlm.status === 'pending' && scene_vlm.vlm_total > 0 && (
|
||||
<div className="status-progress">
|
||||
<ProgressBar value={scene_vlm.vlm_done} max={scene_vlm.vlm_total} />
|
||||
<span>{scene_vlm.vlm_done}/{scene_vlm.vlm_total} scenes</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scene_vlm.status === 'error' && (
|
||||
<div className="status-error">
|
||||
❌ Scene analysis failed
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Scene VLM Processing Flow
|
||||
|
||||
1. **Scene Extraction**: CUT processor extracts scene boundaries
|
||||
2. **Frame Sampling**: System samples representative frames (1 per 10s interval)
|
||||
3. **VLM Analysis**: Gemma4 12B multimodal describes each scene
|
||||
4. **Object/Tag Extraction**: Extract objects and tags from descriptions
|
||||
5. **Status Update**: `scene_vlm.vlm_done` increments as each scene completes
|
||||
|
||||
## Performance Characteristics
|
||||
|
||||
- **Processing Time**: ~3-4 seconds per scene
|
||||
- **Model**: Gemma4 12B Q4_K_M (multimodal)
|
||||
- **API Endpoint**: http://localhost:8080/v1/chat/completions
|
||||
- **GPU Acceleration**: Metal (Apple Silicon) or CUDA
|
||||
|
||||
## Related Processors
|
||||
|
||||
Scene VLM runs **after** CUT processor completes:
|
||||
|
||||
```
|
||||
CUT → Scene Extraction → Scene VLM → scenes.json
|
||||
```
|
||||
|
||||
## Output File
|
||||
|
||||
**Location**: `{OUTPUT_DIR}/{file_uuid}.scenes.json`
|
||||
|
||||
**Structure**:
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d1e18fa4994aae32d9a63852a80c5a2a",
|
||||
"total_scenes": 11,
|
||||
"status": "ready",
|
||||
"scenes": [
|
||||
{
|
||||
"index": 0,
|
||||
"filename": "scene_000.jpg",
|
||||
"timestamp_sec": 1.5,
|
||||
"frame_number": 45,
|
||||
"vlm_status": "completed",
|
||||
"vlm_description": "A serene landscape with...",
|
||||
"vlm_objects": ["river", "tree", "forest"],
|
||||
"vlm_tags": ["nature"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
**Common Issues:**
|
||||
|
||||
1. **VLM service not running**: Check port 8080
|
||||
2. **Scene extraction failed**: Check CUT processor status
|
||||
3. **Empty descriptions**: VLM may be overloaded
|
||||
|
||||
**Debugging:**
|
||||
|
||||
```bash
|
||||
# Check VLM service
|
||||
curl http://localhost:8080/health
|
||||
|
||||
# Check scenes.json
|
||||
cat /Users/accusys/momentry/output/{file_uuid}.scenes.json | python3 -m json.tool
|
||||
|
||||
# Check worker logs
|
||||
tail -f /Users/accusys/momentry_core/logs/worker_3002.log | grep "Scene VLM"
|
||||
```
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-09-22 | Initial documentation for Studio integration |
|
||||
|
||||
## Contact
|
||||
|
||||
- **Core Team**: Responsible for Scene VLM implementation
|
||||
- **Issues**: Report to https://github.com/anomalyco/opencode/issues
|
||||
@@ -0,0 +1,365 @@
|
||||
---
|
||||
title: Scene VLM Frontend Integration Guide
|
||||
version: 1.1.0
|
||||
date: 2026-09-21
|
||||
author: Core Team
|
||||
status: active
|
||||
---
|
||||
|
||||
# Scene VLM Frontend Integration Guide
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| **Scope** | Frontend integration |
|
||||
| **Status** | Production ready |
|
||||
| **Applicable to** | Momentry Studio |
|
||||
| **Backend version** | v1.0.0+ |
|
||||
| **Requirement** | **Mandatory pipeline stage** |
|
||||
|
||||
## Overview
|
||||
|
||||
Scene VLM is a **mandatory pipeline stage** that automatically analyzes video scenes every 10 seconds, extracting key frames and generating scene descriptions using VLM. This replaces per-trace VLM calls with time-based sampling, achieving ~100x speed improvement.
|
||||
|
||||
**Key Differences from Trace VLM**:
|
||||
- **Scene VLM**: Environment/scene descriptions (every 10s interval) - **Mandatory**
|
||||
- **Trace VLM**: Person appearance descriptions (per detected trace) - Optional
|
||||
|
||||
Both can coexist. Scene VLM is for scene context, Trace VLM is for person details.
|
||||
|
||||
## Backend Integration
|
||||
|
||||
### Automatic Trigger (Mandatory)
|
||||
|
||||
Scene VLM is **automatically triggered** by the worker after CUT detection completes. It is a **required step** in the pipeline:
|
||||
|
||||
```
|
||||
Deep Scan → CUT processor completes → Scene VLM starts automatically (mandatory)
|
||||
```
|
||||
|
||||
**No frontend action required** for triggering. Scene VLM will always run after CUT completion.
|
||||
|
||||
**Prerequisites**:
|
||||
1. Worker is running
|
||||
2. User triggers Deep Scan (CUT must be selected)
|
||||
|
||||
### Manual Trigger (Optional)
|
||||
|
||||
If needed, Scene VLM can be regenerated via re-running CUT processor:
|
||||
|
||||
```bash
|
||||
# Frontend: Re-run CUT processor
|
||||
POST /api/v1/file/{file_uuid}/process
|
||||
{
|
||||
"processors": ["cut"]
|
||||
}
|
||||
```
|
||||
|
||||
## Frontend Display
|
||||
|
||||
### 1. Scene Frames in File Detail
|
||||
|
||||
**Location**: `/Library/{file_uuid}` detail view
|
||||
|
||||
**Suggestion**: Add a new "Scenes" tab or section showing:
|
||||
|
||||
```typescript
|
||||
interface SceneFrame {
|
||||
index: number;
|
||||
timestamp_sec: number;
|
||||
quality_score: number; // blur metric (lower = clearer)
|
||||
filename: string; // e.g., "scene_000.jpg"
|
||||
description?: string; // VLM description (future)
|
||||
}
|
||||
|
||||
interface SceneProfile {
|
||||
file_uuid: string;
|
||||
total_scenes: number;
|
||||
status: 'pending' | 'processing' | 'ready' | 'failed';
|
||||
config: {
|
||||
interval_sec: number;
|
||||
samples_per_interval: number;
|
||||
};
|
||||
scenes: SceneFrame[];
|
||||
}
|
||||
```
|
||||
|
||||
**API to fetch**:
|
||||
|
||||
```bash
|
||||
GET /api/v1/file/{file_uuid}/scenes
|
||||
```
|
||||
|
||||
Response: `SceneProfile` object
|
||||
|
||||
### 2. Scene Thumbnails
|
||||
|
||||
**Image URLs**:
|
||||
|
||||
```
|
||||
http://localhost:3002/output/{file_uuid}/scenes/scene_000.jpg
|
||||
http://localhost:3002/output/{file_uuid}/scenes/scene_001.jpg
|
||||
...
|
||||
```
|
||||
|
||||
**Display**: Grid view with timestamp labels
|
||||
|
||||
### 3. Progress Indicator
|
||||
|
||||
**During processing**: Show Scene VLM in pipeline stages
|
||||
|
||||
**Check if Scene VLM exists**:
|
||||
|
||||
```typescript
|
||||
async function hasSceneVLM(file_uuid: string): boolean {
|
||||
const resp = await fetch(`/api/v1/file/${file_uuid}/scenes`)
|
||||
return resp.ok && (await resp.json()).status === 'ready'
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Right-Click Menu Context
|
||||
|
||||
**Suggestion**: In `/Library` context menu, add indicator if Scene VLM data exists
|
||||
|
||||
```typescript
|
||||
// In context menu display
|
||||
<div v-if="hasSceneVLM(ctxMenuFile.file_uuid)">
|
||||
🎬 Scene VLM: {{ ctxMenuFile.sceneCount }} scenes
|
||||
</div>
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Backend Environment Variables
|
||||
|
||||
Scene VLM is **mandatory** and runs by default. These environment variables control the sampling parameters:
|
||||
|
||||
```bash
|
||||
MOMENTRY_SCENE_VLM_INTERVAL=10 # Sampling interval (seconds, default: 10)
|
||||
MOMENTRY_SCENE_VLM_SAMPLES=10 # Frames per interval to evaluate (default: 10)
|
||||
MOMENTRY_SCENE_VLM_USE_CUTS=true # Consider CUT boundaries (default: true)
|
||||
MOMENTRY_SCENE_VLM_MAX_WORKERS=10 # Parallel processing threads (default: 10)
|
||||
```
|
||||
|
||||
**Optional**: To disable Scene VLM (not recommended for production):
|
||||
|
||||
```bash
|
||||
MOMENTRY_SCENE_VLM_ENABLED=false
|
||||
```
|
||||
|
||||
### Frontend Settings
|
||||
|
||||
**No frontend configuration needed**. All sampling logic is handled by backend.
|
||||
|
||||
## Data Structure
|
||||
|
||||
### Output Files
|
||||
|
||||
```
|
||||
/Users/accusys/momentry/output/{file_uuid}/
|
||||
├── {file_uuid}.scenes.json # Scene metadata (full path: /Users/accusys/momentry/output/{file_uuid}.scenes.json)
|
||||
└── scenes/ # Directory: /Users/accusys/momentry/output/{file_uuid}/scenes/
|
||||
├── scene_000.jpg # Frame at 0.5s (full path: /Users/accusys/momentry/output/{file_uuid}/scenes/scene_000.jpg)
|
||||
├── scene_001.jpg # Frame at 14.51s
|
||||
├── scene_002.jpg # Frame at 20.49s
|
||||
└── ...
|
||||
```
|
||||
|
||||
### scenes.json Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3677f81d232e59f13453d737ceb582cb",
|
||||
"total_scenes": 31,
|
||||
"status": "ready",
|
||||
"video_info": {
|
||||
"duration_sec": 160.99,
|
||||
"fps": 29.97,
|
||||
"width": 1280,
|
||||
"height": 720,
|
||||
"total_frames": 4833
|
||||
},
|
||||
"config": {
|
||||
"interval_sec": 10,
|
||||
"use_cuts": true,
|
||||
"samples_per_interval": 10,
|
||||
"quality_metric": "ffmpeg_blurdetect"
|
||||
},
|
||||
"scenes": [
|
||||
{
|
||||
"index": 0,
|
||||
"timestamp_sec": 0.50,
|
||||
"quality_score": 4.40,
|
||||
"filename": "scene_000.jpg"
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"timestamp_sec": 14.51,
|
||||
"quality_score": 5.84,
|
||||
"filename": "scene_001.jpg"
|
||||
}
|
||||
],
|
||||
"created_at": "2026-09-21T12:00:00Z",
|
||||
"updated_at": "2026-09-21T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Metrics
|
||||
|
||||
| Video Duration | Scenes Generated | Processing Time | Speedup vs Trace VLM |
|
||||
|----------------|------------------|-----------------|----------------------|
|
||||
| 160s | 31 scenes | ~3s | 100x (106 calls → 31 calls) |
|
||||
| 1min | 6 scenes | <1s | 100x |
|
||||
| 5min | 30 scenes | ~5s | 100x |
|
||||
| 10min | 60 scenes | ~10s | 100x |
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Get Scene Profile
|
||||
|
||||
```bash
|
||||
GET /api/v1/file/{file_uuid}/scenes
|
||||
```
|
||||
|
||||
**Response**:
|
||||
- `200 OK`: SceneProfile object
|
||||
- `404 Not Found`: Scene VLM not processed yet
|
||||
|
||||
**Example**:
|
||||
|
||||
```bash
|
||||
curl http://localhost:3002/api/v1/file/3677f81d232e59f13453d737ceb582cb/scenes
|
||||
```
|
||||
|
||||
**Note**: This API endpoint needs to be implemented. Currently, frontend can read the JSON file directly from `/Users/accusys/momentry/output/{file_uuid}.scenes.json`.
|
||||
|
||||
### Get Scene Frame Image
|
||||
|
||||
```bash
|
||||
GET /output/{file_uuid}/scenes/scene_{index}.jpg
|
||||
```
|
||||
|
||||
**Full path on server**:
|
||||
```
|
||||
/Users/accusys/momentry/output/{file_uuid}/scenes/scene_{index}.jpg
|
||||
```
|
||||
|
||||
**Example**:
|
||||
|
||||
```html
|
||||
<img src="http://localhost:3002/output/3677f81d/scenes/scene_000.jpg" />
|
||||
```
|
||||
|
||||
## Cleanup on Unregister
|
||||
|
||||
When a file is unregistered, Scene VLM data is **automatically deleted**:
|
||||
|
||||
- `{file_uuid}.scenes.json`
|
||||
- `{file_uuid}/scenes/` directory
|
||||
|
||||
**No frontend action required**.
|
||||
|
||||
## Testing
|
||||
|
||||
### 1. Trigger Deep Scan
|
||||
|
||||
Frontend → Right-click file → Deep Scan (with CUT selected)
|
||||
|
||||
Scene VLM will start automatically after CUT completes.
|
||||
|
||||
### 2. Verify Output
|
||||
|
||||
```bash
|
||||
# Check scenes.json exists (full path)
|
||||
ls /Users/accusys/momentry/output/{file_uuid}.scenes.json
|
||||
|
||||
# Check frames directory (full path)
|
||||
ls /Users/accusys/momentry/output/{file_uuid}/scenes/
|
||||
|
||||
# Count scenes
|
||||
curl http://localhost:3002/api/v1/file/{file_uuid}/scenes | jq '.total_scenes'
|
||||
```
|
||||
|
||||
### 3. Test Unregister
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:3002/api/v1/unregister \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"file_uuid": "{file_uuid}", "reason": "test"}'
|
||||
|
||||
# Verify cleanup (full paths)
|
||||
ls /Users/accusys/momentry/output/{file_uuid}.scenes.json # Should not exist
|
||||
ls /Users/accusys/momentry/output/{file_uuid}/scenes/ # Should not exist
|
||||
```
|
||||
|
||||
## Common Issues
|
||||
|
||||
### Scene VLM Not Running
|
||||
|
||||
**Symptoms**: No `scenes.json` generated
|
||||
|
||||
**Checklist**:
|
||||
1. Worker is running
|
||||
2. CUT processor completed successfully
|
||||
3. VLM server is running (port 8091)
|
||||
4. Check worker logs: `tail -f /Users/accusys/momentry_core/logs/momentry_3002.log | grep "Scene VLM"`
|
||||
|
||||
### Slow Performance
|
||||
|
||||
**Symptoms**: Processing takes >10s for 5min video
|
||||
|
||||
**Possible causes**:
|
||||
- VLM server not running (port 8091)
|
||||
- `MOMENTRY_SCENE_VLM_MAX_WORKERS` too low
|
||||
- System overloaded
|
||||
|
||||
**Solution**:
|
||||
|
||||
```bash
|
||||
# Check VLM server
|
||||
curl http://localhost:8091/health
|
||||
|
||||
# Increase workers
|
||||
export MOMENTRY_SCENE_VLM_MAX_WORKERS=20
|
||||
./run-worker-3002.sh
|
||||
```
|
||||
|
||||
## Integration Checklist
|
||||
|
||||
Frontend integration checklist:
|
||||
|
||||
- [ ] Add "Scenes" section in file detail view
|
||||
- [ ] Display scene thumbnails grid
|
||||
- [ ] Show timestamp labels on thumbnails
|
||||
- [ ] Add Scene VLM indicator in right-click menu
|
||||
- [ ] Test with `MOMENTRY_SCENE_VLM_ENABLED=true`
|
||||
- [ ] Verify cleanup on unregister
|
||||
- [ ] Add loading state during processing
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
|
||||
1. Check worker logs: `/Users/accusys/momentry_core/logs/momentry_3002.log`
|
||||
2. Check API logs: `/Users/accusys/momentry_core/logs/momentry_3002.log`
|
||||
3. Contact Core team via M4 workspace
|
||||
|
||||
---
|
||||
|
||||
## Backend Implementation Files
|
||||
|
||||
For reference, the backend implementation is in these files:
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `/Users/accusys/momentry_core/src/core/processor/scene_vlm.rs` | Core Scene VLM implementation |
|
||||
| `/Users/accusys/momentry_core/src/core/file_profile.rs` | SceneProfile data structures |
|
||||
| `/Users/accusys/momentry_core/src/core/config.rs` | Environment variable configuration |
|
||||
| `/Users/accusys/momentry_core/src/worker/job_worker.rs` | Worker integration (line ~2288) |
|
||||
| `/Users/accusys/momentry_core/src/api/files.rs` | Unregister cleanup (line ~1086) |
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Author | Changes |
|
||||
|---------|------|--------|---------|
|
||||
| 1.1.0 | 2026-09-21 | Core Team | Changed to mandatory pipeline stage, default enabled |
|
||||
| 1.0.0 | 2026-09-21 | Core Team | Initial version |
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Test Scene VLM API Integration
|
||||
# Usage: ./test_scene_vlm_api.sh <file_uuid> <api_key>
|
||||
|
||||
set -e
|
||||
|
||||
FILE_UUID="${1:-d1e18fa4994aae32d9a63852a80c5a2a}"
|
||||
API_KEY="${2:-muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69}"
|
||||
|
||||
echo "=== Scene VLM API Test ==="
|
||||
echo "File UUID: $FILE_UUID"
|
||||
echo ""
|
||||
|
||||
# Test API
|
||||
echo "1. Testing /api/v1/stats/file/{file_uuid}:"
|
||||
RESPONSE=$(curl -s "http://localhost:3002/api/v1/stats/file/$FILE_UUID?api_key=$API_KEY")
|
||||
|
||||
echo "$RESPONSE" | python3 << 'PYEOF'
|
||||
import sys, json
|
||||
|
||||
try:
|
||||
data = json.load(sys.stdin)
|
||||
|
||||
print("\n✅ API Response:")
|
||||
print(f" File: {data.get('file_name', 'N/A')}")
|
||||
print(f" Status: {data.get('status', 'N/A')}")
|
||||
|
||||
sv = data.get('scene_vlm', {})
|
||||
print(f"\n📊 Scene VLM:")
|
||||
print(f" Total Scenes: {sv.get('total_scenes', 0)}")
|
||||
print(f" VLM Done: {sv.get('vlm_done', 0)}")
|
||||
print(f" VLM Total: {sv.get('vlm_total', 0)}")
|
||||
print(f" Status: {sv.get('status', 'unknown')}")
|
||||
|
||||
if sv.get('vlm_done', 0) == sv.get('vlm_total', 0) and sv.get('vlm_total', 0) > 0:
|
||||
print("\n✅ Scene VLM completed!")
|
||||
elif sv.get('vlm_done', 0) > 0:
|
||||
print(f"\n⏳ Scene VLM in progress ({sv['vlm_done']}/{sv['vlm_total']})")
|
||||
else:
|
||||
print("\n⏳ Scene VLM pending")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ Error parsing response: {e}")
|
||||
sys.exit(1)
|
||||
PYEOF
|
||||
|
||||
echo ""
|
||||
echo "2. Testing scenes.json file:"
|
||||
SCENES_FILE="/Users/accusys/momentry/output/$FILE_UUID.scenes.json"
|
||||
|
||||
if [ -f "$SCENES_FILE" ]; then
|
||||
echo " ✅ File exists: $SCENES_FILE"
|
||||
|
||||
python3 << PYEOF
|
||||
import json
|
||||
|
||||
with open('$SCENES_FILE') as f:
|
||||
data = json.load(f)
|
||||
|
||||
print(f" Total scenes: {data['total_scenes']}")
|
||||
print(f" Status: {data['status']}")
|
||||
|
||||
# Check VLM descriptions
|
||||
completed = sum(1 for s in data['scenes'] if s.get('vlm_status') == 'completed')
|
||||
print(f" VLM completed: {completed}/{data['total_scenes']}")
|
||||
|
||||
# Sample first scene
|
||||
if data['scenes']:
|
||||
s = data['scenes'][0]
|
||||
print(f"\n Sample (Scene 0):")
|
||||
print(f" Time: {s['timestamp_sec']}s")
|
||||
desc = s.get('vlm_description', '')[:60]
|
||||
print(f" Description: {desc}...")
|
||||
print(f" Objects: {s.get('vlm_objects', [])}")
|
||||
print(f" Tags: {s.get('vlm_tags', [])}")
|
||||
PYEOF
|
||||
else
|
||||
echo " ❌ File not found: $SCENES_FILE"
|
||||
fi
|
||||
Reference in New Issue
Block a user