adachsoft/video-generation-minimax

MiniMax video generation adapter for AdachSoft video-generation-contracts.

Maintainers

Package info

gitlab.com/a.adach/video-generation-minimax

Issues

pkg:composer/adachsoft/video-generation-minimax

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-03-22 18:48 UTC

This package is not auto-updated.

Last update: 2026-03-23 16:00:42 UTC


README

MiniMax video generation adapter for the adachsoft/video-generation-contracts package.

This library provides a concrete implementation of a video generation client that talks to the MiniMax API and conforms to the shared video-generation-contracts DTOs and interfaces.

Features

  • Simple MiniMax video generation client built on top of Guzzle.
  • Text-to-video and image-to-video support via shared DTOs.
  • Ready-to-use CLI script for quick video generation:
    • --img to provide an input image (URL or local file),
    • --text or positional prompt argument,
    • --duration to control the length of the generated video (in seconds).
  • Factory for creating a configured MinimaxVideoGenerator instance.
  • Webhook handler for MiniMax callbacks.

Installation

Use Composer to install the package:

composer require adachsoft/video-generation-minimax

This library targets modern PHP 8.x and relies on:

  • adachsoft/video-generation-contracts
  • adachsoft/collection
  • guzzlehttp/guzzle

For development and running the CLI locally you will also typically use:

  • vlucas/phpdotenv for loading .env files.

Configuration

The MiniMax API key is read from the MINMAX_KEY environment variable. The recommended way is to store it in a local .env file in your project root:

MINMAX_KEY=your-minimax-api-key

When using the provided bin/cli script, the .env file is loaded automatically (if present) using vlucas/phpdotenv.

CLI usage

This repository ships with a simple CLI helper script in bin/cli which you can use to quickly generate a video using the MiniMax API.

Basic usage:

php bin/cli [--img IMAGE_URL_OR_PATH] [--text PROMPT] [--duration SECONDS] [prompt] [output-file.mp4]

Options and arguments:

  • --img IMAGE_URL_OR_PATH (optional)
    • HTTP(S) URL or local path to an image.
    • Local paths are loaded and converted to a data URL (base64) before being sent to MiniMax.
  • --text PROMPT (optional)
    • Text prompt used for video generation.
    • If omitted, the first positional argument is treated as the prompt.
  • --duration SECONDS (optional)
    • Length of the generated video in seconds.
    • Must be a positive integer.
    • Defaults to 6 seconds when not provided.
  • prompt (positional, optional if --text is used)
    • Prompt text when you do not use --text.
  • output-file.mp4 (positional, optional)
    • Output filename for the generated video.
    • When omitted, a timestamp-based filename is generated automatically.

The resulting file is saved in the var/data directory inside the project root.

CLI examples

Text-to-video with default duration (6 seconds):

php bin/cli --text "A futuristic city skyline at night" output.mp4

Image-to-video with explicit duration:

php bin/cli \
    --img ./examples/input.jpg \
    --text "Camera slowly zooming in" \
    --duration 12 \
    ./output/zoom_in.mp4

Using only positional arguments (prompt and output file):

php bin/cli "Colorful particles swirling in space" particles.mp4

Programmatic usage

If you want to integrate MiniMax video generation directly into your application, use the MinimaxVideoGeneratorFactory and DTOs from adachsoft/video-generation-contracts.

<?php

declare(strict_types=1);

use AdachSoft\VideoGenerationContracts\Dto\VideoRequestDto;
use AdachSoft\VideoGenerationContracts\Enum\VideoAspectRatioEnum;
use AdachSoft\VideoGenerationContracts\Enum\VideoFormatEnum;
use AdachSoft\VideoGenerationContracts\Enum\VideoQualityEnum;
use AdachSoft\VideoGenerationMinimax\Factory\MinimaxVideoGeneratorFactory;

$apiKey = getenv('MINMAX_KEY');

$generator = MinimaxVideoGeneratorFactory::create(
    apiToken: $apiKey,
);

$request = new VideoRequestDto(
    format: VideoFormatEnum::Mp4,
    aspectRatio: VideoAspectRatioEnum::Landscape,
    quality: VideoQualityEnum::Standard,
    durationSeconds: 6,
    prompt: 'A simple prompt',
);

$job = $generator->generate($request);

// Poll for status, then fetch the result using the generator

You can extend this basic example with input media (image or video) by constructing an InputMediaCollection and passing it to VideoRequestDto.

Testing

This project uses PHPUnit and PSR-4 autoloading for tests under the AdachSoft\\VideoGenerationMinimax\\Tests namespace.

Typical test run:

vendor/bin/phpunit

License

This library is released under the MIT License. See the LICENSE file for details.