Skip to main content

Cxalio infrastructure library — core abstractions and utilities for post-production tooling.

Project description

cx-studio

语言 / Languages: 中文 | English

基础设施库,为影视后期自动化工具的开发提供通用组件。

安装

pip install cx-studio

要求 Python >= 3.12, < 3.15。

模块

core — 核心值对象

  • CxTime:SMPTE 时码解析与计算,支持 23.976 / 24 / 25 / 29.97 / 30 / 50 / 59.94 / 60 fps 等常见帧率。
  • FileSize:文件大小的类型化表示,支持 binary(KiB/MiB/GiB)与 international(KB/MB/GB)两种标准,提供 pretty_string() 人类可读输出。
  • TimeRange:时间区间运算,支持重叠检测、包含判断、时点与区间的关系判定。
  • Timebase:帧率抽象基类,预置常见帧率常量。

ffmpeg — FFmpeg 封装

  • FFmpeg:异步 FFmpeg 进程管理器。基于 pyee EventEmitter 的事件驱动设计,支持启动、中止与终止操作,自动解析 stderr 输出流,支持编码信息探测。
  • FFmpegError:带正则匹配的错误分类工厂。子类涵盖文件未找到、参数错误、不支持的编码器、可执行文件缺失、进程运行中冲突等场景。
  • FFmpegCodingInfo:编码信息值对象,包含编码器、时长、分辨率、比特率等字段。
  • FFmpegFilePathPreprocessor:路径预处理,处理引号兼容性与 Windows 路径适配。

filesystem — 文件系统工具

  • PathExpander:路径展开,支持通配符、环境变量和用户目录(~)。
  • CmdFinder:可执行文件查找,遍历 PATH 并检测有效后缀。
  • SuffixFinder:文件后缀匹配。
  • PathValidator / SuffixValidator / EmptyDirValidator / ExecutableValidator:路径验证链组件,支持组合与短路。
  • EncodingDetector:基于 chardet 的文本编码探测。

iotools — IO 工具

跨平台的子进程创建(Windows 下自动配置 CREATE_NEW_PROCESS_GROUP 以支持信号发送)、流式读写、字节流记录与重定向。

text — 文本工具

  • TagReplacer:模板标签替换系统,支持从对象属性、路径信息、环境变量等来源动态渲染文本。
  • auto_quote / auto_unquote:智能引号添加与去除。
  • random_string:随机字符串生成。
  • auto_list_text / auto_unwrap:文本按分隔符拆分与去换行。

number — 数值工具

  • NumberRange:带边界的数值范围对象,支持跨区间映射、百分比转换与 clamp 裁剪。
  • quick_clamp / quick_remap:便捷数值函数,功能类似 AE 表达式中的 clamp 与 remap。

system — 系统抽象

  • SystemType:平台枚举,区分 Windows / macOS / Linux / WSL / iOS / Android / FreeBSD。
  • is_user_admin:跨平台管理员权限检测。
  • opener:跨平台文件或 URL 打开(xdg-open / open / start)。
  • cross_runner:跨平台命令执行封装。

collectiontools — 集合工具

  • flatten_list:递归展平任意深度的嵌套可迭代对象。
  • iter_with_separator:在迭代元素间插入分隔符,适用于构建连接清单。
  • split_to_two:按谓词将序列拆分为两组。

i18n — 国际化

基于 gettext 的翻译基础设施,提供 _()_ng()(复数)函数。简体中文为源语言。

快速示例

from cx_studio.core import CxTime, FileSize, Timebase

# 时码解析
t = CxTime.from_str("01:23:45:12", rate=Timebase.fps_25)
print(t.total_frames)  # 124587

# 文件大小
fs = FileSize.from_bytes(1_234_567_890)
print(fs.pretty_string())  # "1.15 GiB" (binary)
print(fs.pretty_string(standard="international"))  # "1.23 GB"
from cx_studio.ffmpeg import FFmpeg

async def transcode():
    ff = FFmpeg(executable="/usr/bin/ffmpeg")
    await ff.run(["-i", "input.mp4", "output.avi"])

链接

返回项目首页:cx-studio-tk

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cx_studio-0.8.0.2.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cx_studio-0.8.0.2-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file cx_studio-0.8.0.2.tar.gz.

File metadata

  • Download URL: cx_studio-0.8.0.2.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cx_studio-0.8.0.2.tar.gz
Algorithm Hash digest
SHA256 288efec7f5a14a0c4447cb91d545ca2e3cede6dd761f8cf9fadab996930b8d42
MD5 f94925fa82692dd075991dc43130e156
BLAKE2b-256 55b7bc5fca3ff56ea427bcb27a32701a54a7bd5182b2d0b3b70868ecfcd57348

See more details on using hashes here.

File details

Details for the file cx_studio-0.8.0.2-py3-none-any.whl.

File metadata

  • Download URL: cx_studio-0.8.0.2-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cx_studio-0.8.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b85fa5e74f2958b8c2d2e256ef320ea018417e3fa9f5f311c31158bbd97af207
MD5 13d9549bbc0fb10bd5b5560cd48bb23c
BLAKE2b-256 040d411da7c27c01f0aef55dd7b967303d00852a17f6a3ce874951d497216174

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page