video_helper.cli module
Video Helper — command-line interface.
The package’s single command line: a thin dispatch over the pure functions
in video_helper.main, exposing the whole toolkit as subcommands of
one video-helper entry point. Built with click, which is a core
dependency — the CLI is not an optional surface.
Subcommands
validate— probe a video file / URL for validity (boolean)dimensions— dump width/height/duration/frame_rate/has_sound as JSONduration— print the duration in seconds of a videoconvert— re-encode / resize / drop audiochunk— extract a[start, end]sliceblack— synthesize a silent solid-black clipcompress— two-pass compress to a target file sizeimage-loop— loop a still image into a silent clipconcat— concatenate several videos head-to-tailoverlay— overlay a still image on a video (watermark / cursor)extract-audio— dump the audio track of a videomux-audio— mux a separate audio track onto a videoburn-subs— burn.srt/.vtt/.assinto the framessrt2vtt— SRT → WebVTT with color-preserving CSSextract-frames— stream frames to disk (one PNG per sampled frame)extract-flow— dense optical flow: HSV-visualization video or raw.npy
Design notes
Flags are spelled
--input/--output/ … rather than in the more idiomatic click positional style: the HTTP and MCP surfaces name their parameters the same way, so one vocabulary covers all of them.A library exception is caught by
main()(the console-script entry point) and printed as one cleanError: ...line + exit 1, instead of a raw Python traceback.
Usage Example
>>> # video-helper validate --input clip.mp4
>>> # video-helper dimensions --input clip.mp4
>>> # video-helper duration --input clip.mp4
>>> # video-helper convert --input in.mov --output out.mp4 --width 640 --height 480
>>> # video-helper chunk --input in.mp4 --start 10 --end 20 --output cut.mp4
>>> # video-helper black --duration 3 --width 1920 --height 1080 --output buffer.mp4
>>> # video-helper image-loop --image title.png --duration 4 --output title.mp4
>>> # video-helper concat --inputs a.mp4 b.mp4 c.mp4 --output final.mp4
>>> # video-helper overlay --input clip.mp4 --image logo.png --output marked.mp4
>>> # video-helper extract-audio --input clip.mp4 --output audio.wav
>>> # video-helper mux-audio --input silent.mp4 --audio voice.wav --output final.mp4
>>> # video-helper burn-subs --input clip.mp4 --subs subs.srt --output captioned.mp4
>>> # video-helper srt2vtt --input subs.srt
>>> # video-helper extract-frames --input clip.mp4 --output-dir frames/ --frame-step 5
>>> # video-helper extract-flow --input clip.mp4 --output clip-flow.mp4 --method dis
- video_helper.cli.main()[source]
Console entry point (
video-helper).Click’s own dispatch only special-cases
ClickException/Abort(and a broken pipe); a plain library exception (e.g. fromvideo_converter()) would otherwise propagate as a raw Python traceback instead of a clean CLI error. This wraps the whole invocation and translates that last case into a one-line stderr message + exit 1 — click’s own control flow (usage errors,--help, an explicitsys.exit(1)in a subcommand) already raisesSystemExit, aBaseExceptionthis does not catch, so it passes through untouched.- Return type:
None