> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/videoverarbeitung/rife-interpolation.md).

# RIFE-Interpolation

Erhöhe die Bildrate von Videos mit RIFE KI-Interpolation.

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Mieten auf CLORE.AI

1. Besuchen Sie [CLORE.AI Marketplace](https://clore.ai/marketplace)
2. Nach GPU-Typ, VRAM und Preis filtern
3. Wählen **On-Demand** (Festpreis) oder **Spot** (Gebotspreis)
4. Konfigurieren Sie Ihre Bestellung:
   * Docker-Image auswählen
   * Ports festlegen (TCP für SSH, HTTP für Web-UIs)
   * Umgebungsvariablen bei Bedarf hinzufügen
   * Startbefehl eingeben
5. Zahlung auswählen: **CLORE**, **BTC**, oder **USDT/USDC**
6. Bestellung erstellen und auf Bereitstellung warten

### Zugriff auf Ihren Server

* Verbindungsdetails finden Sie in **Meine Bestellungen**
* Webschnittstellen: Verwenden Sie die HTTP-Port-URL
* SSH: `ssh -p <port> root@<proxy-address>`

## Was ist RIFE?

RIFE (Real-Time Intermediate Flow Estimation) kann:

* FPS erhöhen (24→60, 30→120)
* Sanfte Zeitlupe erzeugen
* Ruckelige Aufnahmen reparieren
* Echtzeitverarbeitung

## Schnelle Bereitstellung

**Docker-Image:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
```

**Ports:**

```
22/tcp
```

**Befehl:**

```bash
pip install torch torchvision && \
git clone https://github.com/megvii-research/ECCV2022-RIFE.git && \
cd ECCV2022-RIFE && \
pip install -r requirements.txt
```

## Installation

### Option 1: Python-Paket

```bash
pip install rife-ncnn-vulkan-python
```

### Option 2: Aus dem Quellcode

```bash
git clone https://github.com/megvii-research/ECCV2022-RIFE.git
cd ECCV2022-RIFE
pip install -r requirements.txt
```

## Grundlegende Verwendung

### Doppelte Bildrate

```bash
python inference_video.py --exp=1 --video=input.mp4

# Ausgabe: 2x FPS
```

### 4x Bildrate

```bash
python inference_video.py --exp=2 --video=input.mp4

# Ausgabe: 4x FPS
```

### 8x Bildrate

```bash
python inference_video.py --exp=3 --video=input.mp4

# Ausgabe: 8x FPS
```

## Python-API

### Modell laden

```python
import torch
from model.RIFE import Model

device = torch.device("cuda")
model = Model()
model.load_model('./train_log', -1)
model.eval()
model.device()
```

### Einzelbild interpolieren

```python
import cv2
import numpy as np
import torch

def interpolate_frames(frame1, frame2, model, num_frames=1):
    """Interpoliert Frames zwischen zwei Bildern"""
    # Tensoren vorbereiten
    img0 = torch.from_numpy(frame1).permute(2, 0, 1).float() / 255.0
    img1 = torch.from_numpy(frame2).permute(2, 0, 1).float() / 255.0

    img0 = img0.unsqueeze(0).cuda()
    img1 = img1.unsqueeze(0).cuda()

    # Interpolieren
    with torch.no_grad():
        middle = model.inference(img0, img1)

    # Zurück konvertieren
    middle = (middle[0] * 255).byte().cpu().numpy().transpose(1, 2, 0)
    return middle

# Frames laden
frame1 = cv2.imread('frame1.png')
frame2 = cv2.imread('frame2.png')

# Interpoliertes Frame holen
middle_frame = interpolate_frames(frame1, frame2, model)
cv2.imwrite('interpolated.png', middle_frame)
```

### Video verarbeiten

```python
import cv2
import torch
from model.RIFE import Model

model = Model()
model.load_model('./train_log', -1)
model.eval()
model.device()

def process_video(input_path, output_path, multiplier=2):
    cap = cv2.VideoCapture(input_path)
    fps = cap.get(cv2.CAP_PROP_FPS)
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

    out = cv2.VideoWriter(
        output_path,
        cv2.VideoWriter_fourcc(*'mp4v'),
        fps * multiplier,
        (width, height)
    )

    ret, prev_frame = cap.read()
    if not ret:
        return

    out.write(prev_frame)

    while True:
        ret, curr_frame = cap.read()
        if not ret:
            break

        # Tensoren vorbereiten
        img0 = torch.from_numpy(prev_frame).permute(2, 0, 1).float() / 255.0
        img1 = torch.from_numpy(curr_frame).permute(2, 0, 1).float() / 255.0

        img0 = img0.unsqueeze(0).cuda()
        img1 = img1.unsqueeze(0).cuda()

        # Zwischenframes erzeugen
        for i in range(multiplier - 1):
            t = (i + 1) / multiplier
            with torch.no_grad():
                middle = model.inference(img0, img1, timestep=t)
            middle = (middle[0] * 255).byte().cpu().numpy().transpose(1, 2, 0)
            out.write(middle)

        out.write(curr_frame)
        prev_frame = curr_frame

    cap.release()
    out.release()

process_video('input.mp4', 'output_60fps.mp4', multiplier=2)
```

## Verwendung von rife-ncnn-vulkan

Schnellere NCNN-Implementierung:

```python
from rife_ncnn_vulkan import Rife

rife = Rife(gpu_id=0)

# Interpolieren
frame1 = Image.open('frame1.png')
frame2 = Image.open('frame2.png')
middle = rife.process(frame1, frame2)
middle.save('interpolated.png')
```

### Videobearbeitung

```python
from rife_ncnn_vulkan import Rife
import cv2
from PIL import Image

rife = Rife(gpu_id=0, num_threads=4)

def interpolate_video(input_path, output_path, factor=2):
    cap = cv2.VideoCapture(input_path)
    fps = cap.get(cv2.CAP_PROP_FPS)
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

    out = cv2.VideoWriter(
        output_path,
        cv2.VideoWriter_fourcc(*'mp4v'),
        fps * factor,
        (width, height)
    )

    ret, prev = cap.read()
    out.write(prev)

    while True:
        ret, curr = cap.read()
        if not ret:
            break

        # In PIL konvertieren
        prev_pil = Image.fromarray(cv2.cvtColor(prev, cv2.COLOR_BGR2RGB))
        curr_pil = Image.fromarray(cv2.cvtColor(curr, cv2.COLOR_BGR2RGB))

        # Interpolieren
        for i in range(factor - 1):
            t = (i + 1) / factor
            mid = rife.process(prev_pil, curr_pil, timestep=t)
            mid_cv = cv2.cvtColor(np.array(mid), cv2.COLOR_RGB2BGR)
            out.write(mid_cv)

        out.write(curr)
        prev = curr

    cap.release()
    out.release()
```

## Zeitlupe

Sanfte Zeitlupe erstellen:

```python

# Original: 30 fps, 10 Sekunden = 300 Frames

# 8x Interpolation: 2400 Frames

# Wiedergabe mit 30 fps: 80 Sekunden (8x langsamer)

python inference_video.py --exp=3 --video=input.mp4

# Dies erzeugt 8x Frames, bei originaler FPS abspielen für Zeitlupe
```

### Zeitlupen-Skript

```python
def create_slow_motion(input_path, output_path, slowdown_factor=4):
    """Erstellt ein Zeitlupenvideo"""
    cap = cv2.VideoCapture(input_path)
    original_fps = cap.get(cv2.CAP_PROP_FPS)

    # Interpolieren, um mehr Frames zu erhalten
    exp = int(np.log2(slowdown_factor))
    interpolate_video(input_path, 'temp_interpolated.mp4', factor=slowdown_factor)

    # Erneut mit originaler FPS encodieren
    cap2 = cv2.VideoCapture('temp_interpolated.mp4')
    width = int(cap2.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(cap2.get(cv2.CAP_PROP_FRAME_HEIGHT))

    out = cv2.VideoWriter(
        output_path,
        cv2.VideoWriter_fourcc(*'mp4v'),
        original_fps,  # Originale FPS beibehalten
        (width, height)
    )

    while True:
        ret, frame = cap2.read()
        if not ret:
            break
        out.write(frame)

    cap.release()
    cap2.release()
    out.release()
```

## Batch-Verarbeitung

```python
import os
from concurrent.futures import ThreadPoolExecutor

def process_single(input_path, output_dir, factor=2):
    filename = os.path.basename(input_path)
    output_path = os.path.join(output_dir, f"interpolated_{filename}")
    interpolate_video(input_path, output_path, factor)
    return output_path

input_dir = './videos'
output_dir = './interpolated'
os.makedirs(output_dir, exist_ok=True)

videos = [os.path.join(input_dir, f) for f in os.listdir(input_dir)
          if f.endswith(('.mp4', '.mkv', '.avi'))]

for video in videos:
    result = process_single(video, output_dir, factor=2)
    print(f"Completed: {result}")
```

## Qualitätseinstellungen

### Modellversionen

| Modell    | Qualität  | Geschwindigkeit |
| --------- | --------- | --------------- |
| RIFE v4.6 | Am besten | Langsam         |
| RIFE v4.0 | Großartig | Mittel          |
| RIFE-NCNN | Gut       | Am schnellsten  |

### UHD-Modus

Für 4K+-Videos:

```bash
python inference_video.py --exp=1 --video=input.mp4 --UHD
```

## Speicheroptimierung

### Für begrenzten VRAM

```python

# In Kacheln verarbeiten
from model.RIFE import Model

model = Model()
model.load_model('./train_log', -1)
model.eval()

# Kachelgröße für große Frames festlegen

# model.inference handhabt Kachelung intern
```

### Speicher reduzieren

```bash

# NCNN-Version verwenden (speichereffizienter)
pip install rife-ncnn-vulkan-python
```

## Leistung

| Auflösung | GPU      | 2x Interp FPS |
| --------- | -------- | ------------- |
| 1080p     | RTX 3090 | \~60 fps      |
| 1080p     | RTX 4090 | \~100 fps     |
| 4K        | RTX 3090 | \~15 fps      |
| 4K        | RTX 4090 | \~30 fps      |

## Fehlerbehebung

### Artefakte/Ghosting

* Szenenerkennung verwenden, um Schnitte zu überspringen
* Interpolationsfaktor reduzieren
* Auf schnelle Bewegung prüfen

### Kein Speicher mehr

* NCNN-Version verwenden
* Auf niedrigerer Auflösung verarbeiten, danach hochskalieren
* Batch-Größe reduzieren

### Langsame Verarbeitung

* NCNN-Vulkan-Version verwenden
* GPU-Beschleunigung aktivieren
* Kleineres Modell verwenden

## Szenenerkennung

Interpolation über Szenenschnitte überspringen:

```python
from scenedetect import detect, ContentDetector

scenes = detect('input.mp4', ContentDetector())

# Nicht zwischen Szenen interpolieren
for scene in scenes:
    print(f"Scene: {scene[0].get_frames()} - {scene[1].get_frames()}")
```

## Kostenabschätzung

Typische CLORE.AI-Marktplatztarife (Stand 2024):

| GPU       | Stundensatz | Tagessatz | 4-Stunden-Sitzung |
| --------- | ----------- | --------- | ----------------- |
| RTX 3060  | \~$0.03     | \~$0.70   | \~$0.12           |
| RTX 3090  | \~$0.06     | \~$1.50   | \~$0.25           |
| RTX 4090  | \~$0.10     | \~$2.30   | \~$0.40           |
| A100 40GB | \~$0.17     | \~$4.00   | \~$0.70           |
| A100 80GB | \~$0.25     | \~$6.00   | \~$1.00           |

*Preise variieren je nach Anbieter und Nachfrage. Prüfen Sie* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *auf aktuelle Preise.*

**Geld sparen:**

* Verwenden Sie **Spot** Markt für flexible Workloads (oft 30–50% günstiger)
* Bezahlen mit **CLORE** Token
* Preise bei verschiedenen Anbietern vergleichen

## Nächste Schritte

* [FFmpeg NVENC](/guides/guides_v2-de/videoverarbeitung/ffmpeg-nvenc.md) - Ausgabe encodieren
* [Real-ESRGAN](/guides/guides_v2-de/bildverarbeitung/real-esrgan-upscaling.md) - Video hochskalieren
* [KI-Videogenerierung](/guides/guides_v2-de/video-generierung/ai-video-generation.md) - Videos generieren


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/videoverarbeitung/rife-interpolation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
