PHPackages                             captbaritone/transcode-to-mp3-stream - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. captbaritone/transcode-to-mp3-stream

ActiveLibrary

captbaritone/transcode-to-mp3-stream
====================================

Transcode various audio formats to mp3 streams on the fly

231.6k↑275%3PHP

Since Feb 27Pushed 8y ago3 watchersCompare

[ Source](https://github.com/captbaritone/transcode-to-mp3-stream)[ Packagist](https://packagist.org/packages/captbaritone/transcode-to-mp3-stream)[ RSS](/packages/captbaritone-transcode-to-mp3-stream/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Transcode to MP3 Stream PHP Library
===================================

[](#transcode-to-mp3-stream-php-library)

[![Build Status](https://camo.githubusercontent.com/f76ee0bace9cfee1c88f5c0de6cddf0f6d6b659da9ab4539710343cc1900649d/68747470733a2f2f7472617669732d63692e6f72672f6361707462617269746f6e652f7472616e73636f64652d746f2d6d70332d73747265616d2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/captbaritone/transcode-to-mp3-stream)

Transcode, on the fly, any media file that ffmpeg can read into an MP3 stream playable natively by any modern browser. The library handles the annoying requirements of generating the correct headers and relies on ffmpeg to handle the actual transcoding.

Useful for cases where you have a large collection of audio files which you want users to be able to stream, but don't wish to transcode them all in advance.

Works well with HTML5/JS audio players such as [audio.js](http://kolber.github.io/audiojs/).

Status
------

[](#status)

Beta. This package is working, but may still have some kinks to workout.

Dependencies
------------

[](#dependencies)

We require shell access to `ffmpeg` with the `lame` codec for mp3 encoding. We also require a newish version of `ffprobe` (which comes with `ffmpeg`). However, the current version of in the Ubuntu repository is not modern enough. I'll update with more on that later.

On Ubuntu, these packages do the trick for me:

```
sudo apt-get install ffmpeg
sudo apt-get install libavcodec-extra-53

```

Installation
------------

[](#installation)

Add this line to your `composer.json` file's "require" section:

```
"captbaritone/transcode-to-mp3-stream": "dev-master"

```

Then issue at the command line, in your projects directory:

```
composer update

```

Usage
-----

[](#usage)

I'm assuming, you have the package installed via composer.

The only method you should need is `output()` on the `Mp3Stream` object. It takes the following arguments, of which only the first is required:

- `$sourceMedia` Path to the file you wish to transcode
- `$outputFilename` The filename for the transcoded output
- `$kbps` The constant bitrate bits per second to encode the output with
- `$start` The point in the source where we want to start (in seconds)
- `$end` The point in the source where we want to stop (in seconds)

### Simple usage:

[](#simple-usage)

```
