sonphoenix/laravel-video-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sonphoenix/laravel-video-tools

最新稳定版本:0.1.0

Composer 安装命令:

composer require sonphoenix/laravel-video-tools

包简介

A Laravel package for video processing powered by FFmpeg

README 文档

README

A Laravel package for video processing powered by FFmpeg. It supports trimming, extracting audio, generating thumbnails, merging videos, resizing, and adding watermarks.

Installation

Install the package via Composer:

composer require sonphoenix/laravel-video-tools

Requirements

PHP 8.1 or higher

FFmpeg installed on your system

Laravel 9.x or higher

Usage/Examples

use SonPhoenix\VideoTools\Facades\VideoTools;

// Trim a video
VideoTools::trim('input.mp4', 'output.mp4', '0:01:30', '0:00:15');

// Extract a thumbnail
VideoTools::thumbnail('input.mp4', 'thumbnail.jpg', '0:00:05');

// Extract audio
VideoTools::extractAudio('input.mp4', 'output.mp3', 'mp3');

// Merge videos
VideoTools::merge(['video1.mp4', 'video2.mp4'], 'merged.mp4');

// Add watermark
VideoTools::addWatermark('input.mp4', 'output.mp4', 'watermark.png', 'bottom-right');

// Resize video
VideoTools::resize('input.mp4', 'output.mp4', 640, 480, true);

API Reference

trim or cut video

trim(input, output, start, duration)
Parameter Type Description
input string Path to input video
output string Path to save trimmed video
start string Start time (hh:mm:ss, mm:ss)
duration string Duration of clip (hh:mm:ss)

examples

VideoTools::trim('input.mp4', 'output.mp4', '0:01:30', '0:00:15');

get thumbnail from video

thumbnail(inputPath, outputPath, time)
Parameter Type Description
inputPath string Path to input video
outputPath string Path to save thumbnail
time string Time position (hh:mm:ss or seconds)

examples

VideoTools::thumbnail('input.mp4', 'thumbnail.jpg', '0:00:05');

get audio from video

extractAudio(input, output, format)
Parameter Type Description
inputPath string Path to input video
outputPath string Path to save thumbnail
time string Time position (hh:mm:ss or seconds)

examples

VideoTools::extractAudio('input.mp4', 'output.mp3', 'mp3');

add watermark to video

addWatermark(input, output, watermarkPath, position, x, y, width, height, opacity)
Parameter Type Description
input string Path to input video
output string Path to save watermarked video
watermarkPath string Path to watermark image
position string Position (top-left, top-right, bottom-left, bottom-right, center)
x int X offset in pixels
y int Y offset in pixels
width int Width to resize watermark (optional)
height int Height to resize watermark (optional)
opacity float Watermark opacity (0 = transparent, 1 = opaque)

examples

// Position watermark at bottom-right
VideoTools::addWatermark('input.mp4', 'output.mp4', 'watermark.png', 'bottom-right');

// Custom position and size
VideoTools::addWatermark(
    'input.mp4', 
    'output.mp4', 
    'watermark.png', 
    null, 
    50, 
    50, 
    100, 
    50, 
    0.7
);

merge or fusion a bunch of videos

merge(inputs, output)
Parameter Type Description
inputs array Array of input video paths
output string Path to save merged video

examples

VideoTools::merge(['video1.mp4', 'video2.mp4'], 'merged.mp4');

resize a video

resize(input, output, width, height, keepAspect)
Parameter Type Description
input string Path to input video
output string Path to save resized video
width int Target width
height int Target height
keepAspect bool Keep aspect ratio (true/false)

examples

VideoTools::resize('input.mp4', 'output.mp4', 1280, 720, true);

Authors

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固