vasictech / encoder by vasictech

Laravel package for encoding video files using FFMpeg
16
0
0
Package Data
Maintainer Username: vasictech
Maintainer Contact: info@vasictech.com (Aleksandar Vasic)
Package Create Date: 2016-10-04
Package Last Update: 2016-10-04
Language: PHP
License: MIT
Last Refreshed: 2024-12-24 03:03:18
Package Statistics
Total Downloads: 16
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

#Laravel Encoder (Alpha) 1.0

An OOP Laravel package user for encoding video files with FFMPEG

Package is currently in Alpha stage, with small amount of functions, and it will be constanly upgrade with a lot different features

This library requires a working FFMpeg install.

Installation

The recommended way to install Encoder is through Composer.

{
    "require": {
        "vasictech/encoder": "~1.0"
    }
}

Register package as service in config/app.php

return [
    VasicTech\Encoder\EncoderServiceProvider::class,
]

Execute config publish

return [
    'encoder' => 'ffmpeg',

    'ffmpeg' => [
        'path' => '/usr/bin/ffmpeg',
        'codecs' => [
            'video' => 'libx264',
            'audio' => 'aac',
        ],
        'options' => [
            'strict' => true,
            'replace' => true,
            'fork' => true,
            'log' => storage_path(),
        ]
    ]
];

Configure config file

return [
    VasicTech\Encoder\EncoderServiceProvider::class,
]

Basic Usage

$encoder = VasicTech\Encoder\Encoder\FFMpeg();
$jobId = $encoder
    ->input(storage_path('app/public/trailer.mp4'))
    ->output(storage_path('app/public/trailer_enc.mp4'))
    ->execute();

Script returns jobID which can be recorded in database to be connected with files. Output log file will be named as jobID

Documentation

Codec

You can provide both, or just one parameter, first is video codec, second is audio codec

$encoder->codecs('libx264', 'libfaac');

Bitrate

You can provide both, or just one parameter, first is video bitrate, second is audio bitrate

$encoder->bitrate('1200k', '128k');

Size

You can provide both, or just one parameter, first is video width, second is video height, if one is not provided, video will scale to provided size

$encoder->size(1280, 720);

Replace

If ffmpeg should replace already existing file

$encoder->replace(true);

Strict

If '-strict -2' parameter should be added

$encoder->strict(true);

Fork

If process should be forked

$encoder->fork(true);

Log

If ffmpeg should write to log file

$encoder->log('/path/to/file.log');

Format

Force output format

$encoder->format('mp4');

License

This project is licensed under the MIT license.