Video- und Audioverarbeitung
Plant Medienabläufe mit Uploadprüfung, abspielfertigen Formaten und Hintergrundverarbeitung für aufwendige Konvertierungen.
video-audio-processing
Entdecke, wie der Skill hilftWann ist der Skill hilfreich?
Nutze diesen Skill, wenn Videos langsam starten, Konvertierungen die Anwendung blockieren oder Verarbeitungsfehler schwer nachvollziehbar sind.
Wobei hilft er dir?
- Prüft tatsächliche Bild- und Tonspuren, Auflösung und Dauer vor der Konvertierung.
- Erzeugt bei Bedarf Webvideo, adaptive Streams, Vorschaubilder und Audiowellenformen.
- Begrenzt Hintergrundarbeit und temporären Speicher mit verständlichem Fortschritt und Fehlerkategorien.
Das könntest du fragen
Plane den Upload von Schulungsvideos mit Dateiprüfung, abspielfertiger Version und Vorschaubild. Zeige Fortschritt und einen nachvollziehbaren Wiederanlauf bei fehlgeschlagener Konvertierung. Lade ein gültiges Lernvideo und eine Datei mit nicht unterstützten Streams hoch. Das erste wird abspielbar, das zweite scheitert verständlich ohne unbegrenzten Ressourcenverbrauch.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Video & Audio Processing
Video and audio transcoding are among the most CPU-, disk- and time-intensive operations in a backend system. Design media pipelines around upfront stream probing, safe subprocess execution, streaming-friendly container layouts and resumable background jobs.
1. Upfront Probing & Validation (ffprobe)
Before running an expensive ffmpeg transcode, inspect the container and streams with ffprobe (-v error -show_format -show_streams -of json):
- Verify actual streams: confirm whether the file contains a valid video stream (
codec_type === "video"), audio stream (codec_type === "audio"), duration, dimensions (width,height), frame rate and bitrate. - Enforce media bounds: reject files exceeding maximum duration, resolution or stream count, or files using unsupported/dangerous external reference tracks (such as HLS playlist files containing
file://or internalhttp://segments!). - Disable network protocols on untrusted inputs: pass
-protocol_whitelist file,pipe(or local file only) when probing or decoding user-uploaded files so a crafted playlist container cannot trigger SSRF or local file inclusion.
2. Web-Optimized Transcoding & Delivery Formats
- Progressive MP4 (
+faststart):- When outputting MP4 (
H.264/AAC), always pass-movflags +faststartso themoovatom (index table) is moved to the front of the file. Without+faststart, browsers must download the entire multi-hundred-MB file before playback can start! - Normalize pixel format (
-pix_fmt yuv420p) and audio sample rate/channels (-ac 2 -ar 48000) for universal browser and mobile hardware decoder compatibility.
- When outputting MP4 (
- Adaptive Bitrate Streaming (HLS / DASH):
- For longer or high-resolution videos, generate an HLS master playlist (
.m3u8) and segmented renditions (360p,720p,1080p.tsorfMP4.m4ssegments) so players adapt smoothly to mobile network conditions. - Remember that HLS produces many small files (manifest + hundreds of segments): track the rendition prefix cleanly in
file_derivativesso storage cleanup deletes the entire segment prefix when the parent video is deleted.
- For longer or high-resolution videos, generate an HLS master playlist (
- Poster Frames, Timeline Sprites & Audio Waveforms:
- Extract a representative poster frame (
-sskeyframe + WebP/JPEG output) and, for audio files, precompute normalized peak/RMS waveform JSON arrays during background processing so the UI player renders instantly.
- Extract a representative poster frame (
3. Worker Isolation, Progress & Failure Handling
- Never transcode on web/API nodes: run media jobs on dedicated worker queues with bounded concurrency and scratch disk limits.
- Skip redundant transcoding (Stream Copy): if
ffprobeshows an uploaded video is already within target resolution/bitrate inh264/aac, remux with-c copy -movflags +faststartin seconds instead of re-encoding from scratch. - Always clean up scratch files in
finallyblocks and record clear error classifications (corrupt container vs. missing codec vs. worker timeout).
Enthaltene Dateien 1
SKILL.md
