Skip to main content

GPL H.264 encoder worker for Spiral production video transcoding

Project description

spiral-h264

spiral-h264 is the GPL encoder worker for Spiral video transcoding. It uses the patched x264 fork as a git submodule and exposes a narrow CLI that accepts raw Y4M frames plus a JSON encode schedule, then emits an Annex B H.264 stream and JSONL sample metadata.

The user-facing APIs, frame graph selection, ffmpeg orchestration, MP4 muxing/packing, indexing, and Spiral expressions live in pyspiral / SpiralDB. This package should stay limited to the x264 encode boundary.

It deliberately does not demux source containers, run ffmpeg, mux MP4, pack prefix-readable artifacts, or build Spiral indexes. Those steps stay in the permissive SpiralDB/pyspiral codebase.

CLI

spiral-h264 encode-y4m \
  --config encode.json \
  --annex-b out.h264 \
  --metadata samples.jsonl \
  < input.y4m

--input-y4m path may be used instead of stdin.

The config JSON is intentionally small and mirrors x264 encoder controls plus the scheduled frame IR:

{
  "frame_ir": "schedule.json",
  "keyint": 120,
  "keyint_min": 120,
  "bframes": 15,
  "crf": 25,
  "preset": "medium",
  "scenecut": 0,
  "b_adapt": 0,
  "b_pyramid": "normal",
  "open_gop": false,
  "rc_lookahead": 40,
  "threads": 4,
  "x264_extra_params": "weightp=0:mbtree=0",
  "x264_layer_qps": "0=22,1=23,2=24,3=30,4=34"
}

samples.jsonl starts with one stream record, followed by one record per sample:

{"type":"stream","width":1280,"height":720,"fps_num":30,"fps_den":1}
{"type":"sample","sample_index":0,"byte_offset":693,"byte_len":1312,"pts":0,"dts":0,"duration":1,"is_keyframe":true,"picture_type":1,"display_frame":0,"decode_order":0,"temporal_layer":0,"max_ref_layer":0,"frame_id":0}

Development

git submodule update --init --recursive
cargo test
cargo run -- encode-y4m --help
maturin build --features python
python scripts/check_cargo_licenses.py

ffmpeg is not bundled. SpiralDB/pyspiral is responsible for invoking system ffmpeg to produce Y4M input.

Publishing

Cargo.toml is the single source of truth for the package version. The Python package version is dynamic in pyproject.toml, and maturin derives it from the Cargo package metadata.

PyPI publishing uses GitHub Actions Trusted Publishing / OIDC. No PyPI API token is stored in GitHub. Publishing runs from .github/workflows/publish.yml when a GitHub release is published, or manually through workflow_dispatch.

Configure the PyPI project trusted publisher with:

  • PyPI project: spiral-h264
  • Owner: spiraldb
  • Repository: spiral-h264
  • Workflow: publish.yml
  • Environment: pypi

Release process:

  1. Bump version in Cargo.toml.
  2. Merge the release change after CI is green.
  3. Create and publish a GitHub release tagged vX.Y.Z, matching the Cargo.toml version exactly.
  4. The publish workflow validates the tag/version match, builds macOS and manylinux wheels, builds an sdist that includes the x264 submodule source, then publishes with pypa/gh-action-pypi-publish using job-level id-token: write.

Manual workflow_dispatch is intended only for dry-run validation of the build graph; normal PyPI releases should go through a GitHub release tag.

License

This repository is GPL-2.0-or-later because it statically links the patched x264 source under third_party/x264.

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

spiral_h264-0.1.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

spiral_h264-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

spiral_h264-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (903.5 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file spiral_h264-0.1.0.tar.gz.

File metadata

  • Download URL: spiral_h264-0.1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spiral_h264-0.1.0.tar.gz
Algorithm Hash digest
SHA256 351f8efccf264546b52f390670b5f271edcb71a96e33b7f47e1f3f8b87a97aa4
MD5 9f82246816a2a45acfdc3d37f2b39b60
BLAKE2b-256 a1e4d26e9b7b0828bdb108df41aa164295ecc24a1fcf19dfea36152bb91d48bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for spiral_h264-0.1.0.tar.gz:

Publisher: publish.yml on spiraldb/spiral-h264

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spiral_h264-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for spiral_h264-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15f7d18a2852c4bce0c9e7a2dbe228973982e05361086a1a85cd9252729f04c0
MD5 4ec9ecb2daa276df82af9cdad9c6171b
BLAKE2b-256 383cd90eb75218679dd8a33dbfb34b34bf2432b8bd7f5caf273d7e20390234ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for spiral_h264-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on spiraldb/spiral-h264

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spiral_h264-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spiral_h264-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e8fe0a2906da18c7fc828bf1542dafda4c9438bafe9b0b44428b1ef73f68989
MD5 f05d71c436c3276de49d8d1e8646a4ee
BLAKE2b-256 2b27a01f867345253a30e7821e939a0b8ee64429a1072ac99ada6b44a1dcae41

See more details on using hashes here.

Provenance

The following attestation bundles were made for spiral_h264-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on spiraldb/spiral-h264

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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