Skip to content

Studio: offer video input only when llama-server can launch ffmpeg and ffprobe - #16094

Merged
danielhanchen merged 4 commits into
mainfrom
studio-video-needs-ffmpeg
Oct 30, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
studio-video-needs-ffmpeg

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Fixes #16065

Problem

llama-server decodes chat video by launching the ffmpeg and ffprobe executables (from --video-ffmpeg-dir, else PATH), but its /props reports the video modality for every vision projector without checking that either tool exists. Studio copies that flag into has_video_input, so on a machine without ffmpeg (the usual case for Unsloth Desktop on Windows) the composer accepts the clip and every send fails with an opaque

E probe: failed to launch ffprobe
E mtmd_helper_video_init_from_buf: ffprobe failed on buffer (is ffprobe in PATH?)
llama-server returned 400: {"error":{"code":400,"message":"Failed to load image or audio file"}}

has_video_input is documented as "False unless the mmproj, the build and ffmpeg all support it", and the frontend already has the message for that case ("... a llama.cpp build with video enabled and ffmpeg installed on this machine ..."); only the ffmpeg part was never checked.

Fix

After the load reads /props, keep video on only when the spawned llama-server can actually launch both tools, resolved the way llama.cpp resolves them: --video-ffmpeg-dir from the launched argv, else LLAMA_ARG_VIDEO_FFMPEG_DIR, else the child's PATH (on Windows also the binary's folder and the working directory, which CreateProcess searches). When they are missing the load logs one warning and the user gets the existing "cannot accept video" message at attach time instead of a failed request. Hosts with ffmpeg see no change. No UI, flow or install change.

Verification

Real Studio load_model with the reporter's llama.cpp prebuilt (b11980-mix-a794a53, linux-x64-cpu) and a small vision GGUF (SmolVLM-256M + mmproj), a 2 s mp4:

Arm PATH /props video has_video_input Clip sent
main no ffmpeg True True 400 Failed to load image or audio file
this PR no ffmpeg True False refused at attach time with the existing ffmpeg message
this PR ffmpeg on PATH True True decoded, prefill runs
this PR no ffmpeg, --video-ffmpeg-dir /usr/bin True True decoded, prefill runs

tests/test_video_needs_ffmpeg.py: resolution rules (PATH, flag, env var, flag beats env) plus load-path cases; the load-path "no ffprobe" case fails with the gate removed.

@danielhanchen danielhanchen self-assigned this Oct 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T09:59:19.579799Z d849e75 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41b3fff81a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

bin_dir = bin_dir or source.get("LLAMA_ARG_VIDEO_FFMPEG_DIR")
names = ("ffmpeg.exe", "ffprobe.exe") if sys.platform == "win32" else ("ffmpeg", "ffprobe")
if bin_dir:
return all(os.path.isfile(os.path.join(bin_dir, name)) for name in names)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check executable permissions for explicitly configured tools

On Linux and macOS, if --video-ffmpeg-dir or LLAMA_ARG_VIDEO_FFMPEG_DIR points to files without execute permission, this branch still enables video because os.path.isfile() only checks existence. I reproduced the helper returning True for two mode-0644 tools while launching ffprobe raises PermissionError. Users with such an installation will still be offered video attachments and encounter the opaque request failure this change is intended to prevent. Check executability as well as file existence, consistently with the PATH branch.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d849e75: the explicit dir now goes through shutil.which like PATH does, so non-executable tools no longer count; test added.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: d849e75ce7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Oct 30, 2026
@danielhanchen
danielhanchen merged commit 4e799e0 into main Oct 30, 2026
3 of 50 checks passed
@danielhanchen
danielhanchen deleted the studio-video-needs-ffmpeg branch October 30, 2026 10:24
@danielhanchen danielhanchen mentioned this pull request Oct 30, 2026
1 task done
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 2, 2026
…with the ffmpeg llama-server uses (unslothai#16098)

Follow-up to unslothai#16094 (which closed unslothai#16065).

- A video request to a model whose `/props` advertises video, but where llama-server can't find ffmpeg/ffprobe, now gets a 400 naming FFmpeg instead of the generic "cannot take video input".
- Clip preprocessing uses the selected `--video-ffmpeg-dir` when available and receives the running server's prepared loader environment. Otherwise it retains normal executable lookup.
- A build confirmed to lack `--video-ffmpeg-dir` ignores `LLAMA_ARG_VIDEO_FFMPEG_DIR`, and the reachability check follows that behavior. An inconclusive probe preserves the inherited override.
- `supports_video_ffmpeg_dir` is probed from `--help`. A confirmed supported build can receive an automatically found folder on POSIX; Windows keeps native application-directory search precedence. Inconclusive probes preserve explicit and inherited overrides.

Edge cases run on macOS against a real llama-server with Homebrew ffmpeg: ffmpeg on PATH, no ffmpeg, ffmpeg and ffprobe in different folders, a user's own `--video-ffmpeg-dir` or env var, and a build without that flag.

<!-- video-ffmpeg-evidence:start -->
### API Monitor before and after

Merge base `6fe27d2c5` versus corrected head `19b224260`. API Monitor now names llama-server's FFmpeg search path and explains how to correct a configured override. Both sides use independently built Studio installs with the same injected loaded video GGUF state; authentication, the HTTP request, rejection, monitor recording, and frontend rendering are real. This fixture checks the visible error and performs no model inference.

![API Monitor: generic video refusal before, FFmpeg search-path and override guidance after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16098/pr16098_19b224260-a9195a76435f.png)

The follow-up fixes preserve native Windows executable lookup and application-directory precedence, inherited overrides after an inconclusive help probe, directory whitespace, and the running server's prepared loader environment during preprocessing. Native Windows controls reproduce the earlier lookup and precedence failures; the corrected head keeps both behaviors working.
<!-- video-ffmpeg-evidence:end -->
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] LFM3-Omni Video Input Fails

1 participant