IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

GeneratedMediaStore

GeneratedMediaStore

class max.serve.media.GeneratedMediaStore(root_dir, *, max_storage_bytes=536870912)

source

Bases: object

Stores generated media files for later download via HTTP.

Creating a store sets up the per-category media directories and the cache accounting that backs eviction.

Parameters:

  • root_dir (Path) – The root directory under which the per-category media subdirectories are created.
  • max_storage_bytes (int) – The maximum total size of stored assets, in bytes, defaulting to 512 MiB. Older assets are evicted to make room for new ones.

Raises:

ValueError – If max_storage_bytes is not greater than zero.

encode_video_content()

encode_video_content(content, frames_per_second)

source

Encode raw in-memory frames into an MP4 byte payload.

Parameters:

Return type:

bytes

get_audio()

get_audio(audio_id)

source

Return a stored audio asset by id if it still exists on disk.

Parameters:

audio_id (str)

Return type:

StoredMediaAsset | None

get_image()

get_image(image_id)

source

Return a stored image asset by id if it still exists on disk.

Parameters:

image_id (str)

Return type:

StoredMediaAsset | None

get_video()

get_video(video_id)

source

Return a stored video asset by id if it still exists on disk.

Parameters:

video_id (str)

Return type:

StoredMediaAsset | None

save_audio_content()

async save_audio_content(content)

source

Encode a raw waveform to WAV bytes and persist the result.

Raises:

ValueError – If the content carries no raw samples, or names a container this store cannot write.

Parameters:

content (OutputAudioContent)

Return type:

StoredMediaAsset

save_image_content()

async save_image_content(content)

source

Persist inline image content to disk and register it in the cache.

Parameters:

content (OutputImageContent)

Return type:

StoredMediaAsset

save_video_content()

async save_video_content(content, frames_per_second)

source

Encode raw video frames to MP4 bytes and persist the result.

Parameters:

Return type:

StoredMediaAsset