> 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/ffmpeg-nvenc.md).

# FFmpeg NVENC

Hardware-beschleunigte Video-Codierung mit NVIDIA-GPUs.

{% 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 NVENC?

NVENC (NVIDIA Video Encoder) bietet:

* 5–10× schnellere Codierung als die CPU
* Unterstützung für H.264, H.265/HEVC, AV1
* Echtzeit-Codierung in 4K/8K
* Geringe GPU-Rechenutzung

## Anforderungen

| Codec | Min. GPU  | Empfohlen |
| ----- | --------- | --------- |
| H.264 | GTX 600+  | RTX 3060+ |
| HEVC  | GTX 900+  | RTX 3070+ |
| AV1   | RTX 4000+ | RTX 4090  |

## Schnelle Bereitstellung

**Docker-Image:**

```
nvidia/cuda:12.1.0-devel-ubuntu22.04
```

**Ports:**

```
22/tcp
```

**Befehl:**

```bash
apt-get update && \
apt-get install -y ffmpeg && \
echo "FFmpeg mit NVENC bereit"
```

## NVENC-Unterstützung prüfen

```bash

# Verfügbare Encoder prüfen
ffmpeg -encoders | grep nvenc

# Sollte anzeigen:

# V....D h264_nvenc

# V....D hevc_nvenc

# V....D av1_nvenc (RTX 4000+)
```

## Grundlegende Codierung

### H.264-Codierung

```bash
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p7 -cq 23 output.mp4
```

### HEVC/H.265-Codierung

```bash
ffmpeg -i input.mp4 -c:v hevc_nvenc -preset p7 -cq 23 output.mp4
```

### AV1-Codierung (RTX 4000+)

```bash
ffmpeg -i input.mp4 -c:v av1_nvenc -preset p7 -cq 23 output.mp4
```

## Voreinstellungen

| Voreinstellung | Qualität       | Geschwindigkeit |
| -------------- | -------------- | --------------- |
| p1             | Am niedrigsten | Am schnellsten  |
| p2-p3          | Gering         | Schnell         |
| p4-p5          | Mittel         | Ausgeglichen    |
| p6-p7          | Hoch           | Langsam         |

```bash

# Schnellste Codierung
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p1 output.mp4

# Beste Qualität
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p7 output.mp4
```

## Qualitätssteuerung

### Konstante Qualität (CQ)

```bash

# Niedriger = bessere Qualität, größere Datei
ffmpeg -i input.mp4 -c:v h264_nvenc -cq 18 output.mp4

# Empfohlene Werte: 18–28
```

### Konstante Bitrate (CBR)

```bash
ffmpeg -i input.mp4 -c:v h264_nvenc -b:v 10M output.mp4
```

### Variable Bitrate (VBR)

```bash
ffmpeg -i input.mp4 -c:v h264_nvenc -b:v 10M -maxrate 15M -bufsize 20M output.mp4
```

## Auflösung & Skalierung

### Video skalieren

```bash

# Auf 1080p skalieren
ffmpeg -i input.mp4 -vf "scale=1920:1080" -c:v h264_nvenc output.mp4

# Auf 4K skalieren
ffmpeg -i input.mp4 -vf "scale=3840:2160" -c:v hevc_nvenc output.mp4

# Seitenverhältnis beibehalten
ffmpeg -i input.mp4 -vf "scale=-1:1080" -c:v h264_nvenc output.mp4
```

### GPU-Skalierung (schneller)

```bash
ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
    -i input.mp4 \
    -vf "scale_cuda=1920:1080" \
    -c:v h264_nvenc output.mp4
```

## Hardware-Dekodierung + Codierung

Vollständige GPU-Pipeline:

```bash
ffmpeg \
    -hwaccel cuda \
    -hwaccel_output_format cuda \
    -i input.mp4 \
    -c:v h264_nvenc \
    -preset p4 \
    output.mp4
```

## Stapelkonvertierung

### Shell-Skript

```bash
#!/bin/bash
INPUT_DIR=$1
OUTPUT_DIR=$2

mkdir -p "$OUTPUT_DIR"

for file in "$INPUT_DIR"/*.{mp4,mkv,avi,mov}; do
    if [ -f "$file" ]; then
        filename=$(basename "$file")
        name="${filename%.*}"

        ffmpeg -hwaccel cuda -i "$file" \
            -c:v h264_nvenc -preset p5 -cq 23 \
            -c:a aac -b:a 192k \
            "$OUTPUT_DIR/${name}.mp4"

        echo "Konvertiert: $filename"
    fi
done
```

### Python-Stapel

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

def convert_video(input_path, output_path):
    cmd = [
        'ffmpeg', '-y',
        '-hwaccel', 'cuda',
        '-i', input_path,
        '-c:v', 'h264_nvenc',
        '-preset', 'p5',
        '-cq', '23',
        '-c:a', 'aac',
        '-b:a', '192k',
        output_path
    ]
    subprocess.run(cmd, check=True)

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

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

# Parallel verarbeiten (bei Multi-GPU oder ausreichenden Ressourcen)
for f in files:
    input_path = os.path.join(input_dir, f)
    output_path = os.path.join(output_dir, f.rsplit('.', 1)[0] + '.mp4')
    convert_video(input_path, output_path)
    print(f"Konvertiert: {f}")
```

## Häufige Aufgaben

### In web-optimiertes MP4 konvertieren

```bash
ffmpeg -i input.mp4 \
    -c:v h264_nvenc -preset p5 -cq 23 \
    -c:a aac -b:a 128k \
    -movflags +faststart \
    web_video.mp4
```

### Audio extrahieren

```bash
ffmpeg -i video.mp4 -vn -c:a copy audio.aac
ffmpeg -i video.mp4 -vn -c:a libmp3lame -b:a 320k audio.mp3
```

### Untertitel hinzufügen

```bash

# Untertitel in Video einbrennen
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" -c:v h264_nvenc output.mp4

# Als weiche Untertitel einbetten
ffmpeg -i input.mp4 -i subs.srt -c:v copy -c:a copy -c:s mov_text output.mp4
```

### Video beschneiden

```bash

# Ab 00:01:00 für 30 Sekunden
ffmpeg -ss 00:01:00 -i input.mp4 -t 30 -c:v h264_nvenc output.mp4

# Von Start bis Endzeitstempel
ffmpeg -i input.mp4 -ss 00:00:30 -to 00:02:00 -c:v h264_nvenc output.mp4
```

### Videos zusammenfügen

```bash

# Dateiliste erstellen
echo "file 'video1.mp4'" > list.txt
echo "file 'video2.mp4'" >> list.txt
echo "file 'video3.mp4'" >> list.txt

# Zusammenfügen
ffmpeg -f concat -safe 0 -i list.txt -c:v h264_nvenc output.mp4
```

### GIF erstellen

```bash
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos" output.gif
```

### Frames extrahieren

```bash

# Jeden Frame
ffmpeg -i input.mp4 frames/frame_%04d.png

# Jede 1 Sekunde
ffmpeg -i input.mp4 -vf "fps=1" frames/frame_%04d.png
```

### Frames zu Video

```bash
ffmpeg -framerate 30 -i frames/frame_%04d.png -c:v h264_nvenc output.mp4
```

## Streaming

### RTMP-Stream

```bash
ffmpeg -re -i input.mp4 \
    -c:v h264_nvenc -preset p4 -b:v 4M \
    -c:a aac -b:a 128k \
    -f flv rtmp://server/live/stream
```

### HLS-Ausgabe

```bash
ffmpeg -i input.mp4 \
    -c:v h264_nvenc -preset p5 \
    -c:a aac \
    -f hls -hls_time 10 -hls_list_size 0 \
    output.m3u8
```

## Leistungsvergleich

### Codiergeschwindigkeit (4K-Video)

| Encoder     | GPU/CPU       | Geschwindigkeit |
| ----------- | ------------- | --------------- |
| libx264     | CPU (8 Kerne) | \~30 fps        |
| h264\_nvenc | RTX 3090      | \~300 fps       |
| h264\_nvenc | RTX 4090      | \~450 fps       |
| hevc\_nvenc | RTX 3090      | \~200 fps       |
| hevc\_nvenc | RTX 4090      | \~350 fps       |

## Erweiterte Optionen

### Zwei-Pass-Codierung

```bash

# Durchgang 1
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p7 -b:v 10M -pass 1 -f null /dev/null

# Durchgang 2
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p7 -b:v 10M -pass 2 output.mp4
```

### B-Frames & GOP

```bash
ffmpeg -i input.mp4 \
    -c:v h264_nvenc \
    -bf 2 \           # B-Frames
    -g 60 \           # GOP-Größe
    -keyint_min 30 \  # Minimales Keyframe-Intervall
    output.mp4
```

### HDR-Unterstützung (HEVC)

```bash
ffmpeg -i hdr_input.mp4 \
    -c:v hevc_nvenc \
    -preset p5 \
    -profile:v main10 \
    -pix_fmt p010le \
    hdr_output.mp4
```

## Multi-GPU

```bash

# Spezifische GPU verwenden
ffmpeg -hwaccel cuda -hwaccel_device 0 -i input.mp4 -c:v h264_nvenc output.mp4

# Parallele Codierung auf verschiedenen GPUs
ffmpeg -hwaccel cuda -hwaccel_device 0 -i video1.mp4 -c:v h264_nvenc out1.mp4 &
ffmpeg -hwaccel cuda -hwaccel_device 1 -i video2.mp4 -c:v h264_nvenc out2.mp4 &
wait
```

## Fehlerbehebung

### NVENC nicht gefunden

```bash

# NVIDIA-Treiber prüfen
nvidia-smi

# FFmpeg-Build prüfen
ffmpeg -encoders | grep nvenc
```

### Codierung fehlgeschlagen

```bash

# Gleichzeitige Sitzungen reduzieren (NVENC-Limit)

# Consumer-GPUs: 3–5 Sitzungen

# Professionelle GPUs: unbegrenzt
```

### Schlechte Qualität

* Höheres Preset verwenden (p6, p7)
* Niedrigeren CQ-Wert (18–20)
* Bitrate erhöhen

## 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

* [KI-Videogenerierung](/guides/guides_v2-de/video-generierung/ai-video-generation.md)
* [RIFE-Interpolation](/guides/guides_v2-de/videoverarbeitung/rife-interpolation.md)
* [Real-ESRGAN-Upscaling](/guides/guides_v2-de/bildverarbeitung/real-esrgan-upscaling.md)


---

# 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/ffmpeg-nvenc.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.
