microsoft/VibeVoice · error · RuntimeError
ffmpeg returned empty audio data
Error message
ffmpeg returned empty audio data
What it means
In the Gradio ASR demo script, audio is decoded by shelling out to ffmpeg (subprocess.Popen with stdout=PIPE, stderr=DEVNULL) and reading float32 samples from stdout. If ffmpeg writes zero bytes, np.frombuffer yields an empty array and this RuntimeError fires. stderr is discarded, so ffmpeg's actual error message (bad file, no audio stream, unknown codec, missing ffmpeg) is invisible.
Source
Thrown at vllm_plugin/scripts/gradio_asr_demo_api_video.py:219
target_sr = target_sr or 16000
cmd = [
"ffmpeg", "-i", path,
"-f", "f32le", "-acodec", "pcm_f32le",
"-ac", "1", "-ar", str(target_sr),
"-"
]
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
audio_bytes, _ = process.communicate()
audio_data = np.frombuffer(audio_bytes, dtype=np.float32)
print(f"[DEBUG] ffmpeg loaded: shape={audio_data.shape}, sr={target_sr}")
print(f"[DEBUG] audio range: min={audio_data.min():.6f}, max={audio_data.max():.6f}")
# Check for silent audio
if len(audio_data) == 0:
raise RuntimeError("ffmpeg returned empty audio data")
if audio_data.max() == 0 and audio_data.min() == 0:
print(f"[WARNING] Audio appears to be completely silent!")
return audio_data, target_sr
except Exception as e:
raise RuntimeError(f"Failed to load audio: {e}")
def get_file_size_mb(file_path: str) -> float:
"""Get file size in MB."""
try:
return os.path.getsize(file_path) / (1024 * 1024)
except Exception:
return 0.0
def is_video_file(file_path: str) -> bool:
"""Check if the file is a video file based on extension."""View on GitHub (pinned to 94da20d98b)
Solutions
- Verify the file plays locally and has an audio stream: ffprobe -v error -select_streams a -show_entries stream=codec_type <file>.
- Pre-install/verify full ffmpeg builds (e.g. apt install ffmpeg or a static build with common codecs).
- Patch the script to capture stderr (stderr=subprocess.PIPE) and include it in the error for diagnosis.
- Pre-convert awkward sources to 24 kHz mono wav: ffmpeg -i in.mp4 -vn -ac 1 -ar 24000 out.wav, then feed out.wav.
Example fix
# before
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
audio_bytes, _ = process.communicate()
# after
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
audio_bytes, err = process.communicate()
if len(audio_bytes) == 0:
raise RuntimeError(f"ffmpeg returned empty audio data: {err.decode(errors='replace')[-500:]}") Defensive patterns
Strategy: validation
Validate before calling
import os, subprocess
def precheck_media(path: str) -> None:
assert os.path.getsize(path) > 0, "file is empty"
r = subprocess.run(
["ffprobe", "-v", "error", "-select_streams", "a",
"-show_entries", "stream=codec_type", "-of", "csv=p=0", path],
capture_output=True, text=True)
if "audio" not in r.stdout:
raise ValueError(f"{path} has no decodable audio stream: {r.stderr.strip()}") Type guard
def has_audio_stream(path: str) -> bool:
r = subprocess.run(
["ffprobe", "-v", "error", "-select_streams", "a",
"-show_entries", "stream=codec_type", "-of", "csv=p=0", path],
capture_output=True, text=True)
return "audio" in r.stdout Try / catch
try:
wave, sr = load_audio_ffmpeg(path)
except RuntimeError as e:
if "empty audio data" in str(e):
raise ValueError(f"{path} produced no audio; check file integrity and audio stream")
raise Prevention
- Capture ffmpeg stderr in your own loaders — DEVNULL hides the root cause.
- ffprobe every uploaded file for an audio stream before decode.
- Keep a full-featured ffmpeg on PATH in deployment images.
When it happens
Trigger: Passing a file ffmpeg cannot decode (corrupt download, DRM-protected media, unsupported container); a video with no audio stream so the -map selects nothing; ffmpeg not installed/failing to exec (though that raises differently); wrong stream-selection flags in cmd causing empty output; zero-length input file.
Common situations: Users dragging arbitrary web-downloaded media into the demo; .mp4 recordings from screen capture with muted audio track; systems where a minimal ffmpeg build lacks the needed codec (e.g. no libopus).
Related errors
- Failed to load audio: {e}
- load_audio_bytes_use_ffmpeg requires resample=True
- Unsupported file format: {file_ext}. Supported formats: .wav
AI-assisted analysis of microsoft/VibeVoice@94da20d98b (2026-08-15).
Data as JSON: /api/errors/e3c34993f55a1451.
Report an issue: GitHub.