fmusvid 0.0.1
A Python video processing library
License: MIT
Requires Python: >=3.8
Keywords: video, processing, editing, capture, webcam, ai, streaming

# FMUS-VID Library

FMUS-VID is a Python library for video processing and manipulation.

## Installation

```bash
# Basic installation
pip install fmusvid

# With AI features
pip install fmusvid[ai]

# With streaming support
pip install fmusvid[streaming]

# With GUI support
pip install fmusvid[gui]

# With all features
pip install fmusvid[all]
```

## Quick Start

### Basic Video Processing

```python
from fmusvid.video import VideoProcessor
from fmusvid.operations import basic

# Load a video
video = VideoProcessor("input.mp4")

# Apply operations
video.apply(basic.cut(start=10, end=20))
video.apply(basic.resize(width=1280, height=720))

# Save the result
video.save("output.mp4")
```

### Object Detection

```python
from fmusvid.video import VideoProcessor
from fmusvid.ai import detection

# Load a video
video = VideoProcessor("input.mp4")

# Detect objects
results = video.apply(detection.detect_objects(model="yolo"))

# Save the result with bounding boxes
video.save("output_with_detection.mp4")
```

### RTMP Streaming with Multilingual Subtitles

```python
from fmusvid.stream import RTMPCapture, RTMPOutput
from fmusvid.ai.speech import WhisperTranscriber
from fmusvid.ai.translation import LLMTranslator
from fmusvid.operations.text import SubtitleOverlay

# Create components
rtmp_capture = RTMPCapture("rtmp://localhost/live/stream")
transcriber = WhisperTranscriber(model="medium", device="cuda")
translator = LLMTranslator(model="ollama:mistral", target_languages=["es", "fr", "de"])

# Create outputs for different languages
outputs = {
    "en": RTMPOutput("rtmp://localhost/live/stream_en"),
    "es": RTMPOutput("rtmp://localhost/live/stream_es"),
    "fr": RTMPOutput("rtmp://localhost/live/stream_fr"),
    "de": RTMPOutput("rtmp://localhost/live/stream_de")
}

# Process frames in real-time
async for frame, audio in rtmp_capture.aiter_frames_with_audio():
    # Transcribe audio
    text = await transcriber.transcribe_chunk(audio)

    # Translate text
    translations = await translator.translate_async(text)

    # Create frames with different subtitles
    frames = {}
    for lang, translation in translations.items():
        subtitle = SubtitleOverlay(position="bottom")
        frames[lang] = subtitle.apply(frame, translation)

    # Write frames to outputs
    for lang, output_frame in frames.items():
        await outputs[lang].write_frame(output_frame)
```

### Webcam Capture

```python
from fmusvid.capture import CameraCapture

# List available cameras
from fmusvid.capture import list_cameras
cameras = list_cameras()
for camera in cameras:
    print(f"Camera {camera['id']}: {camera['name']} ({camera['width']}x{camera['height']})")

# Create a camera capture instance
camera = CameraCapture(camera_id=0, width=1280, height=720)

# Start the camera
camera.start()

# Capture a frame
frame = camera.get_frame()

# Capture an image and save it
camera.capture_image("webcam_capture.jpg")

# Record video
camera.record_video("webcam_recording.mp4", duration=10)  # 10 seconds

# Stop the camera
camera.stop()
```

## GUI Applications

FMUS-VID includes a PyQt6-based GUI application for webcam capture:

```bash
# Install with GUI support
pip install fmusvid[gui]

# Run the camera GUI application
python examples/camera_gui.py
```

## Example Scripts

The library includes several example scripts to demonstrate its capabilities:

- `examples/basic_example.py`: Basic video processing operations
- `examples/transitions_example.py`: Video transitions and effects
- `examples/ai_features.py`: Object detection and tracking
- `examples/rtmp_live_example.py`: RTMP streaming with real-time transcription and translation
- `examples/rtmp_demo.py`: Demo of RTMP capabilities using local video files
- `examples/camera_gui.py`: PyQt6-based webcam capture application

## Command Line Interface

FMUS-VID provides a comprehensive command-line interface for common video operations:

```bash
# Basic CLI usage
fmusvid [command] [options]
```

### Available Commands

| Command | Description | Example |
|---------|-------------|---------|
| `convert` | Convert video format | `fmusvid convert input.mp4 output.webm` |
| `cut` | Cut a segment from video | `fmusvid cut -i input.mp4 -o output.mp4 -s 10 -e 20` |
| `resize` | Resize video | `fmusvid resize -i input.mp4 -o output.mp4 -w 1280 -h 720` |
| `info` | Display video information | `fmusvid info input.mp4` |
| `concat` | Concatenate multiple videos | `fmusvid concat -i video1.mp4 video2.mp4 -o output.mp4` |
| `extract-audio` | Extract audio from video | `fmusvid extract-audio -i input.mp4 -o audio.mp3` |
| `add-subtitles` | Add subtitles to video | `fmusvid add-subtitles -i input.mp4 -s subtitles.srt -o output.mp4` |
| `generate-subtitles` | Generate subtitles using AI | `fmusvid generate-subtitles -i input.mp4 -o subtitles.srt --model medium` |
| `translate-subtitles` | Translate subtitles | `fmusvid translate-subtitles -i subtitles.srt -o subtitles_es.srt --target es` |
| `camera` | Capture from webcam | `fmusvid camera -o capture.mp4 -d 10` |
| `screen` | Capture screen recording | `fmusvid screen -o screen.mp4 -d 30` |
| `rtmp-stream` | Stream video to RTMP server | `fmusvid rtmp-stream -i input.mp4 -u rtmp://server/live/stream` |
| `rtmp-capture` | Capture RTMP stream | `fmusvid rtmp-capture -u rtmp://server/live/stream -o output.mp4 -d 60` |

### Global Options

| Option | Description |
|--------|-------------|
| `-v, --verbose` | Enable verbose output |
| `--version` | Show version information |
| `--help` | Show help message |
| `--config FILE` | Use custom configuration file |
| `--log-level LEVEL` | Set logging level (debug, info, warning, error) |

For more detailed help on each command:

```bash
fmusvid [command] --help
```

## Dependencies

- OpenCV
- NumPy
- FFmpeg
- PyTorch (for AI features)
- Faster-Whisper (for speech recognition)
- Local LLM support (for translation)
- PyQt6 (for GUI applications)

## License

This project is licensed under the MIT License.