Principle:0xsline OpenChatCut Audio Extraction
| Knowledge Sources | |
|---|---|
| Domains | Audio_Processing, Transcription, Media_Processing |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Processing principle that extracts and encodes audio from video or large audio files into a speech-recognition-optimized format (16 kHz mono Opus, with MP3 fallback), with caching and fast-fail for sources without audio tracks.
Description
Audio Extraction is the first stage of the transcription pipeline. It converts source media (video files, large audio files) into a compact audio format optimized for speech recognition:
- Format: Opus at 64 kbps, 16 kHz, mono — ideal for ASR.
- Fallback: MP3 at 64 kbps, 16 kHz, mono (if Opus encoding fails).
- Audio detection: Probes the source with FFprobe to detect an audio track before extraction; fast-fails with `noAudio: true` if none found.
- Caching: If a cached ASR audio file exists (`.asr.ogg` or `.asr.mp3`) and `force` is not set, returns the cached file immediately.
- Path safety: Source must be a `/media/uploads/<safe-name>` path.
- Timeout: 30 minutes for long video sources.
The output file naming convention is `<stem>.asr.ogg` (or `.asr.mp3`), stored in the upload directory alongside the source.
Usage
Use this principle when:
- Preparing audio for cloud or local ASR transcription.
- Extracting audio tracks from video files for speech processing.
- Caching extracted audio to avoid re-extraction on repeated transcription.
Theoretical Basis
The extraction pipeline:
# Abstract algorithm (NOT real implementation)
def extract_asr_audio(source):
# Fast-fail if no audio track
if not probe_has_audio(source):
return { noAudio: True }
# Check cache
if not force and exists(cache_path):
return { path: cache_path, cached: True }
# Encode Opus (primary)
try:
encode(source, output, [
'-c:a', 'libopus', '-b:a', '64k',
'-ac', '1', '-ar', '16000',
])
return { path: output, cached: False }
except:
# Fallback to MP3
encode(source, mp3_output, [
'-c:a', 'libmp3lame', '-b:a', '64k',
'-ac', '1', '-ar', '16000',
])
return { path: mp3_output, cached: False }