Audio and Video Processing#
Docling converts audio and video files into a DoclingDocument — the same intermediate representation used for PDFs and DOCX files — that can then be exported to Markdown, JSON, HTML, or DocTags and fed into RAG pipelines, summarizers, or search indexes.
Audio files run through the ASR pipeline (AsrPipeline), which transcribes speech to text. Video files run through the video pipeline (VideoPipeline), which additionally samples representative frames and optionally assigns speaker labels via diarization .
Supported formats :
| Type | Formats |
|---|---|
| Audio | WAV, MP3, M4A, AAC, OGG, FLAC |
| Video | MP4, AVI, MOV, MKV, WEBM |
Prerequisites: Both pipelines require ffmpeg on your PATH for audio decoding. Install with brew install ffmpeg (macOS), apt-get install ffmpeg (Linux), or winget install ffmpeg (Windows) .
Installation#
ASR is an optional extra :
pip install "docling[asr]"
For video with frame sampling and diarization :
pip install "docling-slim[format-video]"
format-video includes everything from asr plus resemblyzer, soundfile, scikit-learn, and librosa.
Pipelines and Entry Points#
ASR Pipeline (audio)#
The primary classes:
AsrPipeline— orchestrates transcription for audio inputsAsrPipelineOptions— top-level configuration; itsasr_optionsfield accepts anyInlineAsrOptionspresetasr_model_specs— preset constants (WHISPER_TINY,WHISPER_TURBO, etc.) and theAsrModelTypeenum used by the CLI
Minimal setup :
from docling.datamodel import asr_model_specs
from docling.datamodel.pipeline_options import AsrPipelineOptions
from docling.document_converter import AudioFormatOption, DocumentConverter
from docling.pipeline.asr_pipeline import AsrPipeline
pipeline_options = AsrPipelineOptions()
pipeline_options.asr_options = asr_model_specs.WHISPER_TURBO
converter = DocumentConverter(
format_options={InputFormat.AUDIO: AudioFormatOption(pipeline_cls=AsrPipeline, pipeline_options=pipeline_options)}
)
result = converter.convert(Path("recording.mp3"))
print(result.document.export_to_markdown())
The output is paragraph-level Markdown with per-segment timestamps: [time: 0.0-4.0] Transcribed text here .
Video Pipeline#
VideoPipeline orchestrates three steps :
- Extract audio from the video via ffmpeg (to a 16kHz mono WAV) and transcribe it using the shared ASR transcriber
- Sample representative frames using fixed-interval or scene-change sampling
- Merge transcript segments and frames by timestamp into a single
DoclingDocument
Frame images and transcript text are interleaved chronologically in the output document . Configuration lives in VideoPipelineOptions.
Frame sampling modes :
| Mode | Value | Behavior |
|---|---|---|
| Fixed interval (default) | FIXED_INTERVAL | One frame every frame_interval_seconds (default 10s) |
| Scene change | SCENE_CHANGE | One frame per detected scene; sensitivity auto-calibrates |
Set generate_frame_images=False to transcribe only, or max_sampled_frames to cap the total frame count.
Speaker diarization: set enable_diarization=True in VideoPipelineOptions to attribute transcript segments to speakers via Resemblyzer embedding clustering. The number of speakers is auto-detected. If the required packages are absent, diarization is silently skipped and transcription proceeds normally .
CLI :
docling --to md video.mp4 # fixed-interval (default)
docling --to md --video-sampling-mode scene --video-prominence 0.03 video.mp4 # scene-change
docling --to md --video-sampling-mode scene --video-diarization video.mp4 # with diarization
Backend Selection and ASR Models#
Three interchangeable ASR backends are available :
| Backend | Library | Hardware | Notes |
|---|---|---|---|
| Native Whisper | openai-whisper (PyTorch) | CPU, CUDA | Default; broadest compatibility |
| MLX Whisper | mlx-whisper | Apple Silicon (MPS) | Optimized for M-series Macs |
| WhisperS2T | whisper-s2t-reborn (CTranslate2) | CPU, CUDA | Experimental; batched decoding for high throughput |
Auto-selecting presets#
Presets like WHISPER_TURBO, WHISPER_LARGE, etc. auto-select the backend at import time by probing for MPS availability and the mlx-whisper package. Priority order :
- MLX Whisper — on Apple Silicon when
mlx-whisperis installed - Native Whisper — everywhere else
WhisperS2T is never auto-selected; use explicit _S2T presets to opt in.
Forcing a backend#
Use suffixed presets to pin a backend regardless of hardware :
WHISPER_TURBO_NATIVE— force native Whisper (CPU/CUDA)WHISPER_TURBO_MLX— force MLX (Apple Silicon)WHISPER_LARGE_V3_S2T— force WhisperS2T (CPU/CUDA only, not available on Apple Silicon)
The full preset list is in asr_model_specs.py. The CLI uses --asr-model <preset_name> (lower-cased) for both audio and video inputs .
Key option classes#
All defined in pipeline_options_asr_model.py:
| Class | Backend | Supported devices |
|---|---|---|
InlineAsrNativeWhisperOptions | openai-whisper | CPU, CUDA |
InlineAsrMlxWhisperOptions | mlx-whisper | MPS (Apple Silicon) |
InlineAsrWhisperS2TOptions | CTranslate2 | CPU, CUDA |
Shared base fields on InlineAsrOptions: repo_id, timestamps (default True), temperature (default 0.0), max_time_chunk (default 30s), torch_dtype.
Language: Native and MLX options default language=None (auto-detect from the first 30 seconds). WhisperS2T defaults to "en". Override with an ISO 639-1 code when needed .
Key Source Files#
| File | Purpose |
|---|---|
docling/pipeline/asr_pipeline.py | Audio transcription pipeline |
docling/pipeline/video_pipeline.py | Video pipeline (audio + frames + diarization) |
docling/pipeline/asr_transcriber.py | Backend dispatch and transcription logic |
docling/datamodel/pipeline_options_asr_model.py | Option classes for all three backends |
docling/datamodel/asr_model_specs.py | Preset constants and hardware auto-selection |
docling/utils/video_frame_sampling.py | FixedIntervalFrameSampler and SimpleSceneChangeFrameSampler |
docling/utils/speaker_diarization.py | diarize() and assign_speakers() |
docs/usage/processing_audio_media.md | Official usage guide |
docs/examples/video_pipeline.ipynb | End-to-end video pipeline notebook |
Limitations#
| Limitation | Workaround |
|---|---|
| No SRT subtitle output | Use WebVTT via doc.save_as_vtt(...), or the openai-whisper CLI for SRT |
| Audio-only pipeline has no speaker diarization | Use VideoPipelineOptions.enable_diarization for video; use pyannote-audio for audio-only |
| No word-level timestamps in export | Not currently exposed in export formats |
| WhisperS2T not available on Apple Silicon | Use native or MLX backends on M-series Macs |
See Also#
- Official usage guide — installation, RAG examples, CLI reference
- Video pipeline notebook — end-to-end example
- Apple Silicon support details — MPS vs MLX decision matrix across all Docling components