33800 Docs

← Retour

Proposition : API FFmpeg pour Jellyfin

Status : IMPLEMENTEE

Date : 18/12/2025

Contexte

Jellyfin (192.168.1.199) dispose d'une carte graphique permettant l'acceleration materielle pour le transcodage video. L'objectif est de creer une API REST simple pour exposer les fonctionnalites ffmpeg aux services du reseau prive.


Architecture proposee

Stack technique

Structure du projet

ffmpeg-api/
├── src/
│   ├── index.ts           # Point d'entree API
│   ├── routes/
│   │   ├── health.ts      # Healthcheck
│   │   ├── transcode.ts   # Endpoints transcodage
│   │   ├── probe.ts       # Analyse fichiers media
│   │   └── thumbnail.ts   # Generation miniatures
│   ├── services/
│   │   ├── ffmpeg.ts      # Wrapper ffmpeg
│   │   └── queue.ts       # File d'attente jobs
│   └── utils/
│       └── validation.ts  # Validation IPs privees
├── Dockerfile
├── docker-compose.yml
├── package.json
├── tsconfig.json
└── README.md

Endpoints API

GET /health

Verification de l'etat du service et de ffmpeg.

POST /probe

Analyse un fichier media et retourne les metadonnees.

{
  "input": "/path/to/video.mp4"
}

POST /transcode

Lance un transcodage video.

{
  "input": "/path/to/source.mp4",
  "output": "/path/to/output.mp4",
  "codec": "h264_nvenc",
  "preset": "fast",
  "crf": 23
}

POST /thumbnail

Genere une miniature.

{
  "input": "/path/to/video.mp4",
  "output": "/path/to/thumb.jpg",
  "timestamp": "00:01:00"
}

GET /jobs

Liste les jobs en cours.

GET /jobs/:id

Statut d'un job specifique.

DELETE /jobs/:id

Annule un job.


Securite

Restriction reseau prive uniquement

// Middleware validation IP
const isPrivateIP = (ip: string): boolean => {
  const privateRanges = [
    /^10\./,
    /^172\.(1[6-9]|2[0-9]|3[0-1])\./,
    /^192\.168\./,
    /^127\./
  ];
  return privateRanges.some(r => r.test(ip));
};

Pas d'authentification externe

L'API ne sera pas exposee publiquement (pas de config nginx externe).


Dockerfile

FROM oven/bun:1 as builder
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
COPY . .

FROM oven/bun:1-slim
WORKDIR /app

# Install ffmpeg avec support GPU
RUN apt-get update && apt-get install -y \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app .

EXPOSE 3200
CMD ["bun", "run", "src/index.ts"]

Note : Pour le support GPU NVIDIA, il faudra utiliser l'image nvidia/cuda ou ajouter les drivers.


Configuration Docker Compose

version: '3.8'
services:
  ffmpeg-api:
    build: .
    container_name: ffmpeg-api
    restart: unless-stopped
    ports:
      - "3200:3200"
    volumes:
      - /mnt/media:/media:ro
      - /mnt/output:/output
    environment:
      - NODE_ENV=production
      - API_PORT=3200
    # Pour GPU NVIDIA (si disponible)
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: 1
    #           capabilities: [gpu]

Deploiement

  1. Creer le projet sur GitLab (gitlab.33800.nowhere84.com)
  2. Cloner sur Jellyfin (192.168.1.199)
  3. Build et run avec docker-compose
  4. Tester depuis le reseau prive

URL finale


Questions prealables

  1. GPU : Quelle carte graphique sur Jellyfin ? (NVIDIA/AMD/Intel)
  2. Volumes : Quels chemins media monter ?
  3. Port : 3200 convient-il ?

Actions proposees

Dois-je proceder ?