三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

视频硬件压缩_cli-anything-quietshrink

视频硬件压缩_cli-anything-quietshrink

以下为本文档的中文说明

Quietshrink 是一个充分利用 Apple Silicon 芯片硬件视频编码加速能力的视频压缩工具,能够在几乎零 CPU 占用的情况下大幅压缩 macOS 屏幕录制文件的体积。该工具的核心技术优势在于使用 Apple Silicon 芯片内置的 Media Engine 专用硬件 HEVC 编码器进行视频编码,而不是通过 CPU 进行软件编码,因此在编码过程中电脑风扇保持安静,CPU 资源几乎不受影响,用户可以继续进行其他工作。使用场景非常明确:当用户需要压缩屏幕录制、屏幕广播或任何 mov 和 mp4 格式的视频文件以便于通过网络分享时;当视频文件体积过大无法通过聊天工具、电子邮件附件或 GitHub 上传限制发送时;当需要在保持视觉无损的前提下大幅减小文件体积以节省存储空间时。该工具特别适合在配备 Apple Silicon 芯片的 Mac 电脑上使用,效果最佳,但在非屏幕内容如摄像头拍摄的视频或 Vlog 上效果有限,因为这类内容缺少可丢弃的重复帧。核心特点与原则包括:第一,纯硬件加速编码——利用 Apple Silicon 的专用媒体引擎进行 HEVC 编码,CPU 占用率极低,编码过程安静无声,不影响其他工作。第二,显著的压缩效果——通常可将文件体积减小百分之七十到九十,同时保持视觉无损的观看体验。第三,多种质量预设方案——提供 tiny 最小体积模式约百分之九十压缩率、balanced 平衡模式约百分之八十八、transparent 透明模式默认设置视觉无损约百分之八十七和 pristine 接近原始质量模式约百分之八十四,适应不同使用场景需求。第四,结构化 JSON 输出——支持 json 标志参数,返回输入输出文件大小、节省空间百分比、编码速度等完整结构化数据。第五,前置检查机制——提供 doctor 命令验证运行环境是否完备,probe 命令检查待处理文件的详细编码信息。


quietshrink — Agent Skill

You have access tocli-anything-quietshrink, a CLI for compressing video files on macOS Apple Silicon. It uses the Media Engine (hardware HEVC encoder), not the CPU, so encoding is fast and silent.

When to use it

  • User wants to compress a screen recording, screencast, or any .mov/.mp4 file
  • File is too large to share (chat, email, GitHub)
  • Need smaller files but cannot tolerate visible quality loss
  • Apple Silicon Mac (M1/M2/M3/M4) — best results

Don’tuse this on non-screen content (camera footage, vlogs) — savings will be much smaller because there are no duplicate frames to drop.

Commands

# Compress with default transparent qualitycli-anything-quietshrink compress<input>[output]# Compress with specific presetcli-anything-quietshrink compress-qtiny<input># smallestcli-anything-quietshrink compress-qtransparent<input># default, visually losslesscli-anything-quietshrink compress-qpristine<input># near-source quality# Inspect a file before compressingcli-anything-quietshrink probe<input># List quality presetscli-anything-quietshrink presets# Verify environmentcli-anything-quietshrink doctor

All commands accept--jsonfor machine-readable output.

Quality presets

PresetqTypical reductionSSIMUse case
tiny50~90%~0.95Chat/email — small artifacts OK
balanced55~88%~0.99Docs/sharing — high quality
transparent(default)60~87%~0.99+Anything important— visually lossless
pristine70~84%~0.997Archival — near-source

JSON output schema

compressreturns:

{"input":"/path/to/input.mov","output":"/path/to/output.mov","input_size":105952129,"output_size":12345678,"saved_bytes":93606451,"saved_percent":88.3,"duration_seconds":193.3,"elapsed_seconds":87,"encoding_speed":"2.2x","quality_preset":"transparent","q_value":60,"gop":600}

probereturns:

{"path":"...","size_bytes":105952129,"size_mb":101.04,"codec":"h264","width":3024,"height":1964,"framerate":"120/1","duration_seconds":193.31}

Decision flow for agents

User wants to share a recording ├─ Is it on Apple Silicon Mac? → use quietshrink │ ├─ For chat/email/quick share → -q tiny │ ├─ For docs/important sharing → -q transparent (default) │ └─ For archival/editing → -q pristine └─ Not on Mac? → falls back to software, less efficient

Before processing, rundoctorto verify environment.
For unfamiliar files, runprobeto understand resolution/codec/duration.

Errors and recovery

  • ffmpeg not foundbrew install ffmpeg
  • hevc_videotoolbox not availablebrew reinstall ffmpeg
  • compression_failed→ check input file isn’t corrupted; try--verbosemode to see ffmpeg errors

Source

  • Main repo: https://github.com/achiya-automation/quietshrink
  • Bash CLI:quietshrinkcommand (via the install script)
  • Why this approach works: see WHY.md
← 返回列表