dsh-tool-media: Processing Local Media with ffmpeg in DeepSeek Harness

Preface

When running an Agent in DeepSeek Harness (DSH), once a task involves local video or audio, the model often has to guess based on the filename or context: how long it is, what codec is used, how big the file is. A wrong guess means rerunning transcoding or compression, wasting a round of conversation and compute resources. If ffmpeg is already installed locally, a more sensible approach is to let the Agent “ask first” before acting.

Below we introduce the community plugin dsh-tool-media (maintainer: yuehancn). It wraps local ffmpeg / ffprobe into six structured tools for DSH to call under desktop or web profile. It belongs to the “model inference” related extensions in the community directory; the directory page and the source code are independent, and it is not an official DeepSeek app store entry.

What Is This

dsh-tool-media is a self-built tool plugin for DeepSeek Harness: it does not replace ffmpeg, but turns common operations such as probing specifications, remuxing, extracting frames, extracting audio tracks, and compressing to a target size into fixed interfaces that an Agent can call.

The plugin’s README states it is built and tested against dsh 0.2.0-rc.2 (preview); the apply(ctx) plugin spec is relatively stable, but if you use a newer dsh version, verify it yourself. The npm package name is @yuehancn/dsh-tool-media, the version listed in the current material is 1.0.0, license MIT.

Core Functions: Six Tools

Before a long task, you can call media_status first to check whether ffmpeg / ffprobe are executable in PATH, their version info, and list available conversion targets, avoiding discovering that ffmpeg is not found locally only after a timeout.

media_probe(path) returns structured facts: duration, size, bitrate, container format, video stream (codec, resolution, frame rate, pixel format), audio stream (codec, sample rate, channel count), and stream count.

media_convert(path, target, ...) transcodes according to preset targets. The targets listed in the material include:

target container video codec audio codec
mp4-h264 mp4 libx264 aac
mp4-h265 mp4 libx265 aac
webm webm libvpx-vp9 libopus
gif gif gif —
mp3 / wav / aac / flac respective containers — corresponding codecs

Optional parameters include: width (scale proportionally and use even width/height), start and duration (trim a segment), crf (0–51, lower value means better quality), removeAudio (remove audio track).

media_frames(path, count | timestamps, format) extracts frames from a video. By default, frames are taken evenly across the entire duration (not just from the first few seconds); you can also pass explicit timestamps, e.g. "0,5,12.5".

media_audio(path, target, sampleRate, channels) exports the audio track. Default output is wav; if you need to do speech recognition afterwards, you can specify sampleRate=16000, channels=1.

media_compress(path, targetSizeMb, audioKbps, width) compresses by byte budget, rather than a simple quality tier. The implementation uses ffmpeg two-pass encoding so the output stays as close to the target size as possible without easily exceeding it. If the budget is too small, causing the calculated video bitrate to drop below 50 kbps, the plugin will directly throw an error, prompting you to relax the budget or trim the source material first, instead of silently producing an unusable file. The illustrative relationship in the README is as follows:

media_probe  →  duration 2:13 / 1920x1080 / h264 + aac / 48.2 MB
media_compress(targetSizeMb=10)  →  two-pass encoding, lands at 9.8 MB

Installation and Activation

The official one-line installation command is as follows (original from the material; desktop can be replaced with web):

dsh plugin --profile desktop add github:yuehancn/dsh-tool-media

Supported profiles are desktop and web. After installation, restart dsh to use the tools.

The local machine must be able to run ffmpeg and ffprobe. On Windows, the README suggests downloading the full build from gyan.dev, then after extracting, writing the bin directory into the config or adding it to PATH; as long as ffmpeg -version outputs the version, it is fine.

Configuration

In ~/.dsh/profiles/<profile>/cordis.patch.yml, you can add config for the plugin tool-media, e.g.:

# ~/.dsh/profiles/<profile>/cordis.patch.yml
- id: tool-media
  config:
    ffmpegPath: C:/AI/ffmpeg/ffmpeg-release-full/bin/ffmpeg.exe
    ffprobePath: C:/AI/ffmpeg/ffmpeg-release-full/bin/ffprobe.exe
    outputDir: C:/Users/you/Videos/media-output
    maxFrames: 60
field default description
ffmpegPath ffmpeg path to the ffmpeg executable
ffprobePath ffprobe path to the ffprobe executable
outputDir media-output output artifact directory
timeoutMs 900000 per-call timeout (15 minutes)
maxFrames 60 maximum number of frames extracted per call
probe / convert / frames / audio / compress / status true individual tools can be disabled as needed

Typical Usage Ideas

  1. Use media_status to confirm the environment, then call media_probe on the target file, writing duration, resolution, and codec into subsequent decisions.
  2. When you need to send to someone or upload to a platform with a human-set size limit, use media_compress with targetSizeMb, instead of repeatedly trying crf.
  3. When you need a cover image or a quick browse of the content, use media_frames to extract several frames evenly, or specify timestamps.
  4. Before speech transcription, use media_audio to export a 16 kHz mono wav.
  5. When the format is incompatible or you need webm / gif etc., use media_convert to select the corresponding target, optionally combined with trimming and scaling.

All the above steps are performed locally by spawning ffmpeg as a subprocess; the plugin README states it only uses spawn(command, argsArray), does not concatenate shell strings; the read/write scope is limited to the input files you specify and outputDir, with no upload and no network access; -y only applies to artifacts inside the output directory and will not overwrite source file paths.

Applicable Scenarios and Notes

This is suitable for developers who already handle local audio/video in their DSH workflow and want the Agent to structure-read metadata and perform transcoding. The plugin runs with the permissions of the current dsh process user; before installation, it is recommended to read the GitHub repository source code and the MIT license, confirming that the paths and output directories meet your security policy.

Community directory page: yuehancn/dsh-tool-media. The DSH ecosystem emphasizes “everything is a plugin”; directory sites such as SkillHub have no official affiliation with DeepSeek / High-Flyer; plugin quality and maintenance pace are subject to the repository and maintainer. The GitHub stars in the material are 0, which does not mean the functionality is unusable, only reflecting current attention.

Conclusion

dsh-tool-media replaces “guessing media specifications” with six reusable tool calls: probe first, then convert, extract frames, extract audio track, or compress by MB budget. If your Agent frequently deals with local ffmpeg tasks, you can install it via the command above, configure the paths, and restart dsh to try it out.

  • Directory page: https://www.skillhub.cn/plugins/yuehancn/dsh-tool-media
  • Source code and full documentation: https://github.com/yuehancn/dsh-tool-media
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye