Skip to content

fix(api): bound transcribe_audio's ffmpeg calls with QWEN_MM_FFMPEG_TIMEOUT - #71

Merged
JJJYmmm merged 2 commits into
QwenLM:mainfrom
Lesereingrape:fix/asr-honours-ffmpeg-timeout
Oct 1, 2026
Merged

JJJYmmm merged 2 commits into
QwenLM:mainfrom
Lesereingrape:fix/asr-honours-ffmpeg-timeout

Conversation

@Lesereingrape

Copy link
Copy Markdown
Contributor

Closes #70

What changed

transcribe_audio was the only ffprobe/ffmpeg call site in the api capability that ignored
QWEN_MM_FFMPEG_TIMEOUT, which src/shared/env.py:252 documents as "ffmpeg/ffprobe timeout
seconds"
.

Two lines in src/capabilities/api/qwen_mm_plugins_api/others/asr.py:

  • _get_duration() now passes timeout=FFMPEG_TIMEOUT, so the duration probe is bounded the way
    every probe in shared/video.py:76,124,213 and omni-video2note's pipeline/media.py already
    is. Before this, subprocess.run got no timeout argument, so a media read that stalls — a
    dead mount, a truncated stream — hung the tool with nothing an operator could do.
  • _extract_audio() now passes timeout=max(FFMPEG_TIMEOUT, 600) instead of a bare 600, so
    raising the knob widens this call too.

Why the 600 floor on extraction: a chunk of a one-hour recording legitimately outlives the 120 s
probe default, so handing the transcode the bare knob would silently cut a budget it never had and
break working setups. max() is the shape pipeline/media.py:269,433 already use for long
transcodes: the knob can only widen this call, never narrow it.

Why the scope stops at this file. The unbounded renders in omni-chatcut's
music_to_mv/pipeline.py and the video-edit skill scripts are a different decision — several of
them (-count_frames, blackdetect, silencedetect) are expected to run for many minutes, so
they need per-site floors rather than a probe default. That belongs in its own issue, not folded
in here.

Verification

tests/test_api_tools.py::test_asr_media_calls_honour_ffmpeg_timeout (2 params) records the
kwargs reaching subprocess.run:

  • On main at 7f7ca38: 2 failed — actual [('ffprobe', 'NO TIMEOUT'), ('ffmpeg', 600)]
    against expected [('ffprobe', 42|900), ('ffmpeg', 600|900)].
  • On this branch: 2 passed; tests/test_api_tools.py as a whole 53 passed, 6 skipped.
  • Full offline gate python -m pytest -q -m "not reachability", same host (Windows, no ffmpeg
    installed), both trees run sequentially: pristine main 32 failed, 1028 passed, 97 skipped, 2 errors; this branch 32 failed, 1030 passed, 97 skipped, 2 errors. The two failure lists
    differ by exactly two entries — test_isolated_worker_timeout (fails on either tree when run
    alone, with PermissionError) and test_mhs_adapter_server::…[application/json] (passes on
    either tree alone) — which swap places between the runs. Neither file imports asr.
  • ruff check and ruff format --check on both changed files: clean.

The test stubs asr.subprocess rather than shelling out, so it also holds on a runner with no
ffmpeg binary — the same constraint behind #59.

Not tested: no live ffmpeg run and no DashScope call was made here (this machine has no ffmpeg
installed, so the numbers above come from the stub, and the TimeoutExpired path has not been
observed against real media).

Compatibility

  • Existing MCP tool names, inputs, and outputs are unchanged, or the change is explained above.
    transcribe_audio's schema and success output are untouched; the only new outcome is a
    subprocess.TimeoutExpired on a probe that previously hung forever — the same failure shape as
    the existing RuntimeError("ffprobe failed: …") from this function, which handle() does not
    catch either.
  • Tests and documentation were updated where behavior changed.
  • No credentials, private media, generated artifacts, or machine-specific configuration are
    included.

plugin-versions.json is untouched — tell me if a bugfix like this should carry a version bump.

…IMEOUT

_get_duration() ran ffprobe with no `timeout` argument at all, so a media read
that stalls -- a dead network mount, a truncated stream -- hangs the
transcribe_audio tool indefinitely with nothing the operator can do about it.
_extract_audio()'s hardcoded 600 ignored the knob in both directions, so
raising QWEN_MM_FFMPEG_TIMEOUT could not widen it either.

shared/env.py documents QWEN_MM_FFMPEG_TIMEOUT as "ffmpeg/ffprobe timeout
seconds", and every media subprocess in shared/video.py and in omni-video2note's
pipeline passes it; asr.py was the only ffprobe/ffmpeg call site in the api
capability that did not.

The probe now takes the knob directly, like the other probes. Extraction takes
max(FFMPEG_TIMEOUT, 600), the shape media.py already uses for long transcodes: a
chunk of a one-hour recording legitimately outlives the 120s default, so the knob
widens this budget without ever shortening the 600s it already had.

The regression test stubs asr.subprocess rather than shelling out, so it also runs
on hosts with no ffmpeg binary (the reason behind QwenLM#59).
@JJJYmmm
JJJYmmm merged commit b26320d into QwenLM:main Oct 1, 2026
4 checks passed
@JJJYmmm

JJJYmmm commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

TY! (btw you just need to fix the bugs, I'll handle the plugin version😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] transcribe_audio hangs forever: its ffprobe call has no timeout and QWEN_MM_FFMPEG_TIMEOUT is ignored

2 participants