2017 © Pedro Peláez
 

library phplame

PHP wrapper for LAME (MP3 encoder)

image

b-b3rn4rd/phplame

PHP wrapper for LAME (MP3 encoder)

  • Tuesday, December 23, 2014
  • by b-b3rn4rd
  • Repository
  • 3 Watchers
  • 10 Stars
  • 6,787 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 1 Versions
  • 27 % Grown

The README.md

PHP LAME

Build Status Coverage Status, (*1)

PHP LAME is a php wrapper for LAME MP3 encoder. It provides convenient interface to encode wav file(s) into mp3., (*2)

In order to use this library you will need to download & install LAME. Read here how to install it., (*3)

## Installation

Install PHP LAME wrapper using Composer:, (*4)

{
    "require": {
        "b-b3rn4rd/phplame": "dev-master"
    }
}

##Usage examples

Encode single file using preset settings

<?php
require 'vendor/autoload.php';

use Lame\Lame;
use Lame\Settings;

// encoding type
$encoding = new Settings\Encoding\Preset();
$encoding->setType(Settings\Encoding\Preset::TYPE_STANDARD);

// lame settings
$settings = new Settings\Settings($encoding);

// lame wrapper
$lame = new Lame('/usr/bin/lame', $settings);

try {
    $lame->encode("/home/bernard/Music/B.W. Souls - Marvin's Groove.wav", 
        "/home/bernard/Music/mp3/B.W. Souls - Marvin's Groove.mp3");
} catch(\RuntimeException $e) {
    var_dump($e->getMessage());
} 

The example above executed following command: /usr/bin/lame --preset standard '/home/bernard/Music/B.W. Souls - Marvin'\\''s Groove.wav' '/home/bernard/Music/mp3/B.W. Souls - Marvin'\\''s Groove.mp3', (*5)

Encode multiple files using VBR encoding and additional settings

<?php
require 'vendor/autoload.php';

use Lame\Lame;
use Lame\Settings;

// encoding type
$encoding = new Settings\Encoding\VBR();
$encoding->setMinBitrate(320);

// lame settings
$settings = new Settings\Settings($encoding);
$settings->setAlgorithmQuality(0);

// lame wrapper
$lame = new Lame('/usr/bin/lame', $settings);

try {
    $lame->encode("/home/bernard/Music/*.wav", "/home/bernard/Music/mp3/");
} catch(\RuntimeException $e) {
    var_dump($e->getMessage());
} 

Lame command was executed for each file found in $inputfile path with following options: /usr/bin/lame -q 0 -b 320 '/home/bernard/Music/B.W. Souls - Marvin'\\''s Groove.wav' '/home/bernard/Music/mp3/B.W. Souls - Marvin'\\''s Groove.mp3' etc..., (*6)

Encode single file using manually specified settings and optional callback

<?php
require 'vendor/autoload.php';

use Lame\Lame;
use Lame\Settings;

// encoding type
$encoding = new Settings\Encoding\NullEncoding();

// lame settings
$settings = new Settings\Settings($encoding, array(
    '-V'        => 0,
    '--vbr-new' => true,
    '-q'        => 0,
    '-m'        => 's'
));

// lame wrapper
$lame = new Lame('/usr/bin/lame', $settings);

try {
    $lame->encode("/home/bernard/Music/Benny Gordon - Give A Damn.wav", 
        "/home/bernard/Music/mp3/", function($inputfile, $outputfile) {
            unlink($inputfile);
        });
} catch(\RuntimeException $e) {
    var_dump($e->getMessage());
} 

This example uses optional callback to remove $inputfile after it was encoded. Callback is executed each time after a file has been encoded., (*7)

## Encoding types

PHP LAME provides following encoding interfaces: - \Lame\Settings\Bitrate\ABR — Average Bitrate Encoding (ABR) related options - \Lame\Settings\Bitrate\CBR — Constant Bitrate Encoding (CBR) related options - \Lame\Settings\Encoding\VBR — \Lame\Settings\Encoding\VBR related options - \Lame\Settings\Encoding\Preset — Preconfigured settings - \Lame\Settings\Encoding\NullEncoding — no encoding, (*8)

License

[Unlicened][3], (*9)

The Versions

23/12 2014

dev-master

9999999-dev

PHP wrapper for LAME (MP3 encoder)

  Sources   Download

The Requires

  • php >=5.3

 

The Development Requires

by Bernard Baltrusaitis

wrapper mp3 encoder lame-php mp3 encoder