承接 subhashladumor1/laravel-ai-video 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

subhashladumor1/laravel-ai-video

Composer 安装命令:

composer require subhashladumor1/laravel-ai-video

包简介

Laravel AI Video is a high-performance, multi-model AI video generator for Laravel AI SDK. Create text-to-video, image-to-video, marketing videos, social media reels, and multi-aspect ratio content using modern AI models like Runway, Stability, Pika, and OpenAI.

README 文档

README

Latest Version on Packagist License Total Downloads

Laravel AI Video is a comprehensive, production-ready package for generating cinematic AI videos. It acts as an orchestration layer, combining the best AI models for scripting, visuals, motion, and voice into a single, unified pipeline.

Whether you need to automate Social Media Reels, create Product Ads, or generate Storytelling Content, this package handles the complex workflow of chaining AI APIs and rendering the final output.

🌟 Features

  • 🎬 Multi-Model Orchestration ("Composed" Driver):
    • Scripting: OpenAI GPT-4o breaks prompts into cinematic scenes.
    • Visuals: OpenAI DALL-E 3 generates high-consistency scene images.
    • Motion: Runway Gen-4 Turbo / Leonardo Kling 2.1 brings images to life.
    • Voice: OpenAI TTS-1 adds synchronized voiceovers.
    • Rendering: FFmpeg merges everything with transitions and subtitles.
  • 🖼️ Image-to-Video: Support for animating images using Runway (Gen-4), Leonardo (Kling 2.1), or OpenAI (Sora).
  • 📱 Smart Templates: Built-in aspect ratios for Instagram/TikTok (9:16), YouTube (16:9), and Feeds (1:1).
  • 🛡️ AI Guard Integration: Prevents API bill shock by estimating costs before execution and strictly enforcing budgets.
  • ⚡ High-Performance Architecture:
    • Queue-based asynchronous processing.
    • Streams temporary files to avoid memory overflows.
    • Parallel execution where possible (dependent on driver).

🛠️ How It Works

The Composed Driver automates the entire video production lifecycle:

graph TD
    User[User Prompt] -->|1. Plan| Planner(Scene Planner / GPT-4o / Gemini 1.5)
    Planner -->|JSON Scenes| Manager{Video Manager}
    
    subgraph "Parallel Processing Per Scene"
        Manager -->|Describe| GenImg[Image Gen / DALL-E 3]
        GenImg -->|Image| Animate[Motion / Runway / Kling / Sora]
        Manager -->|Text| TTS[Voice / OpenAI TTS]
    end
    
    Animate -->|Video Clip| Renderer[FFmpeg Renderer]
    TTS -->|Audio Clip| Renderer
    Planner -->|Subtitles| Renderer
    
    Renderer -->|Merge & Render| Final[Final MP4 Output]
Loading

🚀 Installation

  1. Install via Composer:

    composer require subhashladumor1/laravel-ai-video
  2. Publish Configuration:

    php artisan vendor:publish --tag=ai-video-config
  3. Install FFmpeg: Ensure ffmpeg and ffprobe are installed on your server.

    # Ubuntu/Debian
    sudo apt update && sudo apt install ffmpeg
  4. Configure .env: Add your API keys. The package works best with multiple providers enabled.

    OPENAI_API_KEY=sk-...
    RUNWAY_API_KEY=...
    LEONARDO_API_KEY=...
    GEMINI_API_KEY=...
    
    # Enable the Budget Guard
    AI_VIDEO_GUARD_ENABLED=true

📖 Complete Usage Guide

1. Text-to-Video (The "Composed" Pipeline)

This is the most powerful feature. It creates a full video from a simple text prompt.

Basic Usage:

use Subhashladumor1\LaravelAiVideo\Facades\AiVideo;

$path = AiVideo::driver('composed')->textToVideo(
    "A cyberpunk detective walking through neon-lit rainy streets of Tokyo.",
    [
        'duration' => 15, // Total video duration (approx)
        'template' => 'youtube-short' // 9:16 Aspect Ratio
    ]
);

return response()->download($path);

Advanced Usage (Asynchronous Job): Recommended for production to avoid timeout issues.

use Subhashladumor1\LaravelAiVideo\Jobs\ProcessVideoJob;

ProcessVideoJob::dispatch(
    'text-to-video',
    "Create a 30-second commercial for a new eco-friendly coffee brand.",
    [
        'template' => 'instagram-reel', 
        'voice_id' => 'alloy',
        'style' => 'Cinematic, Warm Lighting, Slow Motion',
        'fps' => 30
    ],
    'composed'
);

2. Image-to-Video (Motion Generation)

Ideal for bringing product photography or static assets to life. Supports Runway, Leonardo, and Sora.

use Subhashladumor1\LaravelAiVideo\Facades\AiVideo;

// Using Runway Gen-4 Turbo
$videoPath = AiVideo::driver('runway')->imageToVideo(
    public_path('images/product-shoe.jpg'),
    [
        'prompt' => 'Cinematic slow motion, floating in air', // Text prompt required for control
        'duration' => 10,
        'model' => 'gen4_turbo'
    ]
);

// Using Leonardo (Kling 2.1)
$videoPath2 = AiVideo::driver('leonardo')->imageToVideo(
    public_path('images/portrait.jpg'),
    [
        'prompt' => 'Character smiles and waves',
        'model' => 'KLING2_1'
    ]
);

3. Scene Planning (Scripting Only)

Use the AI Director to break down a script into visual scenes without generating the video yet. Useful for UI previews.

$scenes = AiVideo::driver('openai')->generateScenes(
    "A history of the Roman Empire in 60 seconds."
);

// Returns:
// [
//    [
//      'scene_number' => 1,
//      'visual_description' => 'Aerial view of the Colosseum at sunset...',
//      'voiceover_text' => 'It began as a small city-state...',
//      'duration_seconds' => 5
//    ],
//    ...
// ]

4. Voiceover Generation (TTS)

Generate high-quality AI voiceovers directly.

$audioPath = AiVideo::driver('openai')->generateVoice(
    "Welcome to the future of video generation.",
    'nova', // Voice options: alloy, echo, fable, onyx, nova, shimmer
    ['model' => 'tts-1-hd']
);

🛡️ AI Guard & Cost Control

This package includes a Budget Enforcement System. It estimates the cost of every operation before it runs.

How to Configure: In config/ai-video.php:

'guard' => [
    'enabled' => true,
    'cost_limit_per_video' => 5.00, // Maximum USD per video
],

Usage Flow:

try {
    // This will throw an Exception if estimated cost > $5.00
    AiVideo::driver('composed')->textToVideo("An extremely long 1-hour movie description...");
} catch (\Exception $e) {
    // "Estimated cost $12.50 exceeds budget limit of $5.00"
    return back()->with('error', $e->getMessage());
}

📖 Function Reference

VideoDriver Interface

The Facade AiVideo::driver('name') returns an instance implementing these methods:

Method Description Options
textToVideo($prompt, $opts) Generates full video from text. duration, template, style
imageToVideo($path, $opts) Animates a static image. motion_bucket_id, seed
generateScenes($script) Returns array of scene objects. model (e.g., gpt-4o)
generateVoice($text, $voice) Creates MP3 audio from text. output_path, speed
estimateCost($type, $params) Returns float ($) cost estimate. input

Supported Templates

Templates control the Output Resolution and default styling.

Template Aspect Ratio Resolution Best For
youtube-standard 16:9 1920x1080 YouTube, TV, Desktop
youtube-short 9:16 1080x1920 Shorts, TikTok, Reels
instagram-reel 9:16 1080x1920 Instagram Stories/Reels
square-post 1:1 1080x1080 FB/Insta Feed, Product Ads
portrait 4:5 1080x1350 Mobile Feed

🏗️ Extending

You can create your own drivers by implementing Subhashladumor1\LaravelAiVideo\Contracts\VideoDriver.

namespace App\Drivers;

use Subhashladumor1\LaravelAiVideo\Contracts\VideoDriver;

class MyCustomDriver implements VideoDriver
{
    public function textToVideo(string $prompt, array $options = []): string
    {
        // Call your custom AI API here
        return 'path/to/video.mp4';
    }
    
    // implement other methods...
}

Register it in AppServiceProvider:

AiVideo::extend('custom', function ($app) {
    return new MyCustomDriver();
});

🧪 Testing

composer test

📄 License

The MIT License (MIT). Please see License File for more information.

subhashladumor1/laravel-ai-video 适用场景与选型建议

subhashladumor1/laravel-ai-video 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「video」 「laravel」 「ai」 「openai」 「stability」 「runway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 subhashladumor1/laravel-ai-video 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 subhashladumor1/laravel-ai-video 我们能提供哪些服务?
定制开发 / 二次开发

基于 subhashladumor1/laravel-ai-video 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-14