Metadata-Version: 2.5
Name: trytond_mediaserver_encoding
Version: 8.0.0.1
Summary: Media Server Encoding
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: encoding,media,server,transcoding,tryton
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.10
Requires-Dist: trytond-mediaserver<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Mediaserver Encoding
====================

The ``mediaserver_encoding`` module provides video encoding and transcoding
pipeline management for the Tryton mediaserver.

Features
--------

- **Encoding Profiles**: Define resolution, codec, bitrate, and container
  format presets (e.g. 1080p H.264, 720p H.265, 480p web).
- **Encoding Jobs**: Queue-based encoding tasks with state tracking
  (pending, running, done, failed, cancelled).
- **Encoded Files**: Output files linked to profiles, stored in a
  hash-based storage tree.
- **ffmpeg Integration**: Encoding is performed via ffmpeg subprocess calls
  with progress tracking and log capture.
- **Cron Processing**: A cron job automatically processes pending encoding
  jobs from the queue.
- **Wizard**: A wizard allows selecting a media file and multiple profiles
  to create encoding jobs in bulk.
- **HLS Adaptive Streaming**: Support for multi-bitrate HLS output with
  master playlist generation.
- **Two-Pass Encoding**: Optional two-pass encoding for better bitrate
  distribution.

Configuration
-------------

The module uses the ``[mediaserver]`` configuration section:

- ``storage_dir``: Root directory for the hash-based storage tree.
  Falls back to ``media_dir/encoded`` if not set.
- ``media_dir``: Used as fallback for storage directory.
- ``delete_files_on_delete``: Whether to delete physical files when
  records are deleted (default: True).

Requirements
------------

- ``ffmpeg`` and ``ffprobe`` must be installed and available in the
  system PATH.

Models
------

- ``mediaserver_encoding.profile`` — ``EncodingProfile``: codec, bitrate,
  resolution, and container format preset (MP4, WebM, MKV, or HLS) with
  optional two-pass encoding.
- ``mediaserver_encoding.job`` — ``EncodingJob``: workflow-based encoding
  task (``pending`` → ``running`` → ``done`` / ``failed`` / ``cancelled``)
  with progress tracking and ffmpeg log capture.
- ``mediaserver_encoding.encoded_file`` — ``EncodedFile``: an output file,
  HLS segment, or manifest produced by an encoding job, stored in a
  hash-based tree.
- extends ``mediaserver.media_file`` — adds ``encoding_jobs`` and
  ``encoded_files`` ``One2Many`` fields and cascades physical file
  deletion to encoded files.

Cron Jobs
---------

- ``cron_encoding_queue``: runs every 5 minutes and calls
  ``mediaserver_encoding.job|process_queue`` to process pending encoding
  jobs from the queue.

Wizards
-------

- ``EncodingWizard``: select a media file and one or more active encoding
  profiles to create encoding jobs in bulk.  An optional flag generates an
  HLS master playlist referencing all variant streams for adaptive
  streaming when all selected profiles use the HLS container format.
