Joshi004/VideoCaptionService

This generates captions for provided video and compares different models to do so

Python

0

7 commits

updated Nov 27, 2025

See the code

README

Video Caption Service

Generate video captions using Qwen3-Omni-30B on remote H100 cluster with a modern web interface.

๐ŸŽฏ Features

  • ๐ŸŽฅ Video-to-Text Captioning: Comprehensive video analysis including visual content, actions, audio, and speech
  • ๐Ÿค– Qwen3-Omni-30B: Powered by Alibaba's advanced multimodal LLM running on H100 GPUs
  • ๐ŸŽจ Modern UI: Beautiful React + Material-UI interface
  • ๐Ÿณ Docker Ready: Easy deployment with Docker Compose
  • โ˜๏ธ Remote Processing: Leverage powerful H100 cluster for caption generation
  • ๐Ÿ”’ Secure: SSH tunnels for encrypted communication with remote server

๐Ÿ—๏ธ Architecture

Local Machine (MacBook)
โ”œโ”€โ”€ Frontend (React+MUI - Port 3001)
โ”œโ”€โ”€ Backend (FastAPI - Port 8001)
โ””โ”€โ”€ SSH Tunnels (localhost:8000, localhost:8080)
        โ†“ Encrypted SSH
Remote H100 Cluster (85.234.64.44)
โ”œโ”€โ”€ vLLM Service (Qwen3-Omni-30B - Port 8000)
โ”œโ”€โ”€ Video HTTP Server (Port 8080)
โ”œโ”€โ”€ Videos: ~/datasets/videos/
โ””โ”€โ”€ Captions: ~/datasets/captions/

๐Ÿ“‹ Prerequisites

Local Machine

  • Docker & Docker Compose: For containerized services
  • SSH Access: To remote server ([email protected])
  • Network: Stable internet connection for SSH tunnels

Remote Server (Already Set Up)

  • H100 GPU Cluster: With Slurm scheduler
  • Personal Partition: p_naresh with worker-9 node
  • 8ร— H100 GPUs: 80GB VRAM each

๐Ÿš€ Quick Start

Step 1: Setup Remote Server

First time only - Set up the H100 cluster:

# See REMOTE_SETUP.md for complete guide
# Summary:
# 1. SSH to server: ssh [email protected]
# 2. Create directories: mkdir -p ~/datasets/{videos,captions}
# 3. Start vLLM service (see REMOTE_SETUP.md)
# 4. Start video HTTP server (see REMOTE_SETUP.md)

๐Ÿ“– Full instructions: REMOTE_SETUP.md

Step 2: Upload Videos to Remote

# Upload videos to remote server
rsync -avz --progress ./my-videos/ [email protected]:~/datasets/videos/

Step 3: Configure Local Environment

cd VideoCaptionService
cp .env.example .env
# .env is pre-configured for remote setup

Step 4: Establish SSH Tunnels

In a separate terminal, run:

./scripts/start-tunnels.sh

This creates tunnels for:

  • Port 8000: vLLM API
  • Port 8080: Video HTTP server

Keep this terminal open!

Step 5: Start Local Services

./start.sh

This will:

  • โœ… Verify SSH tunnels are active
  • โœ… Start backend Docker container
  • โœ… Start frontend Docker container

Step 6: Access the Application

Step 7: Generate Captions

  1. Open http://localhost:3001
  2. Videos from remote server appear automatically
  3. Click "Generate Caption" on any video
  4. Processing happens on remote H100 (1-3 minutes)
  5. Click "View" to see video with caption

๐Ÿ“‚ Project Structure

VideoCaptionService/
โ”œโ”€โ”€ backend/                    # FastAPI backend (Docker)
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ routers/            # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ services/           # Business logic (vLLM client)
โ”‚   โ”‚   โ””โ”€โ”€ utils/              # Helper functions
โ”‚   โ”œโ”€โ”€ videos/                 # (Not used - videos on remote)
โ”‚   โ””โ”€โ”€ captions/               # Generated captions (synced from remote)
โ”‚
โ”œโ”€โ”€ frontend/                   # React frontend (Docker)
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/         # UI components
โ”‚       โ””โ”€โ”€ services/           # API client
โ”‚
โ”œโ”€โ”€ scripts/                    # Helper scripts
โ”‚   โ”œโ”€โ”€ start-tunnels.sh        # Establish SSH tunnels
โ”‚   โ””โ”€โ”€ sync-captions.sh        # Sync captions from remote
โ”‚
โ”œโ”€โ”€ docker-compose.yml          # Docker orchestration
โ”œโ”€โ”€ start.sh                    # Startup script (checks tunnels)
โ”œโ”€โ”€ stop.sh                     # Shutdown script
โ”œโ”€โ”€ REMOTE_SETUP.md             # Remote server setup guide
โ””โ”€โ”€ .env.example                # Environment configuration

๐ŸŽฎ Usage

Daily Workflow

1. Start SSH Tunnels (if not already running):

./scripts/start-tunnels.sh

2. Start Local Services:

./start.sh

3. Use the Application:

4. Stop Local Services:

./stop.sh

Note: SSH tunnels and remote services remain running.

Managing Videos

Upload videos to remote:

rsync -avz my_video.mp4 [email protected]:~/datasets/videos/

Sync captions to local:

./scripts/sync-captions.sh

View captions:

ls backend/captions/
cat backend/captions/my_video.mp4_qwen3-omni.json

Caption format:

{
  "filename": "my_video.mp4",
  "caption": "The video shows...",
  "generated_at": "2025-11-05T10:30:00Z",
  "processing_time_seconds": 45.2,
  "model_name": "qwen3-omni",
  "model_version": "Qwen/Qwen3-Omni-30B-A3B-Instruct"
}

๐Ÿ”ง Configuration

Environment Variables

Edit .env:

# Remote Server
[email protected]
REMOTE_VIDEOS_DIR=~/datasets/videos
REMOTE_CAPTIONS_DIR=~/datasets/captions

# SSH Tunnel Ports
VLLM_API_URL=http://localhost:8000
REMOTE_VIDEO_URL=http://localhost:8080

# Local Ports
BACKEND_PORT=8011
FRONTEND_PORT=3001

# Video Constraints
MAX_VIDEO_SIZE_MB=100           # Max file size
MAX_VIDEO_DURATION_SEC=300      # Max duration (5 min)

# Model
MODEL_NAME=qwen3-omni

๐Ÿ› Troubleshooting

SSH Tunnels Not Working

# Check tunnel status
lsof -i :8000
lsof -i :8080

# Test vLLM connectivity
curl http://localhost:8000/v1/models

# Test video server
curl http://localhost:8080/

# Restart tunnels
lsof -ti:8000 | xargs kill
lsof -ti:8080 | xargs kill
./scripts/start-tunnels.sh

Docker Services Won't Start

# Check container logs
docker-compose logs -f

# Check port conflicts
lsof -i :8001
lsof -i :3001

# Rebuild containers
docker-compose down
docker-compose up --build

Caption Generation Fails

Check:

  1. โœ… SSH tunnels active: ./scripts/start-tunnels.sh
  2. โœ… Remote vLLM running: curl http://localhost:8000/v1/models
  3. โœ… Video exists on remote: ssh [email protected] "ls ~/datasets/videos/"
  4. โœ… Video server running: curl http://localhost:8080/
  5. โœ… Video size < 100MB, duration < 5 min

Remote Service Issues

# SSH to remote server
ssh [email protected]

# Check vLLM status
squeue -u $USER

# View vLLM logs
tail -f qwen3-vllm-*.log

# Restart vLLM (see REMOTE_SETUP.md)

๐Ÿ“Š Performance

  • Caption Generation: 1-3 minutes per video (depends on length)
  • Network Latency: 2-5 seconds for video streaming via tunnel
  • Remote Resources:
    • vLLM Service: 1ร— H100 (80GB VRAM) + 128GB RAM
    • Processing: ~45s for 1-min video, ~2-3min for 5-min video
  • Local Resources:
    • Backend Container: ~1GB RAM
    • Frontend Container: ~512MB RAM
    • SSH Tunnels: Minimal CPU/RAM

๐Ÿ”’ Security Notes

  • All communication with remote server uses encrypted SSH tunnels
  • vLLM service only accessible via localhost (tunneled)
  • Remote cluster network is isolated
  • For production:
    • Use VPN or WireGuard instead of SSH tunnels
    • Add API authentication
    • Implement rate limiting

๐Ÿ“ API Documentation

Once running, visit:

Key endpoints:

  • GET /api/videos - List all videos (from remote)
  • POST /api/videos/{filename}/caption - Generate caption (via vLLM)
  • GET /api/videos/{filename}/caption - Get existing caption
  • GET /api/videos/{filename}/stream - Stream video (from remote)

๐Ÿค Contributing

This is a prototype service. Improvements welcome!

๐Ÿ“„ License

See LICENSE file.

๐Ÿ™ Credits

๐Ÿ“ž Support

For issues:

  1. Check SSH tunnels: ./scripts/start-tunnels.sh
  2. Check local logs: docker-compose logs -f
  3. Check remote services: See REMOTE_SETUP.md
  4. Verify connectivity: curl http://localhost:8000/v1/models

๐Ÿ“š Additional Documentation


Happy Captioning! ๐ŸŽฌ

Joshi004/VideoCaptionService

This generates captions for provided video and compares different models to do so

Python

0

7 commits

updated Nov 27, 2025

See the code

README

Video Caption Service

Generate video captions using Qwen3-Omni-30B on remote H100 cluster with a modern web interface.

๐ŸŽฏ Features

  • ๐ŸŽฅ Video-to-Text Captioning: Comprehensive video analysis including visual content, actions, audio, and speech
  • ๐Ÿค– Qwen3-Omni-30B: Powered by Alibaba's advanced multimodal LLM running on H100 GPUs
  • ๐ŸŽจ Modern UI: Beautiful React + Material-UI interface
  • ๐Ÿณ Docker Ready: Easy deployment with Docker Compose
  • โ˜๏ธ Remote Processing: Leverage powerful H100 cluster for caption generation
  • ๐Ÿ”’ Secure: SSH tunnels for encrypted communication with remote server

๐Ÿ—๏ธ Architecture

Local Machine (MacBook)
โ”œโ”€โ”€ Frontend (React+MUI - Port 3001)
โ”œโ”€โ”€ Backend (FastAPI - Port 8001)
โ””โ”€โ”€ SSH Tunnels (localhost:8000, localhost:8080)
        โ†“ Encrypted SSH
Remote H100 Cluster (85.234.64.44)
โ”œโ”€โ”€ vLLM Service (Qwen3-Omni-30B - Port 8000)
โ”œโ”€โ”€ Video HTTP Server (Port 8080)
โ”œโ”€โ”€ Videos: ~/datasets/videos/
โ””โ”€โ”€ Captions: ~/datasets/captions/

๐Ÿ“‹ Prerequisites

Local Machine

  • Docker & Docker Compose: For containerized services
  • SSH Access: To remote server ([email protected])
  • Network: Stable internet connection for SSH tunnels

Remote Server (Already Set Up)

  • H100 GPU Cluster: With Slurm scheduler
  • Personal Partition: p_naresh with worker-9 node
  • 8ร— H100 GPUs: 80GB VRAM each

๐Ÿš€ Quick Start

Step 1: Setup Remote Server

First time only - Set up the H100 cluster:

# See REMOTE_SETUP.md for complete guide
# Summary:
# 1. SSH to server: ssh [email protected]
# 2. Create directories: mkdir -p ~/datasets/{videos,captions}
# 3. Start vLLM service (see REMOTE_SETUP.md)
# 4. Start video HTTP server (see REMOTE_SETUP.md)

๐Ÿ“– Full instructions: REMOTE_SETUP.md

Step 2: Upload Videos to Remote

# Upload videos to remote server
rsync -avz --progress ./my-videos/ [email protected]:~/datasets/videos/

Step 3: Configure Local Environment

cd VideoCaptionService
cp .env.example .env
# .env is pre-configured for remote setup

Step 4: Establish SSH Tunnels

In a separate terminal, run:

./scripts/start-tunnels.sh

This creates tunnels for:

  • Port 8000: vLLM API
  • Port 8080: Video HTTP server

Keep this terminal open!

Step 5: Start Local Services

./start.sh

This will:

  • โœ… Verify SSH tunnels are active
  • โœ… Start backend Docker container
  • โœ… Start frontend Docker container

Step 6: Access the Application

Step 7: Generate Captions

  1. Open http://localhost:3001
  2. Videos from remote server appear automatically
  3. Click "Generate Caption" on any video
  4. Processing happens on remote H100 (1-3 minutes)
  5. Click "View" to see video with caption

๐Ÿ“‚ Project Structure

VideoCaptionService/
โ”œโ”€โ”€ backend/                    # FastAPI backend (Docker)
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ routers/            # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ services/           # Business logic (vLLM client)
โ”‚   โ”‚   โ””โ”€โ”€ utils/              # Helper functions
โ”‚   โ”œโ”€โ”€ videos/                 # (Not used - videos on remote)
โ”‚   โ””โ”€โ”€ captions/               # Generated captions (synced from remote)
โ”‚
โ”œโ”€โ”€ frontend/                   # React frontend (Docker)
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/         # UI components
โ”‚       โ””โ”€โ”€ services/           # API client
โ”‚
โ”œโ”€โ”€ scripts/                    # Helper scripts
โ”‚   โ”œโ”€โ”€ start-tunnels.sh        # Establish SSH tunnels
โ”‚   โ””โ”€โ”€ sync-captions.sh        # Sync captions from remote
โ”‚
โ”œโ”€โ”€ docker-compose.yml          # Docker orchestration
โ”œโ”€โ”€ start.sh                    # Startup script (checks tunnels)
โ”œโ”€โ”€ stop.sh                     # Shutdown script
โ”œโ”€โ”€ REMOTE_SETUP.md             # Remote server setup guide
โ””โ”€โ”€ .env.example                # Environment configuration

๐ŸŽฎ Usage

Daily Workflow

1. Start SSH Tunnels (if not already running):

./scripts/start-tunnels.sh

2. Start Local Services:

./start.sh

3. Use the Application:

4. Stop Local Services:

./stop.sh

Note: SSH tunnels and remote services remain running.

Managing Videos

Upload videos to remote:

rsync -avz my_video.mp4 [email protected]:~/datasets/videos/

Sync captions to local:

./scripts/sync-captions.sh

View captions:

ls backend/captions/
cat backend/captions/my_video.mp4_qwen3-omni.json

Caption format:

{
  "filename": "my_video.mp4",
  "caption": "The video shows...",
  "generated_at": "2025-11-05T10:30:00Z",
  "processing_time_seconds": 45.2,
  "model_name": "qwen3-omni",
  "model_version": "Qwen/Qwen3-Omni-30B-A3B-Instruct"
}

๐Ÿ”ง Configuration

Environment Variables

Edit .env:

# Remote Server
[email protected]
REMOTE_VIDEOS_DIR=~/datasets/videos
REMOTE_CAPTIONS_DIR=~/datasets/captions

# SSH Tunnel Ports
VLLM_API_URL=http://localhost:8000
REMOTE_VIDEO_URL=http://localhost:8080

# Local Ports
BACKEND_PORT=8011
FRONTEND_PORT=3001

# Video Constraints
MAX_VIDEO_SIZE_MB=100           # Max file size
MAX_VIDEO_DURATION_SEC=300      # Max duration (5 min)

# Model
MODEL_NAME=qwen3-omni

๐Ÿ› Troubleshooting

SSH Tunnels Not Working

# Check tunnel status
lsof -i :8000
lsof -i :8080

# Test vLLM connectivity
curl http://localhost:8000/v1/models

# Test video server
curl http://localhost:8080/

# Restart tunnels
lsof -ti:8000 | xargs kill
lsof -ti:8080 | xargs kill
./scripts/start-tunnels.sh

Docker Services Won't Start

# Check container logs
docker-compose logs -f

# Check port conflicts
lsof -i :8001
lsof -i :3001

# Rebuild containers
docker-compose down
docker-compose up --build

Caption Generation Fails

Check:

  1. โœ… SSH tunnels active: ./scripts/start-tunnels.sh
  2. โœ… Remote vLLM running: curl http://localhost:8000/v1/models
  3. โœ… Video exists on remote: ssh [email protected] "ls ~/datasets/videos/"
  4. โœ… Video server running: curl http://localhost:8080/
  5. โœ… Video size < 100MB, duration < 5 min

Remote Service Issues

# SSH to remote server
ssh [email protected]

# Check vLLM status
squeue -u $USER

# View vLLM logs
tail -f qwen3-vllm-*.log

# Restart vLLM (see REMOTE_SETUP.md)

๐Ÿ“Š Performance

  • Caption Generation: 1-3 minutes per video (depends on length)
  • Network Latency: 2-5 seconds for video streaming via tunnel
  • Remote Resources:
    • vLLM Service: 1ร— H100 (80GB VRAM) + 128GB RAM
    • Processing: ~45s for 1-min video, ~2-3min for 5-min video
  • Local Resources:
    • Backend Container: ~1GB RAM
    • Frontend Container: ~512MB RAM
    • SSH Tunnels: Minimal CPU/RAM

๐Ÿ”’ Security Notes

  • All communication with remote server uses encrypted SSH tunnels
  • vLLM service only accessible via localhost (tunneled)
  • Remote cluster network is isolated
  • For production:
    • Use VPN or WireGuard instead of SSH tunnels
    • Add API authentication
    • Implement rate limiting

๐Ÿ“ API Documentation

Once running, visit:

Key endpoints:

  • GET /api/videos - List all videos (from remote)
  • POST /api/videos/{filename}/caption - Generate caption (via vLLM)
  • GET /api/videos/{filename}/caption - Get existing caption
  • GET /api/videos/{filename}/stream - Stream video (from remote)

๐Ÿค Contributing

This is a prototype service. Improvements welcome!

๐Ÿ“„ License

See LICENSE file.

๐Ÿ™ Credits

๐Ÿ“ž Support

For issues:

  1. Check SSH tunnels: ./scripts/start-tunnels.sh
  2. Check local logs: docker-compose logs -f
  3. Check remote services: See REMOTE_SETUP.md
  4. Verify connectivity: curl http://localhost:8000/v1/models

๐Ÿ“š Additional Documentation


Happy Captioning! ๐ŸŽฌ