Skip to main content

Baycone

Transcode videos into streaming-friendly MP4 with ffmpeg — as a Python library or a command.

Baycone turns a video file into an MP4 that plays everywhere and starts instantly: h264 or hevc video, AAC audio and the moov atom up front. It only re-encodes what needs it, picks the audio tracks you want and never leaves a half-written file behind.

This package is the pipeline behind the Baycone Docker image, which watches media libraries and processes new files automatically.

Features

  • Two-pass libx264 / libx265 encode to a target bitrate, never above the source's
  • Copies streams that are already within limits; a container mismatch alone is fixed by a remux
  • Scales down to fit 1920×1080 (configurable), crops black bars and tone maps HDR10 / HLG to SDR
  • Keeps the original audio language plus your preferred ones, one track per language at the preferred channel count
  • Extracts text subtitles to UTF-8 .srt files
  • Detects copies that were cut off, kills a hung ffmpeg, and resumes an interrupted encode from its second pass
  • Writes the output in one step after it is safely on disk; the input file is never modified

Requirements

  • Python 3.14
  • ffmpeg and ffprobe on PATH, built with libx264, libx265 and libzimg (most distribution builds are)

Installation

pip install baycone
# or, for the command only
uv tool install baycone

Command line

baycone-cli movie.mkv                          # result in _baycone_processed/movie.mp4 next to the input
baycone-cli movie.mkv --output /media/out.mp4
baycone-cli movie.mkv -l cze -l eng -v 1800    # audio languages in order, video bitrate in kbps
baycone-cli movie.mkv --codec hevc
baycone-cli movie.mkv --remux-only             # never encode, only remux into MP4
baycone-cli movie.mkv --info                   # print the analysis as JSON and exit
Flag Default Description
--output _baycone_processed/ Output file
--work-dir .baycone/cli/ Temporary files; the default one is removed afterwards
-l, --language original eng cze Audio language to keep, repeatable, in order
-v, --video-bitrate 2250 Target video bitrate in kbps
-a, --audio-bitrate 64 Target audio bitrate per channel in kbps
--codec h264 Target video codec, h264 or hevc
--subtitles none Subtitle language to extract to .srt, repeatable
--remux-only off Copy every stream, only remux into the target container
--info off Print the analysis as JSON and exit
--ffmpeg, --ffprobe ffmpeg, ffprobe Binaries to use

Exit codes: 0 success, 1 invalid arguments, 2 the file could not be processed.

Library

from pathlib import Path

from baycone import BayconeError, Encoder, EncodingSettings, Job

settings = EncodingSettings(target_video_bitrate=1800, target_audio_languages=["original", "eng"])
job = Job(input_file=Path("movie.mkv"), output_file=Path("out/movie.mp4"), work_dir=Path("work"))

try:
    Encoder(settings, on_progress=lambda step, percent: print(step, percent)).process(job)
except BayconeError as e:
    ...  # the input is untouched and no output is left behind
  • EncodingSettings holds every encoding setting: allowed codecs and containers, targets and limits.
  • Encoder.process() returns the output path or raises a BayconeError: InsufficientSpaceError before anything is written, InvalidFileError for an unreadable or truncated file, EncodingError when ffmpeg fails, and SourceChangedError when the input changed while it was processed.
  • Keep work_dir on the same filesystem as output_file, otherwise publishing has to copy the file.
  • Analyzer(settings).analyze(path) returns the analysis alone, without encoding anything.
  • The library logs through logging under baycone.* and configures no handlers. It is fully typed.

Released under the MIT License.

Metadata

Release files for baycone 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baycone 0.7.0
File Size Uploaded Provenance Actions
baycone-0.7.0.tar.gz 26.3 kB Without provenance Details for baycone-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for baycone 0.7.0
File Interpreter ABI Platform Actions
baycone-0.7.0-py3-none-any.whl Python 3 none any Details for baycone-0.7.0-py3-none-any.whl

Total release size: 53.4 kB

Release files / baycone-0.7.0.tar.gz

Download URL baycone-0.7.0.tar.gz
Size 26.3 kB
Tags Source
SHA-256 checksum
How to use checksums
348d14da442a1ca2b523b8c8685c28ce5c7dd0d97a4617681b44cc69c382a581
BLAKE2b-256 checksum
How to use checksums
428f78883726e96ab3041bf452121d825d9be073a326705089b2ad04069efc17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}

Release files / baycone-0.7.0-py3-none-any.whl

Download URL baycone-0.7.0-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baf4094b2bf6b823bd84a6eb72117abd9732c888ee65c47a6b6c090bf5059bb2
BLAKE2b-256 checksum
How to use checksums
ef7941f5b5a9b3bdc6a551c6d025368bce1324bf00223c22c31735ed302e53fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}

Security for baycone 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page